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 /** Hypervisor is present */
43 #define CPUID_FEATURES_INTEL_ECX_HYPERVISOR 0x80000000UL
44 
45 /** TSC is present */
46 #define CPUID_FEATURES_INTEL_EDX_TSC 0x00000010UL
47 
48 /** FXSAVE and FXRSTOR are supported */
49 #define CPUID_FEATURES_INTEL_EDX_FXSR 0x01000000UL
50 
51 /** Get largest extended function */
52 #define CPUID_AMD_MAX_FN 0x80000000UL
53 
54 /** Extended function existence check */
55 #define CPUID_AMD_CHECK 0x80000000UL
56 
57 /** Extended function existence check mask */
58 #define CPUID_AMD_CHECK_MASK 0xffff0000UL
59 
60 /** Get extended features */
61 #define CPUID_AMD_FEATURES 0x80000001UL
62 
63 /** Get CPU model */
64 #define CPUID_MODEL 0x80000002UL
65 
66 /** Get APM information */
67 #define CPUID_APM 0x80000007UL
68 
69 /** Invariant TSC */
70 #define CPUID_APM_EDX_TSC_INVARIANT 0x00000100UL
71 
72 /**
73  * Issue CPUID instruction
74  *
75  * @v function CPUID function (input via %eax)
76  * @v subfunction CPUID subfunction (input via %ecx)
77  * @v eax Output via %eax
78  * @v ebx Output via %ebx
79  * @v ecx Output via %ecx
80  * @v edx Output via %edx
81  */
82 static inline __attribute__ (( always_inline )) void
85 
86  __asm__ ( "cpuid"
87  : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
88  : "0" ( function ), "2" ( subfunction ) );
89 }
90 
91 extern int cpuid_supported ( uint32_t function );
92 extern void x86_features ( struct x86_features *features );
93 
94 #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:83
static uint32_t uint32_t uint32_t * ebx
Definition: cpuid.h:83
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:83
uint32_t features
Supported features.
Definition: ena.h:16
static uint32_t uint32_t uint32_t uint32_t uint32_t * edx
Definition: cpuid.h:84
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:83
An x86 CPU feature register set.
Definition: cpuid.h:15