MOS Source Code
Loading...
Searching...
No Matches
cpuid.h File Reference
#include <mos/mos_global.h>
#include <mos/types.h>
+ Include dependency graph for cpuid.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CPU_FEATURE_FPU   1, 0, d, 0
 ! this feature list must start at line 9 for correct counting (see below...)
 
#define CPU_FEATURE_VME   1, 0, d, 1
 
#define CPU_FEATURE_DE   1, 0, d, 2
 
#define CPU_FEATURE_PSE   1, 0, d, 3
 
#define CPU_FEATURE_TSC   1, 0, d, 4
 
#define CPU_FEATURE_MSR   1, 0, d, 5
 
#define CPU_FEATURE_PAE   1, 0, d, 6
 
#define CPU_FEATURE_MCE   1, 0, d, 7
 
#define CPU_FEATURE_CX8   1, 0, d, 8
 
#define CPU_FEATURE_APIC   1, 0, d, 9
 
#define CPU_FEATURE_SEP   1, 0, d, 11
 
#define CPU_FEATURE_MTRR   1, 0, d, 12
 
#define CPU_FEATURE_PGE   1, 0, d, 13
 
#define CPU_FEATURE_MCA   1, 0, d, 14
 
#define CPU_FEATURE_CMOV   1, 0, d, 15
 
#define CPU_FEATURE_PAT   1, 0, d, 16
 
#define CPU_FEATURE_PSE36   1, 0, d, 17
 
#define CPU_FEATURE_PSN   1, 0, d, 18
 
#define CPU_FEATURE_CLFSH   1, 0, d, 19
 
#define CPU_FEATURE_DS   1, 0, d, 21
 
#define CPU_FEATURE_ACPI   1, 0, d, 22
 
#define CPU_FEATURE_MMX   1, 0, d, 23
 
#define CPU_FEATURE_FXSR   1, 0, d, 24
 
#define CPU_FEATURE_SSE   1, 0, d, 25
 
#define CPU_FEATURE_SSE2   1, 0, d, 26
 
#define CPU_FEATURE_SS   1, 0, d, 27
 
#define CPU_FEATURE_HTT   1, 0, d, 28
 
#define CPU_FEATURE_TM1   1, 0, d, 29
 
#define CPU_FEATURE_IA64   1, 0, d, 30
 
#define CPU_FEATURE_PBE   1, 0, d, 31
 
#define CPU_FEATURE_SSE3   1, 0, c, 0
 
#define CPU_FEATURE_SSSE3   1, 0, c, 9
 
#define CPU_FEATURE_PCID   1, 0, c, 17
 
#define CPU_FEATURE_DCA   1, 0, c, 18
 
#define CPU_FEATURE_SSE4_1   1, 0, c, 19
 
#define CPU_FEATURE_SSE4_2   1, 0, c, 20
 
#define CPU_FEATURE_X2APIC   1, 0, c, 21
 
#define CPU_FEATURE_MOVBE   1, 0, c, 22
 
#define CPU_FEATURE_POPCNT   1, 0, c, 23
 
#define CPU_FEATURE_TSC_DEADLINE   1, 0, c, 24
 
#define CPU_FEATURE_AES_NI   1, 0, c, 25
 
#define CPU_FEATURE_XSAVE   1, 0, c, 26
 
#define CPU_FEATURE_OSXSAVE   1, 0, c, 27
 
#define CPU_FEATURE_AVX   1, 0, c, 28
 
#define CPU_FEATURE_F16C   1, 0, c, 29
 
#define CPU_FEATURE_RDRAND   1, 0, c, 30
 
#define CPU_FEATURE_HYPERVISOR   1, 0, c, 31
 
#define CPU_FEATURE_AVX2   7, 0, b, 5
 
#define CPU_FEATURE_FSGSBASE   7, 0, b, 0
 
#define CPU_FEATURE_LA57   7, 0, c, 16
 
#define CPU_FEATURE_XSAVES   0xd, 1, a, 3
 
#define CPU_FEATURE_NX   0x80000001, 0, d, 20
 
#define CPU_FEATURE_PDPE1GB   0x80000001, 0, d, 26
 
#define FOR_ALL_CPU_FEATURES(M)
 
#define _do_count(leaf)
 
#define x86_cpu_get_feature_impl(leaf, subleaf, reg, bit)
 
#define cpu_has_feature(feat)
 
#define FOR_ALL_SUPPORTED_CPUID_LEAF(M)
 
#define X86_CPUID_LEAF_ENUM(leaf, subleaf, reg, ...)
 
#define _do_define_enum(leaf, subleaf, reg)
 
#define XCR0_X87   BIT(0)
 
#define XCR0_SSE   BIT(1)
 
#define XCR0_AVX   BIT(2)
 
#define XCR0_BNDREGS   BIT(3)
 
#define XCR0_BNDCSR   BIT(4)
 
#define XCR0_OPMASK   BIT(5)
 
#define XCR0_ZMM_Hi256   BIT(6)
 
#define XCR0_Hi16_ZMM   BIT(7)
 
#define XCR0_PT   BIT(8)
 
#define XCR0_PKRU   BIT(9)
 
#define XCR0_PASID   BIT(10)
 
#define XCR0_CET_U   BIT(11)
 
#define XCR0_CET_S   BIT(12)
 
#define XCR0_HDC   BIT(13)
 
#define XCR0_UINTR   BIT(14)
 
#define XCR0_LBR   BIT(15)
 
#define XCR0_HMP   BIT(16)
 
#define XCR0_AMX_TILECFG   BIT(17)
 
#define XCR0_AMX_TILEDATA   BIT(18)
 
#define XCR0_APX_EXGPRS   BIT(19)
 

Typedefs

typedef reg32_t x86_cpuid_array[_X86_CPUID_COUNT]
 

Enumerations

enum  {
  X86_CPUID_1_0_d , X86_CPUID_1_0_c , X86_CPUID_7_0_b , X86_CPUID_7_0_c ,
  X86_CPUID_0xd_1_a , X86_CPUID_0x80000001_0_d , _X86_CPUID_COUNT
}
 

Functions

 MOS_STATIC_ASSERT (sizeof((int[]){ __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, })/sizeof(int)==__LINE__ - 21, "FOR_ALL_CPU_FEATURES is incomplete")
 

Macro Definition Documentation

◆ CPU_FEATURE_FPU

#define CPU_FEATURE_FPU   1, 0, d, 0

! this feature list must start at line 9 for correct counting (see below...)

Definition at line 9 of file cpuid.h.

◆ CPU_FEATURE_VME

#define CPU_FEATURE_VME   1, 0, d, 1

Definition at line 10 of file cpuid.h.

◆ CPU_FEATURE_DE

#define CPU_FEATURE_DE   1, 0, d, 2

Definition at line 11 of file cpuid.h.

◆ CPU_FEATURE_PSE

#define CPU_FEATURE_PSE   1, 0, d, 3

Definition at line 12 of file cpuid.h.

◆ CPU_FEATURE_TSC

#define CPU_FEATURE_TSC   1, 0, d, 4

Definition at line 13 of file cpuid.h.

◆ CPU_FEATURE_MSR

#define CPU_FEATURE_MSR   1, 0, d, 5

Definition at line 14 of file cpuid.h.

Referenced by lapic_memory_setup().

◆ CPU_FEATURE_PAE

#define CPU_FEATURE_PAE   1, 0, d, 6

Definition at line 15 of file cpuid.h.

◆ CPU_FEATURE_MCE

#define CPU_FEATURE_MCE   1, 0, d, 7

Definition at line 16 of file cpuid.h.

◆ CPU_FEATURE_CX8

#define CPU_FEATURE_CX8   1, 0, d, 8

Definition at line 17 of file cpuid.h.

◆ CPU_FEATURE_APIC

#define CPU_FEATURE_APIC   1, 0, d, 9

Definition at line 18 of file cpuid.h.

Referenced by lapic_memory_setup().

◆ CPU_FEATURE_SEP

#define CPU_FEATURE_SEP   1, 0, d, 11

Definition at line 19 of file cpuid.h.

◆ CPU_FEATURE_MTRR

#define CPU_FEATURE_MTRR   1, 0, d, 12

Definition at line 20 of file cpuid.h.

◆ CPU_FEATURE_PGE

#define CPU_FEATURE_PGE   1, 0, d, 13

Definition at line 21 of file cpuid.h.

◆ CPU_FEATURE_MCA

#define CPU_FEATURE_MCA   1, 0, d, 14

Definition at line 22 of file cpuid.h.

◆ CPU_FEATURE_CMOV

#define CPU_FEATURE_CMOV   1, 0, d, 15

Definition at line 23 of file cpuid.h.

◆ CPU_FEATURE_PAT

#define CPU_FEATURE_PAT   1, 0, d, 16

Definition at line 24 of file cpuid.h.

◆ CPU_FEATURE_PSE36

#define CPU_FEATURE_PSE36   1, 0, d, 17

Definition at line 25 of file cpuid.h.

◆ CPU_FEATURE_PSN

#define CPU_FEATURE_PSN   1, 0, d, 18

Definition at line 26 of file cpuid.h.

◆ CPU_FEATURE_CLFSH

#define CPU_FEATURE_CLFSH   1, 0, d, 19

Definition at line 27 of file cpuid.h.

◆ CPU_FEATURE_DS

#define CPU_FEATURE_DS   1, 0, d, 21

Definition at line 28 of file cpuid.h.

◆ CPU_FEATURE_ACPI

#define CPU_FEATURE_ACPI   1, 0, d, 22

Definition at line 29 of file cpuid.h.

◆ CPU_FEATURE_MMX

#define CPU_FEATURE_MMX   1, 0, d, 23

Definition at line 30 of file cpuid.h.

◆ CPU_FEATURE_FXSR

#define CPU_FEATURE_FXSR   1, 0, d, 24

Definition at line 31 of file cpuid.h.

Referenced by x86_cpu_initialise_caps().

◆ CPU_FEATURE_SSE

#define CPU_FEATURE_SSE   1, 0, d, 25

Definition at line 32 of file cpuid.h.

Referenced by x86_cpu_initialise_caps().

◆ CPU_FEATURE_SSE2

#define CPU_FEATURE_SSE2   1, 0, d, 26

Definition at line 33 of file cpuid.h.

◆ CPU_FEATURE_SS

#define CPU_FEATURE_SS   1, 0, d, 27

Definition at line 34 of file cpuid.h.

◆ CPU_FEATURE_HTT

#define CPU_FEATURE_HTT   1, 0, d, 28

Definition at line 35 of file cpuid.h.

◆ CPU_FEATURE_TM1

#define CPU_FEATURE_TM1   1, 0, d, 29

Definition at line 36 of file cpuid.h.

◆ CPU_FEATURE_IA64

#define CPU_FEATURE_IA64   1, 0, d, 30

Definition at line 37 of file cpuid.h.

◆ CPU_FEATURE_PBE

#define CPU_FEATURE_PBE   1, 0, d, 31

Definition at line 38 of file cpuid.h.

◆ CPU_FEATURE_SSE3

#define CPU_FEATURE_SSE3   1, 0, c, 0

Definition at line 39 of file cpuid.h.

◆ CPU_FEATURE_SSSE3

#define CPU_FEATURE_SSSE3   1, 0, c, 9

Definition at line 40 of file cpuid.h.

◆ CPU_FEATURE_PCID

#define CPU_FEATURE_PCID   1, 0, c, 17

Definition at line 41 of file cpuid.h.

◆ CPU_FEATURE_DCA

#define CPU_FEATURE_DCA   1, 0, c, 18

Definition at line 42 of file cpuid.h.

◆ CPU_FEATURE_SSE4_1

#define CPU_FEATURE_SSE4_1   1, 0, c, 19

Definition at line 43 of file cpuid.h.

◆ CPU_FEATURE_SSE4_2

#define CPU_FEATURE_SSE4_2   1, 0, c, 20

Definition at line 44 of file cpuid.h.

◆ CPU_FEATURE_X2APIC

#define CPU_FEATURE_X2APIC   1, 0, c, 21

Definition at line 45 of file cpuid.h.

◆ CPU_FEATURE_MOVBE

#define CPU_FEATURE_MOVBE   1, 0, c, 22

Definition at line 46 of file cpuid.h.

◆ CPU_FEATURE_POPCNT

#define CPU_FEATURE_POPCNT   1, 0, c, 23

Definition at line 47 of file cpuid.h.

◆ CPU_FEATURE_TSC_DEADLINE

#define CPU_FEATURE_TSC_DEADLINE   1, 0, c, 24

Definition at line 48 of file cpuid.h.

◆ CPU_FEATURE_AES_NI

#define CPU_FEATURE_AES_NI   1, 0, c, 25

Definition at line 49 of file cpuid.h.

◆ CPU_FEATURE_XSAVE

#define CPU_FEATURE_XSAVE   1, 0, c, 26

Definition at line 50 of file cpuid.h.

Referenced by x86_cpu_initialise_caps().

◆ CPU_FEATURE_OSXSAVE

#define CPU_FEATURE_OSXSAVE   1, 0, c, 27

Definition at line 51 of file cpuid.h.

◆ CPU_FEATURE_AVX

#define CPU_FEATURE_AVX   1, 0, c, 28

Definition at line 52 of file cpuid.h.

Referenced by x86_cpu_setup_xsave_area().

◆ CPU_FEATURE_F16C

#define CPU_FEATURE_F16C   1, 0, c, 29

Definition at line 53 of file cpuid.h.

◆ CPU_FEATURE_RDRAND

#define CPU_FEATURE_RDRAND   1, 0, c, 30

Definition at line 54 of file cpuid.h.

◆ CPU_FEATURE_HYPERVISOR

#define CPU_FEATURE_HYPERVISOR   1, 0, c, 31

Definition at line 55 of file cpuid.h.

◆ CPU_FEATURE_AVX2

#define CPU_FEATURE_AVX2   7, 0, b, 5

Definition at line 56 of file cpuid.h.

◆ CPU_FEATURE_FSGSBASE

#define CPU_FEATURE_FSGSBASE   7, 0, b, 0

Definition at line 57 of file cpuid.h.

Referenced by x86_cpu_initialise_caps().

◆ CPU_FEATURE_LA57

#define CPU_FEATURE_LA57   7, 0, c, 16

Definition at line 58 of file cpuid.h.

◆ CPU_FEATURE_XSAVES

#define CPU_FEATURE_XSAVES   0xd, 1, a, 3

Definition at line 59 of file cpuid.h.

◆ CPU_FEATURE_NX

#define CPU_FEATURE_NX   0x80000001, 0, d, 20

Definition at line 60 of file cpuid.h.

◆ CPU_FEATURE_PDPE1GB

#define CPU_FEATURE_PDPE1GB   0x80000001, 0, d, 26

Definition at line 61 of file cpuid.h.

Referenced by x86_setup_direct_map().

◆ FOR_ALL_CPU_FEATURES

#define FOR_ALL_CPU_FEATURES ( M)
Value:
M(FPU) M(VME) M(DE) M(PSE) M(TSC) M(MSR) M(PAE) M(MCE) M(CX8) M(APIC) \
M(SEP) M(MTRR) M(PGE) M(MCA) M(CMOV) M(PAT) M(PSE36) M(PSN) M(CLFSH) M(DS) \
M(ACPI) M(MMX) M(FXSR) M(SSE) M(SSE2) M(SS) M(HTT) M(TM1) M(IA64) M(PBE) \
M(SSE3) M(SSSE3) M(PCID) M(DCA) M(SSE4_1) M(SSE4_2) M(X2APIC) M(MOVBE) M(POPCNT) M(TSC_DEADLINE) \
M(AES_NI) M(XSAVE) M(OSXSAVE) M(AVX) M(F16C) M(RDRAND) M(HYPERVISOR) M(AVX2) M(FSGSBASE) M(LA57) \
M(XSAVES) M(NX) M(PDPE1GB)

Definition at line 64 of file cpuid.h.

Referenced by MOS_STATIC_ASSERT(), and platform_startup_early().

◆ _do_count

#define _do_count ( leaf)
Value:
__COUNTER__,

Definition at line 73 of file cpuid.h.

Referenced by MOS_STATIC_ASSERT().

◆ x86_cpu_get_feature_impl

#define x86_cpu_get_feature_impl ( leaf,
subleaf,
reg,
bit )
Value:
(per_cpu(platform_info->cpu)->cpuinfo.cpuid[X86_CPUID_LEAF_ENUM(leaf, subleaf, reg, )] & (1 << bit))
#define X86_CPUID_LEAF_ENUM(leaf, subleaf, reg,...)
Definition cpuid.h:89
#define per_cpu(var)
Definition platform.h:25
mos_platform_info_t *const platform_info
struct mos_platform_info_t::cpu cpu

Definition at line 77 of file cpuid.h.

◆ cpu_has_feature

#define cpu_has_feature ( feat)
Value:
#define x86_cpu_get_feature_impl(leaf, subleaf, reg, bit)
Definition cpuid.h:77

Definition at line 79 of file cpuid.h.

Referenced by lapic_memory_setup(), x86_cpu_initialise_caps(), x86_cpu_setup_xsave_area(), and x86_setup_direct_map().

◆ FOR_ALL_SUPPORTED_CPUID_LEAF

#define FOR_ALL_SUPPORTED_CPUID_LEAF ( M)
Value:
M(1, 0, d) \
M(1, 0, c) \
M(7, 0, b) \
M(7, 0, c) \
M(0xd, 1, a) \
M(0x80000001, 0, d)

Definition at line 81 of file cpuid.h.

Referenced by x86_cpu_initialise_caps().

◆ X86_CPUID_LEAF_ENUM

#define X86_CPUID_LEAF_ENUM ( leaf,
subleaf,
reg,
... )
Value:
X86_CPUID_##leaf##_##subleaf##_##reg

Definition at line 89 of file cpuid.h.

◆ _do_define_enum

#define _do_define_enum ( leaf,
subleaf,
reg )
Value:
X86_CPUID_LEAF_ENUM(leaf, subleaf, reg, _unused_),

Definition at line 93 of file cpuid.h.

◆ XCR0_X87

#define XCR0_X87   BIT(0)

Definition at line 101 of file cpuid.h.

Referenced by x86_cpu_setup_xsave_area().

◆ XCR0_SSE

#define XCR0_SSE   BIT(1)

Definition at line 102 of file cpuid.h.

Referenced by x86_cpu_setup_xsave_area().

◆ XCR0_AVX

#define XCR0_AVX   BIT(2)

Definition at line 103 of file cpuid.h.

Referenced by x86_cpu_setup_xsave_area().

◆ XCR0_BNDREGS

#define XCR0_BNDREGS   BIT(3)

Definition at line 104 of file cpuid.h.

◆ XCR0_BNDCSR

#define XCR0_BNDCSR   BIT(4)

Definition at line 105 of file cpuid.h.

◆ XCR0_OPMASK

#define XCR0_OPMASK   BIT(5)

Definition at line 106 of file cpuid.h.

◆ XCR0_ZMM_Hi256

#define XCR0_ZMM_Hi256   BIT(6)

Definition at line 107 of file cpuid.h.

◆ XCR0_Hi16_ZMM

#define XCR0_Hi16_ZMM   BIT(7)

Definition at line 108 of file cpuid.h.

◆ XCR0_PT

#define XCR0_PT   BIT(8)

Definition at line 109 of file cpuid.h.

◆ XCR0_PKRU

#define XCR0_PKRU   BIT(9)

Definition at line 110 of file cpuid.h.

◆ XCR0_PASID

#define XCR0_PASID   BIT(10)

Definition at line 111 of file cpuid.h.

◆ XCR0_CET_U

#define XCR0_CET_U   BIT(11)

Definition at line 112 of file cpuid.h.

◆ XCR0_CET_S

#define XCR0_CET_S   BIT(12)

Definition at line 113 of file cpuid.h.

◆ XCR0_HDC

#define XCR0_HDC   BIT(13)

Definition at line 114 of file cpuid.h.

◆ XCR0_UINTR

#define XCR0_UINTR   BIT(14)

Definition at line 115 of file cpuid.h.

◆ XCR0_LBR

#define XCR0_LBR   BIT(15)

Definition at line 116 of file cpuid.h.

◆ XCR0_HMP

#define XCR0_HMP   BIT(16)

Definition at line 117 of file cpuid.h.

◆ XCR0_AMX_TILECFG

#define XCR0_AMX_TILECFG   BIT(17)

Definition at line 118 of file cpuid.h.

◆ XCR0_AMX_TILEDATA

#define XCR0_AMX_TILEDATA   BIT(18)

Definition at line 119 of file cpuid.h.

◆ XCR0_APX_EXGPRS

#define XCR0_APX_EXGPRS   BIT(19)

Definition at line 120 of file cpuid.h.

Typedef Documentation

◆ x86_cpuid_array

typedef reg32_t x86_cpuid_array[_X86_CPUID_COUNT]

Definition at line 99 of file cpuid.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
X86_CPUID_1_0_d 
X86_CPUID_1_0_c 
X86_CPUID_7_0_b 
X86_CPUID_7_0_c 
X86_CPUID_0xd_1_a 
X86_CPUID_0x80000001_0_d 
_X86_CPUID_COUNT 

Definition at line 91 of file cpuid.h.

Function Documentation

◆ MOS_STATIC_ASSERT()

MOS_STATIC_ASSERT ( sizeof((int[]){ __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, __COUNTER__, })/sizeof(int) = =__LINE__ - 21,
"FOR_ALL_CPU_FEATURES is incomplete"  )