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 /* ebx saving is necessary for PIC. gcc seems unable to see it alone */
8 static inline void cpuid(int index
, int *eax
, int *ebx
, int *ecx
, int *edx
)
10 asm ("pushl %%ebx\n\t"
14 : "=a" (*eax
), "=m" (*ebx
),
15 "=c" (*ecx
), "=d" (*edx
)
20 /* Function to test if multimedia instructions are supported... */
24 int eax
, ebx
, ecx
, edx
;
26 __asm__
__volatile__ (
27 /* See if CPUID instruction is supported ... */
28 /* ... Get copies of EFLAGS into eax and ecx */
33 /* ... Toggle the ID bit in one copy and store */
34 /* to the EFLAGS reg */
35 "xorl $0x200000, %0\n\t"
39 /* ... Get the (hopefully modified) EFLAGS */
42 : "=a" (eax
), "=c" (ecx
)
48 return 0; /* CPUID not supported */
50 cpuid(0, &eax
, &ebx
, &ecx
, &edx
);
52 if (ebx
== 0x756e6547 &&
58 cpuid(1, &eax
, &ebx
, &ecx
, &edx
);
59 if ((edx
& 0x00800000) == 0)
63 rval
|= MM_MMXEXT
| MM_SSE
;
67 } else if (ebx
== 0x68747541 &&
71 cpuid(0x80000000, &eax
, &ebx
, &ecx
, &edx
);
72 if ((unsigned)eax
< 0x80000001)
74 cpuid(0x80000001, &eax
, &ebx
, &ecx
, &edx
);
75 if ((edx
& 0x00800000) == 0)
83 } else if (ebx
== 0x69727943 &&
87 /* See if extended CPUID level 80000001 is supported */
88 /* The value of CPUID/80000001 for the 6x86MX is undefined
89 according to the Cyrix CPU Detection Guide (Preliminary
90 Rev. 1.01 table 1), so we'll check the value of eax for
91 CPUID/0 to see if standard CPUID level 2 is supported.
92 According to the table, the only CPU which supports level
93 2 is also the only one which supports extended CPUID levels.
97 cpuid(0x80000001, &eax
, &ebx
, &ecx
, &edx
);
98 if ((eax
& 0x00800000) == 0)
101 if (eax
& 0x01000000)