iPXE
cpuid.h
Go to the documentation of this file.
1 #ifndef _IPXE_CPUID_H
2 #define _IPXE_CPUID_H
3 
4 /** @file
5  *
6  * x86 CPU feature detection
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stdint.h>
14 
15 /** An x86 CPU feature register set */
17  /** Features returned via %ecx */
19  /** Features returned via %edx */
21 };
22 
23 /** x86 CPU features */
24 struct x86_features {
25  /** Intel-defined features (%eax=0x00000001) */
27  /** AMD-defined features (%eax=0x80000001) */
29 };
30 
31 /** CPUID support flag */
32 #define CPUID_FLAG 0x00200000UL
33 
34 /** CPUID extended function */
35 #define CPUID_EXTENDED 0x80000000UL
36 
37 /** CPUID hypervisor function */
38 #define CPUID_HYPERVISOR 0x40000000UL
39 
40 /** Get vendor ID and largest standard function */
41 #define CPUID_VENDOR_ID 0x00000000UL
42 
43 /** Get standard features */
44 #define CPUID_FEATURES 0x00000001UL
45 
46 /** RDRAND instruction is supported */
47 #define CPUID_FEATURES_INTEL_ECX_RDRAND 0x40000000UL
48 
49 /** Hypervisor is present */
50 #define CPUID_FEATURES_INTEL_ECX_HYPERVISOR 0x80000000UL
51 
52 /** TSC is present */
53 #define CPUID_FEATURES_INTEL_EDX_TSC 0x00000010UL
54 
55 /** FXSAVE and FXRSTOR are supported */
56 #define CPUID_FEATURES_INTEL_EDX_FXSR 0x01000000UL
57 
58 /** Get largest extended function */
59 #define CPUID_AMD_MAX_FN 0x80000000UL
60 
61 /** Extended function existence check */
62 #define CPUID_AMD_CHECK 0x80000000UL
63 
64 /** Extended function existence check mask */
65 #define CPUID_AMD_CHECK_MASK 0xffff0000UL
66 
67 /** Get extended features */
68 #define CPUID_AMD_FEATURES 0x80000001UL
69 
70 /** Get CPU model */
71 #define CPUID_MODEL 0x80000002UL
72 
73 /** Get APM information */
74 #define CPUID_APM 0x80000007UL
75 
76 /** Invariant TSC */
77 #define CPUID_APM_EDX_TSC_INVARIANT 0x00000100UL
78 
79 /**
80  * Issue CPUID instruction
81  *
82  * @v function CPUID function (input via %eax)
83  * @v subfunction CPUID subfunction (input via %ecx)
84  * @v eax Output via %eax
85  * @v ebx Output via %ebx
86  * @v ecx Output via %ecx
87  * @v edx Output via %edx
88  */
89 static inline __attribute__ (( always_inline )) void
92 
93  __asm__ ( "cpuid"
94  : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
95  : "0" ( function ), "2" ( subfunction ) );
96 }
97 
98 extern int cpuid_supported ( uint32_t function );
99 extern void x86_features ( struct x86_features *features );
100 
101 #endif /* _IPXE_CPUID_H */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct x86_feature_registers intel
Intel-defined features (eax=0x00000001)
Definition: cpuid.h:26
x86 CPU features
Definition: cpuid.h:24
struct x86_feature_registers __attribute__
static uint32_t subfunction
Definition: cpuid.h:90
static uint32_t uint32_t uint32_t * ebx
Definition: cpuid.h:90
int cpuid_supported(uint32_t function)
Check whether or not CPUID function is supported.
Definition: cpuid.c:76
uint32_t ecx
Features returned via ecx.
Definition: cpuid.h:18
static uint32_t uint32_t uint32_t uint32_t * ecx
Definition: cpuid.h:90
uint32_t features
Supported features.
Definition: ena.h:16
static uint32_t uint32_t uint32_t uint32_t uint32_t * edx
Definition: cpuid.h:91
void x86_features(struct x86_features *features)
Get x86 CPU features.
Definition: cpuid.c:164
unsigned int uint32_t
Definition: stdint.h:12
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
FILE_SECBOOT(PERMITTED)
uint32_t edx
Features returned via edx.
Definition: cpuid.h:20
struct x86_feature_registers amd
AMD-defined features (eax=0x80000001)
Definition: cpuid.h:28
static uint32_t uint32_t * eax
Definition: cpuid.h:90
An x86 CPU feature register set.
Definition: cpuid.h:16