These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / x86 / include / ipxe / cpuid.h
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 */
15 struct x86_feature_registers {
16         /** Features returned via %ecx */
17         uint32_t ecx;
18         /** Features returned via %edx */
19         uint32_t edx;
20 };
21
22 /** x86 CPU features */
23 struct x86_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;
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 /**
61  * Issue CPUID instruction
62  *
63  * @v operation         CPUID operation
64  * @v eax               Output via %eax
65  * @v ebx               Output via %ebx
66  * @v ecx               Output via %ecx
67  * @v edx               Output via %edx
68  */
69 static inline __attribute__ (( always_inline )) void
70 cpuid ( uint32_t operation, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
71         uint32_t *edx ) {
72
73         __asm__ ( "cpuid"
74                   : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
75                   : "0" ( operation ) );
76 }
77
78 extern int cpuid_is_supported ( void );
79 extern void x86_features ( struct x86_features *features );
80
81 #endif /* _IPXE_CPUID_H */