1 /* Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz
2 and R. Fisher). Converted to C and improved by Gerard Lantau */
5 #include "../dsputil.h"
7 /* need this external function to solve -fPIC ebx issues ! */
8 extern void cpuid(int index, int *eax, int *ebx, int *ecx, int *edx);
10 /* Function to test if multimedia instructions are supported... */
14 int eax, ebx, ecx, edx;
16 __asm__ __volatile__ (
17 /* See if CPUID instruction is supported ... */
18 /* ... Get copies of EFLAGS into eax and ecx */
23 /* ... Toggle the ID bit in one copy and store */
24 /* to the EFLAGS reg */
25 "xorl $0x200000, %0\n\t"
29 /* ... Get the (hopefully modified) EFLAGS */
32 : "=a" (eax), "=c" (ecx)
38 return 0; /* CPUID not supported */
40 cpuid(0, &eax, &ebx, &ecx, &edx);
42 if (ebx == 0x756e6547 &&
48 cpuid(1, &eax, &ebx, &ecx, &edx);
49 if ((edx & 0x00800000) == 0)
53 rval |= MM_MMXEXT | MM_SSE;
57 } else if (ebx == 0x68747541 &&
61 cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
62 if ((unsigned)eax < 0x80000001)
64 cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
65 if ((edx & 0x00800000) == 0)
73 } else if (ebx == 0x69727943 &&
77 /* See if extended CPUID level 80000001 is supported */
78 /* The value of CPUID/80000001 for the 6x86MX is undefined
79 according to the Cyrix CPU Detection Guide (Preliminary
80 Rev. 1.01 table 1), so we'll check the value of eax for
81 CPUID/0 to see if standard CPUID level 2 is supported.
82 According to the table, the only CPU which supports level
83 2 is also the only one which supports extended CPUID levels.
87 cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
88 if ((eax & 0x00800000) == 0)