Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/include/cpu_feat.h
| Show All 23 Lines | |||||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| * SUCH DAMAGE. | * SUCH DAMAGE. | ||||
| */ | */ | ||||
| #ifndef _MACHINE_CPU_FEAT_H_ | #ifndef _MACHINE_CPU_FEAT_H_ | ||||
| #define _MACHINE_CPU_FEAT_H_ | #define _MACHINE_CPU_FEAT_H_ | ||||
| #include <sys/linker_set.h> | #include <sys/linker_set.h> | ||||
| #include <sys/sysctl.h> | |||||
| typedef enum { | typedef enum { | ||||
| ERRATA_UNKNOWN, /* Unknown erratum */ | ERRATA_UNKNOWN, /* Unknown erratum */ | ||||
| ERRATA_NONE, /* No errata for this feature on this system. */ | ERRATA_NONE, /* No errata for this feature on this system. */ | ||||
| ERRATA_AFFECTED, /* There is errata on this system. */ | ERRATA_AFFECTED, /* There is errata on this system. */ | ||||
| ERRATA_FW_MITIGAION, /* There is errata, and a firmware */ | ERRATA_FW_MITIGAION, /* There is errata, and a firmware */ | ||||
| /* mitigation. The mitigation may need a */ | /* mitigation. The mitigation may need a */ | ||||
| /* kernel component. */ | /* kernel component. */ | ||||
| } cpu_feat_errata; | } cpu_feat_errata; | ||||
| #define CPU_FEAT_STAGE_MASK 0x00000001 | #define CPU_FEAT_STAGE_MASK 0x00000001 | ||||
| #define CPU_FEAT_EARLY_BOOT 0x00000000 | #define CPU_FEAT_EARLY_BOOT 0x00000000 | ||||
| #define CPU_FEAT_AFTER_DEV 0x00000001 | #define CPU_FEAT_AFTER_DEV 0x00000001 | ||||
| #define CPU_FEAT_SCOPE_MASK 0x00000010 | #define CPU_FEAT_SCOPE_MASK 0x00000010 | ||||
| #define CPU_FEAT_PER_CPU 0x00000000 | #define CPU_FEAT_PER_CPU 0x00000000 | ||||
| #define CPU_FEAT_SYSTEM 0x00000010 | #define CPU_FEAT_SYSTEM 0x00000010 | ||||
| struct cpu_feat; | struct cpu_feat; | ||||
| typedef bool (cpu_feat_check)(const struct cpu_feat *, u_int); | typedef bool (cpu_feat_check)(const struct cpu_feat *, u_int); | ||||
| typedef bool (cpu_feat_has_errata)(const struct cpu_feat *, u_int, | typedef bool (cpu_feat_has_errata)(const struct cpu_feat *, u_int, | ||||
| u_int **, u_int *); | u_int **, u_int *); | ||||
| typedef void (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata, | typedef bool (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata, | ||||
| u_int *, u_int); | u_int *, u_int); | ||||
| struct cpu_feat { | struct cpu_feat { | ||||
| const char *feat_name; | const char *feat_name; | ||||
| cpu_feat_check *feat_check; | cpu_feat_check *feat_check; | ||||
| cpu_feat_has_errata *feat_has_errata; | cpu_feat_has_errata *feat_has_errata; | ||||
| cpu_feat_enable *feat_enable; | cpu_feat_enable *feat_enable; | ||||
| uint32_t feat_flags; | uint32_t feat_flags; | ||||
| bool feat_enabled; | |||||
| }; | }; | ||||
| SET_DECLARE(cpu_feat_set, struct cpu_feat); | SET_DECLARE(cpu_feat_set, struct cpu_feat); | ||||
| #define CPU_FEAT(name, check, has_errata, enable, flags) \ | SYSCTL_DECL(_hw_feat); | ||||
| #define CPU_FEAT(name, descr, check, has_errata, enable, flags) \ | |||||
| static struct cpu_feat name = { \ | static struct cpu_feat name = { \ | ||||
imp: Any reason descr isn't retained somewhere? | |||||
Done Inline ActionsI previously had it in struct cpu_feat, but didn't have a need for it other than in the sysctl below. andrew: I previously had it in `struct cpu_feat`, but didn't have a need for it other than in the… | |||||
| .feat_name = #name, \ | .feat_name = #name, \ | ||||
| .feat_check = check, \ | .feat_check = check, \ | ||||
| .feat_has_errata = has_errata, \ | .feat_has_errata = has_errata, \ | ||||
| .feat_enable = enable, \ | .feat_enable = enable, \ | ||||
| .feat_flags = flags, \ | .feat_flags = flags, \ | ||||
| .feat_enabled = false, \ | |||||
| }; \ | }; \ | ||||
| DATA_SET(cpu_feat_set, name) | DATA_SET(cpu_feat_set, name); \ | ||||
| SYSCTL_BOOL(_hw_feat, OID_AUTO, name, CTLFLAG_RD, &name.feat_enabled, \ | |||||
| 0, descr) | |||||
| /* | /* | ||||
| * Allow drivers to mark an erratum as worked around, e.g. the Errata | * Allow drivers to mark an erratum as worked around, e.g. the Errata | ||||
| * Management ABI may know the workaround isn't needed on a given system. | * Management ABI may know the workaround isn't needed on a given system. | ||||
| */ | */ | ||||
| typedef cpu_feat_errata (*cpu_feat_errata_check_fn)(const struct cpu_feat *, | typedef cpu_feat_errata (*cpu_feat_errata_check_fn)(const struct cpu_feat *, | ||||
| u_int); | u_int); | ||||
| void cpu_feat_register_errata_check(cpu_feat_errata_check_fn); | void cpu_feat_register_errata_check(cpu_feat_errata_check_fn); | ||||
| Show All 15 Lines | |||||
Any reason descr isn't retained somewhere?