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