29 #define cpuid(index,eax,ebx,ecx,edx)\
31 ("mov %%"REG_b", %%"REG_S"\n\t"\
33 "xchg %%"REG_b", %%"REG_S\
34 : "=a" (eax), "=S" (ebx),\
35 "=c" (ecx), "=d" (edx)\
38 #define xgetbv(index,eax,edx) \
39 __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
45 int eax, ebx, ecx, edx;
46 int max_std_level, max_ext_level, std_caps=0, ext_caps=0;
47 int family=0, model=0;
48 union {
int i[3];
char c[12]; } vendor;
61 "xor $0x200000, %0\n\t"
77 cpuid(0, max_std_level, ebx, ecx, edx);
82 if(max_std_level >= 1){
83 cpuid(1, eax, ebx, ecx, std_caps);
84 family = ((eax>>8)&0xf) + ((eax>>20)&0xff);
85 model = ((eax>>4)&0xf) + ((eax>>12)&0xf0);
86 if (std_caps & (1 << 15))
88 if (std_caps & (1<<23))
90 if (std_caps & (1<<25))
94 if (std_caps & (1<<26))
98 if (ecx & 0x00000200 )
100 if (ecx & 0x00080000 )
102 if (ecx & 0x00100000 )
106 if ((ecx & 0x18000000) == 0x18000000) {
109 if ((eax & 0x6) == 0x6)
117 cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
119 if(max_ext_level >= 0x80000001){
120 cpuid(0x80000001, eax, ebx, ecx, ext_caps);
121 if (ext_caps & (1
U<<31))
123 if (ext_caps & (1<<30))
125 if (ext_caps & (1<<23))
127 if (ext_caps & (1<<22))
137 if (!strncmp(vendor.c,
"AuthenticAMD", 12) &&
145 if (ecx & 0x00000800)
147 if (ecx & 0x00010000)
152 if (!strncmp(vendor.c,
"GenuineIntel", 12)) {
153 if (family == 6 && (model == 9 || model == 13 || model == 14)) {
168 if (family == 6 && model == 28)