Add qemu 2.4.0
[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 );
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 /** Get largest extended function */
43 #define CPUID_AMD_MAX_FN 0x80000000UL
44
45 /** Extended function existence check */
46 #define CPUID_AMD_CHECK 0x80000000UL
47
48 /** Extended function existence check mask */
49 #define CPUID_AMD_CHECK_MASK 0xffff0000UL
50
51 /** Get extended features */
52 #define CPUID_AMD_FEATURES 0x80000001UL
53
54 /** Get CPU model */
55 #define CPUID_MODEL 0x80000002UL
56
57 /**
58  * Issue CPUID instruction
59  *
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
65  */
66 static inline __attribute__ (( always_inline )) void
67 cpuid ( uint32_t operation, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
68         uint32_t *edx ) {
69
70         __asm__ ( "cpuid"
71                   : "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
72                   : "0" ( operation ) );
73 }
74
75 extern int cpuid_is_supported ( void );
76 extern void x86_features ( struct x86_features *features );
77
78 #endif /* _IPXE_CPUID_H */