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