minix/lib/libc/arch/i386/misc/_cpufeature.c
Arun Thomas 2a8fabf4ad Include directory reorg and makefile updates.
-Convert the include directory over to using bsdmake
 syntax
-Update/add mkfiles
-Modify install(1) so that it can create symlinks
-Update makefiles to use new install(1) options
-Rename /usr/include/ibm to /usr/include/i386
-Create /usr/include/machine symlink to arch header files
-Move vm_i386.h to its new home in the /usr/include/i386
-Update source files to #include the header files at their
 new homes.
-Add new gnu-includes target for building GCC headers
2010-03-08 11:04:59 +00:00

68 lines
1.5 KiB
C

#include <stdint.h>
#include <minix/minlib.h>
#include <minix/cpufeature.h>
#include <machine/vm.h>
int _cpufeature(int cpufeature)
{
u32_t eax, ebx, ecx, edx;
int proc;
eax = ebx = ecx = edx = 0;
proc = getprocessor();
/* If processor supports CPUID and its CPUID supports enough
* parameters, retrieve EDX feature flags to test against.
*/
if(proc >= 586) {
eax = 0;
_cpuid(&eax, &ebx, &ecx, &edx);
if(eax > 0) {
eax = 1;
_cpuid(&eax, &ebx, &ecx, &edx);
}
}
switch(cpufeature) {
case _CPUF_I386_PSE:
return edx & CPUID1_EDX_PSE;
case _CPUF_I386_PGE:
return edx & CPUID1_EDX_PGE;
case _CPUF_I386_APIC_ON_CHIP:
return edx & CPUID1_EDX_APIC_ON_CHIP;
case _CPUF_I386_TSC:
return edx & CPUID1_EDX_TSC;
case _CPUF_I386_FPU:
return edx & CPUID1_EDX_FPU;
case _CPUF_I386_SSEx:
return (edx & (CPUID1_EDX_FXSR |
CPUID1_EDX_SSE |
CPUID1_EDX_SSE2)) &&
(ecx & (CPUID1_ECX_SSE3 |
CPUID1_ECX_SSSE3 |
CPUID1_ECX_SSE4_1 |
CPUID1_ECX_SSE4_2));
case _CPUF_I386_FXSR:
return edx & CPUID1_EDX_FXSR;
case _CPUF_I386_SSE:
return edx & CPUID1_EDX_SSE;
case _CPUF_I386_SSE2:
return edx & CPUID1_EDX_SSE2;
case _CPUF_I386_SSE3:
return ecx & CPUID1_ECX_SSE3;
case _CPUF_I386_SSSE3:
return ecx & CPUID1_ECX_SSSE3;
case _CPUF_I386_SSE4_1:
return ecx & CPUID1_ECX_SSE4_1;
case _CPUF_I386_SSE4_2:
return ecx & CPUID1_ECX_SSE4_2;
case _CPUF_I386_HTT:
return edx & CPUID1_EDX_HTT;
case _CPUF_I386_HTT_MAX_NUM:
return (ebx >> 16) & 0xff;
}
return 0;
}