33 #define cpuid(index, eax, ebx, ecx, edx) \
34 ff_cpu_cpuid(index, &eax, &ebx, &ecx, &edx)
36 #define xgetbv(index, eax, edx) \
37 ff_cpu_xgetbv(index, &eax, &edx)
42 #define cpuid(index, eax, ebx, ecx, edx) \
44 "mov %%"REG_b", %%"REG_S" \n\t" \
46 "xchg %%"REG_b", %%"REG_S \
47 : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \
50 #define xgetbv(index, eax, edx) \
51 __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
53 #define get_eflags(x) \
54 __asm__ volatile ("pushfl \n" \
58 #define set_eflags(x) \
59 __asm__ volatile ("push %0 \n" \
67 #define cpuid_test() 1
71 #define cpuid_test ff_cpu_cpuid_test
75 static int cpuid_test(
void)
82 set_eflags(a ^ 0x200000);
96 int eax, ebx, ecx, edx;
97 int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;
98 int family = 0, model = 0;
99 union {
int i[3];
char c[12]; } vendor;
104 cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]);
106 if (max_std_level >= 1) {
107 cpuid(1, eax, ebx, ecx, std_caps);
108 family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
109 model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
110 if (std_caps & (1 << 15))
112 if (std_caps & (1 << 23))
114 if (std_caps & (1 << 25))
117 if (std_caps & (1 << 25))
119 if (std_caps & (1 << 26))
123 if (ecx & 0x00000200 )
125 if (ecx & 0x00080000 )
127 if (ecx & 0x00100000 )
131 if ((ecx & 0x18000000) == 0x18000000) {
134 if ((eax & 0x6) == 0x6) {
136 if (ecx & 0x00001000)
143 if (max_std_level >= 7) {
144 cpuid(7, eax, ebx, ecx, edx);
146 if (ebx & 0x00000020)
150 if (ebx & 0x00000008) {
152 if (ebx & 0x00000100)
157 cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
159 if (max_ext_level >= 0x80000001) {
160 cpuid(0x80000001, eax, ebx, ecx, ext_caps);
161 if (ext_caps & (1
U << 31))
163 if (ext_caps & (1 << 30))
165 if (ext_caps & (1 << 23))
167 if (ext_caps & (1 << 22))
177 if (!strncmp(vendor.c,
"AuthenticAMD", 12) &&
185 if (ecx & 0x00000800)
187 if (ecx & 0x00010000)
192 if (!strncmp(vendor.c,
"GenuineIntel", 12)) {
193 if (family == 6 && (model == 9 || model == 13 || model == 14)) {
211 if (family == 6 && model == 28)