|
|
@ -4,12 +4,18 @@ |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include "../dsputil.h" |
|
|
|
#include "../dsputil.h" |
|
|
|
|
|
|
|
|
|
|
|
#define cpuid(index,eax,ebx,ecx,edx) \ |
|
|
|
/* ebx saving is necessary for PIC. gcc seems unable to see it alone */ |
|
|
|
asm ("cpuid" \
|
|
|
|
static inline void cpuid(int index, int *eax, int *ebx, int *ecx, int *edx) |
|
|
|
: "=a" (eax), "=b" (ebx), \
|
|
|
|
{ |
|
|
|
"=c" (ecx), "=d" (edx) \
|
|
|
|
asm ("pushl %%ebx\n\t" |
|
|
|
: "a" (index) \
|
|
|
|
"cpuid\n\t" |
|
|
|
: "cc") |
|
|
|
"movl %%ebx, %1\n\t" |
|
|
|
|
|
|
|
"popl %%ebx\n\t" |
|
|
|
|
|
|
|
: "=a" (*eax), "=m" (*ebx),
|
|
|
|
|
|
|
|
"=c" (*ecx), "=d" (*edx) |
|
|
|
|
|
|
|
: "a" (index) |
|
|
|
|
|
|
|
: "cc"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Function to test if multimedia instructions are supported... */ |
|
|
|
/* Function to test if multimedia instructions are supported... */ |
|
|
|
int mm_support(void) |
|
|
|
int mm_support(void) |
|
|
@ -17,7 +23,6 @@ int mm_support(void) |
|
|
|
int rval; |
|
|
|
int rval; |
|
|
|
int eax, ebx, ecx, edx; |
|
|
|
int eax, ebx, ecx, edx; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__asm__ __volatile__ ( |
|
|
|
__asm__ __volatile__ ( |
|
|
|
/* See if CPUID instruction is supported ... */ |
|
|
|
/* See if CPUID instruction is supported ... */ |
|
|
|
/* ... Get copies of EFLAGS into eax and ecx */ |
|
|
|
/* ... Get copies of EFLAGS into eax and ecx */ |
|
|
@ -42,7 +47,7 @@ int mm_support(void) |
|
|
|
if (eax == ecx) |
|
|
|
if (eax == ecx) |
|
|
|
return 0; /* CPUID not supported */ |
|
|
|
return 0; /* CPUID not supported */ |
|
|
|
|
|
|
|
|
|
|
|
cpuid(0, eax, ebx, ecx, edx); |
|
|
|
cpuid(0, &eax, &ebx, &ecx, &edx); |
|
|
|
|
|
|
|
|
|
|
|
if (ebx == 0x756e6547 && |
|
|
|
if (ebx == 0x756e6547 && |
|
|
|
edx == 0x49656e69 && |
|
|
|
edx == 0x49656e69 && |
|
|
@ -50,7 +55,7 @@ int mm_support(void) |
|
|
|
|
|
|
|
|
|
|
|
/* intel */ |
|
|
|
/* intel */ |
|
|
|
inteltest: |
|
|
|
inteltest: |
|
|
|
cpuid(1, eax, ebx, ecx, edx); |
|
|
|
cpuid(1, &eax, &ebx, &ecx, &edx); |
|
|
|
if ((edx & 0x00800000) == 0) |
|
|
|
if ((edx & 0x00800000) == 0) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
rval = MM_MMX; |
|
|
|
rval = MM_MMX; |
|
|
@ -63,10 +68,10 @@ int mm_support(void) |
|
|
|
edx == 0x69746e65 && |
|
|
|
edx == 0x69746e65 && |
|
|
|
ecx == 0x444d4163) { |
|
|
|
ecx == 0x444d4163) { |
|
|
|
/* AMD */ |
|
|
|
/* AMD */ |
|
|
|
cpuid(0x80000000, eax, ebx, ecx, edx); |
|
|
|
cpuid(0x80000000, &eax, &ebx, &ecx, &edx); |
|
|
|
if ((unsigned)eax < 0x80000001) |
|
|
|
if ((unsigned)eax < 0x80000001) |
|
|
|
goto inteltest; |
|
|
|
goto inteltest; |
|
|
|
cpuid(0x80000001, eax, ebx, ecx, edx); |
|
|
|
cpuid(0x80000001, &eax, &ebx, &ecx, &edx); |
|
|
|
if ((edx & 0x00800000) == 0) |
|
|
|
if ((edx & 0x00800000) == 0) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
rval = MM_MMX; |
|
|
|
rval = MM_MMX; |
|
|
@ -89,7 +94,7 @@ int mm_support(void) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (eax != 2)
|
|
|
|
if (eax != 2)
|
|
|
|
goto inteltest; |
|
|
|
goto inteltest; |
|
|
|
cpuid(0x80000001, eax, ebx, ecx, edx); |
|
|
|
cpuid(0x80000001, &eax, &ebx, &ecx, &edx); |
|
|
|
if ((eax & 0x00800000) == 0) |
|
|
|
if ((eax & 0x00800000) == 0) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
rval = MM_MMX; |
|
|
|
rval = MM_MMX; |
|
|
|