6 * x86 CPU feature detection
10 FILE_LICENCE ( GPL2_OR_LATER );
14 /** An x86 CPU feature register set */
15 struct x86_feature_registers {
16 /** Features returned via %ecx */
18 /** Features returned via %edx */
22 /** x86 CPU features */
24 /** Intel-defined features (%eax=0x00000001) */
25 struct x86_feature_registers intel;
26 /** AMD-defined features (%eax=0x80000001) */
27 struct x86_feature_registers amd;
30 /** CPUID support flag */
31 #define CPUID_FLAG 0x00200000UL
33 /** CPUID extended function */
34 #define CPUID_EXTENDED 0x80000000UL
36 /** Get vendor ID and largest standard function */
37 #define CPUID_VENDOR_ID 0x00000000UL
39 /** Get standard features */
40 #define CPUID_FEATURES 0x00000001UL
42 /** Get largest extended function */
43 #define CPUID_AMD_MAX_FN 0x80000000UL
45 /** Extended function existence check */
46 #define CPUID_AMD_CHECK 0x80000000UL
48 /** Extended function existence check mask */
49 #define CPUID_AMD_CHECK_MASK 0xffff0000UL
51 /** Get extended features */
52 #define CPUID_AMD_FEATURES 0x80000001UL
55 #define CPUID_MODEL 0x80000002UL
58 * Issue CPUID instruction
60 * @v operation CPUID operation
61 * @v eax Output via %eax
62 * @v ebx Output via %ebx
63 * @v ecx Output via %ecx
64 * @v edx Output via %edx
66 static inline __attribute__ (( always_inline )) void
67 cpuid ( uint32_t operation, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
71 : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
72 : "0" ( operation ) );
75 extern int cpuid_is_supported ( void );
76 extern void x86_features ( struct x86_features *features );
78 #endif /* _IPXE_CPUID_H */