kernel32: Rewrite GetSystemInfo() purely on ntdll calls.
This commit is contained in:
parent
004fdc7a97
commit
e1e9f5993f
|
@ -22,22 +22,6 @@
|
|||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SYSCTL_H
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_MACHINE_CPU_H
|
||||
# include <machine/cpu.h>
|
||||
#endif
|
||||
#ifdef HAVE_MACH_MACHINE_H
|
||||
# include <mach/machine.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
|
@ -61,101 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
|||
|
||||
#define SHARED_DATA ((KSHARED_USER_DATA*)0x7ffe0000)
|
||||
|
||||
#define AUTH 0x68747541 /* "Auth" */
|
||||
#define ENTI 0x69746e65 /* "enti" */
|
||||
#define CAMD 0x444d4163 /* "cAMD" */
|
||||
|
||||
/* Calls cpuid with an eax of 'ax' and returns the 16 bytes in *p
|
||||
* We are compiled with -fPIC, so we can't clobber ebx.
|
||||
*/
|
||||
static inline void do_cpuid(unsigned int ax, unsigned int *p)
|
||||
{
|
||||
#ifdef __i386__
|
||||
__asm__("pushl %%ebx\n\t"
|
||||
"cpuid\n\t"
|
||||
"movl %%ebx, %%esi\n\t"
|
||||
"popl %%ebx"
|
||||
: "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
|
||||
: "0" (ax));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* From xf86info havecpuid.c 1.11 */
|
||||
static inline int have_cpuid(void)
|
||||
{
|
||||
#ifdef __i386__
|
||||
unsigned int f1, f2;
|
||||
__asm__("pushfl\n\t"
|
||||
"pushfl\n\t"
|
||||
"popl %0\n\t"
|
||||
"movl %0,%1\n\t"
|
||||
"xorl %2,%0\n\t"
|
||||
"pushl %0\n\t"
|
||||
"popfl\n\t"
|
||||
"pushfl\n\t"
|
||||
"popl %0\n\t"
|
||||
"popfl"
|
||||
: "=&r" (f1), "=&r" (f2)
|
||||
: "ir" (0x00200000));
|
||||
return ((f1^f2) & 0x00200000) != 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ULONGLONG cpuHz = 1000000000; /* default to a 1GHz */
|
||||
|
||||
static inline void get_cpuinfo( SYSTEM_INFO *info )
|
||||
{
|
||||
unsigned int regs[4], regs2[4];
|
||||
|
||||
if (!have_cpuid()) return;
|
||||
|
||||
do_cpuid(0x00000000, regs); /* get standard cpuid level and vendor name */
|
||||
if (regs[0]>=0x00000001) /* Check for supported cpuid version */
|
||||
{
|
||||
do_cpuid(0x00000001, regs2); /* get cpu features */
|
||||
switch ((regs2[0] >> 8) & 0xf) /* cpu family */
|
||||
{
|
||||
case 3:
|
||||
info->dwProcessorType = PROCESSOR_INTEL_386;
|
||||
info->wProcessorLevel = 3;
|
||||
break;
|
||||
case 4:
|
||||
info->dwProcessorType = PROCESSOR_INTEL_486;
|
||||
info->wProcessorLevel = 4;
|
||||
break;
|
||||
case 5:
|
||||
info->dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
info->wProcessorLevel = 5;
|
||||
break;
|
||||
case 6:
|
||||
case 15: /* PPro/2/3/4 has same info as P1 */
|
||||
info->dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
info->wProcessorLevel = 6;
|
||||
break;
|
||||
default:
|
||||
FIXME("unknown cpu family %d, please report! (-> setting to 386)\n",
|
||||
(regs2[0] >> 8)&0xf);
|
||||
break;
|
||||
}
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !(regs2[3] & 1);
|
||||
SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] & (1 << 4 )) >> 4;
|
||||
SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = (regs2[3] & (1 << 8 )) >> 8;
|
||||
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 23)) >> 23;
|
||||
|
||||
if (regs[1] == AUTH &&
|
||||
regs[3] == ENTI &&
|
||||
regs[2] == CAMD) {
|
||||
do_cpuid(0x80000000, regs); /* get vendor cpuid level */
|
||||
if (regs[0]>=0x80000001) {
|
||||
do_cpuid(0x80000001, regs2); /* get vendor features */
|
||||
SHARED_DATA->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 31 )) >> 31;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* QueryPerformanceCounter (KERNEL32.@)
|
||||
*
|
||||
|
@ -213,444 +102,61 @@ BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
|
|||
* On the first call it creates cached values, so it doesn't have to determine
|
||||
* them repeatedly. On Linux, the "/proc/cpuinfo" special file is used.
|
||||
*
|
||||
* It creates a registry subhierarchy, looking like:
|
||||
* "\HARDWARE\DESCRIPTION\System\CentralProcessor\<processornumber>\Identifier (CPU x86)".
|
||||
* Note that there is a hierarchy for every processor installed, so this
|
||||
* supports multiprocessor systems. This is done like Win95 does it, I think.
|
||||
*
|
||||
* It creates some registry entries in the environment part:
|
||||
* "\HKLM\System\CurrentControlSet\Control\Session Manager\Environment". These are
|
||||
* always present. When deleted, Windows will add them again.
|
||||
*
|
||||
* It also creates a cached flag array for IsProcessorFeaturePresent().
|
||||
*/
|
||||
VOID WINAPI GetSystemInfo(
|
||||
LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */)
|
||||
{
|
||||
static int cache = 0;
|
||||
static SYSTEM_INFO cachedsi;
|
||||
SYSTEM_BASIC_INFORMATION sbi;
|
||||
NTSTATUS nts;
|
||||
SYSTEM_BASIC_INFORMATION sbi;
|
||||
SYSTEM_CPU_INFORMATION sci;
|
||||
|
||||
TRACE("si=0x%p\n", si);
|
||||
if (cache) {
|
||||
*si = cachedsi;
|
||||
return;
|
||||
}
|
||||
memset(SHARED_DATA->ProcessorFeatures,0,sizeof(SHARED_DATA->ProcessorFeatures));
|
||||
TRACE("si=0x%p\n", si);
|
||||
|
||||
NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL );
|
||||
cachedsi.dwPageSize = sbi.PageSize;
|
||||
cachedsi.lpMinimumApplicationAddress = sbi.LowestUserAddress;
|
||||
cachedsi.lpMaximumApplicationAddress = sbi.HighestUserAddress;
|
||||
cachedsi.dwNumberOfProcessors = sbi.NumberOfProcessors;
|
||||
cachedsi.dwAllocationGranularity = sbi.AllocationGranularity;
|
||||
if ((nts = NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL )) != STATUS_SUCCESS ||
|
||||
(nts = NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL )) != STATUS_SUCCESS)
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(nts));
|
||||
return;
|
||||
}
|
||||
|
||||
/* choose sensible defaults ...
|
||||
* FIXME: perhaps overridable with precompiler flags?
|
||||
*/
|
||||
cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
|
||||
cachedsi.dwActiveProcessorMask = 0;
|
||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel = 5; /* 586 */
|
||||
cachedsi.wProcessorRevision = 0;
|
||||
si->u.s.wProcessorArchitecture = sci.Architecture;
|
||||
si->u.s.wReserved = 0;
|
||||
si->dwPageSize = sbi.PageSize;
|
||||
si->lpMinimumApplicationAddress = sbi.LowestUserAddress;
|
||||
si->lpMaximumApplicationAddress = sbi.HighestUserAddress;
|
||||
si->dwActiveProcessorMask = sbi.ActiveProcessorsAffinityMask;
|
||||
si->dwNumberOfProcessors = sbi.NumberOfProcessors;
|
||||
|
||||
cache = 1; /* even if there is no more info, we now have a cache entry */
|
||||
*si = cachedsi;
|
||||
|
||||
/* Hmm, reasonable processor feature defaults? */
|
||||
|
||||
#ifdef linux
|
||||
{
|
||||
char line[200];
|
||||
FILE *f = fopen ("/proc/cpuinfo", "r");
|
||||
|
||||
if (!f)
|
||||
return;
|
||||
while (fgets(line,200,f)!=NULL) {
|
||||
char *s,*value;
|
||||
|
||||
/* NOTE: the ':' is the only character we can rely on */
|
||||
if (!(value = strchr(line,':')))
|
||||
continue;
|
||||
|
||||
/* terminate the valuename */
|
||||
s = value - 1;
|
||||
while ((s >= line) && ((*s == ' ') || (*s == '\t'))) s--;
|
||||
*(s + 1) = '\0';
|
||||
|
||||
/* and strip leading spaces from value */
|
||||
value += 1;
|
||||
while (*value==' ') value++;
|
||||
if ((s=strchr(value,'\n')))
|
||||
*s='\0';
|
||||
|
||||
if (!strcasecmp(line,"processor")) {
|
||||
/* processor number counts up... */
|
||||
unsigned int x;
|
||||
|
||||
if (sscanf(value,"%d",&x))
|
||||
if (x+1>cachedsi.dwNumberOfProcessors)
|
||||
cachedsi.dwNumberOfProcessors=x+1;
|
||||
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(line,"model")) {
|
||||
/* First part of wProcessorRevision */
|
||||
int x;
|
||||
|
||||
if (sscanf(value,"%d",&x))
|
||||
cachedsi.wProcessorRevision = cachedsi.wProcessorRevision | (x << 8);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 2.1 method */
|
||||
if (!strcasecmp(line, "cpu family")) {
|
||||
if (isdigit (value[0])) {
|
||||
switch (value[0] - '0') {
|
||||
case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
|
||||
cachedsi.wProcessorLevel= 3;
|
||||
break;
|
||||
case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
|
||||
cachedsi.wProcessorLevel= 4;
|
||||
break;
|
||||
case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel= 5;
|
||||
break;
|
||||
|
||||
default:
|
||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel = atoi(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* old 2.0 method */
|
||||
if (!strcasecmp(line, "cpu")) {
|
||||
if ( isdigit (value[0]) && value[1] == '8' &&
|
||||
value[2] == '6' && value[3] == 0
|
||||
) {
|
||||
switch (value[0] - '0') {
|
||||
case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
|
||||
cachedsi.wProcessorLevel= 3;
|
||||
break;
|
||||
case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
|
||||
cachedsi.wProcessorLevel= 4;
|
||||
break;
|
||||
case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel= 5;
|
||||
break;
|
||||
case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel= 6;
|
||||
break;
|
||||
default:
|
||||
FIXME("unknown Linux 2.0 cpu family '%s', please report ! (-> setting to 386)\n", value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(line,"stepping")) {
|
||||
/* Second part of wProcessorRevision */
|
||||
int x;
|
||||
|
||||
if (sscanf(value,"%d",&x))
|
||||
cachedsi.wProcessorRevision = cachedsi.wProcessorRevision | x;
|
||||
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(line, "cpu MHz")) {
|
||||
double cmz;
|
||||
if (sscanf( value, "%lf", &cmz ) == 1) {
|
||||
/* SYSTEMINFO doesn't have a slot for cpu speed, so store in a global */
|
||||
cpuHz = cmz * 1000 * 1000;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(line,"fdiv_bug")) {
|
||||
if (!strncasecmp(value,"yes",3))
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
|
||||
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(line,"fpu")) {
|
||||
if (!strncasecmp(value,"no",2))
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
|
||||
|
||||
continue;
|
||||
}
|
||||
if ( !strcasecmp(line,"flags") ||
|
||||
!strcasecmp(line,"features")) {
|
||||
if (strstr(value,"cx8"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||
if (strstr(value,"mmx"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(value,"tsc"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||
if (strstr(value,"3dnow"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
/* This will also catch sse2, but we have sse itself
|
||||
* if we have sse2, so no problem */
|
||||
if (strstr(value,"sse"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(value,"sse2"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(value,"pae"))
|
||||
SHARED_DATA->ProcessorFeatures[PF_PAE_ENABLED] = TRUE;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fclose (f);
|
||||
}
|
||||
#elif defined (__NetBSD__)
|
||||
switch (sci.Architecture)
|
||||
{
|
||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||
switch (sci.Level)
|
||||
{
|
||||
int mib[2];
|
||||
int value;
|
||||
size_t val_len;
|
||||
char model[256];
|
||||
char *cpuclass;
|
||||
FILE *f = fopen ("/var/run/dmesg.boot", "r");
|
||||
|
||||
/* first deduce as much as possible from the sysctls */
|
||||
mib[0] = CTL_MACHDEP;
|
||||
#ifdef CPU_FPU_PRESENT
|
||||
mib[1] = CPU_FPU_PRESENT;
|
||||
val_len = sizeof(value);
|
||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !value;
|
||||
#endif
|
||||
#ifdef CPU_SSE
|
||||
mib[1] = CPU_SSE; /* this should imply MMX */
|
||||
val_len = sizeof(value);
|
||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||
if (value) SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
#endif
|
||||
#ifdef CPU_SSE2
|
||||
mib[1] = CPU_SSE2; /* this should imply MMX */
|
||||
val_len = sizeof(value);
|
||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||
if (value) SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
#endif
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_NCPU;
|
||||
val_len = sizeof(value);
|
||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||
if (value > cachedsi.dwNumberOfProcessors)
|
||||
cachedsi.dwNumberOfProcessors = value;
|
||||
mib[1] = HW_MODEL;
|
||||
val_len = sizeof(model)-1;
|
||||
if (sysctl(mib, 2, model, &val_len, NULL, 0) >= 0) {
|
||||
model[val_len] = '\0'; /* just in case */
|
||||
cpuclass = strstr(model, "-class");
|
||||
if (cpuclass != NULL) {
|
||||
while(cpuclass > model && cpuclass[0] != '(') cpuclass--;
|
||||
if (!strncmp(cpuclass+1, "386", 3)) {
|
||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
|
||||
cachedsi.wProcessorLevel= 3;
|
||||
}
|
||||
if (!strncmp(cpuclass+1, "486", 3)) {
|
||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
|
||||
cachedsi.wProcessorLevel= 4;
|
||||
}
|
||||
if (!strncmp(cpuclass+1, "586", 3)) {
|
||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel= 5;
|
||||
}
|
||||
if (!strncmp(cpuclass+1, "686", 3)) {
|
||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||
cachedsi.wProcessorLevel= 6;
|
||||
/* this should imply MMX */
|
||||
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* it may be worth reading from /var/run/dmesg.boot for
|
||||
additional information such as CX8, MMX and TSC
|
||||
(however this information should be considered less
|
||||
reliable than that from the sysctl calls) */
|
||||
if (f != NULL)
|
||||
{
|
||||
while (fgets(model, 255, f) != NULL) {
|
||||
int cpu, features;
|
||||
if (sscanf(model,"cpu%d: features %x<", &cpu, &features) == 2) {
|
||||
/* we could scan the string but it is easier
|
||||
to test the bits directly */
|
||||
if (features & 0x1)
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
|
||||
if (features & 0x10)
|
||||
SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||
if (features & 0x100)
|
||||
SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||
if (features & 0x800000)
|
||||
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
case 3: si->dwProcessorType = PROCESSOR_INTEL_386; break;
|
||||
case 4: si->dwProcessorType = PROCESSOR_INTEL_486; break;
|
||||
case 5:
|
||||
case 6: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
|
||||
default: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
{
|
||||
int ret, num;
|
||||
size_t len;
|
||||
|
||||
get_cpuinfo( &cachedsi );
|
||||
|
||||
/* Check for OS support of SSE -- Is this used, and should it be sse1 or sse2? */
|
||||
/*len = sizeof(num);
|
||||
ret = sysctlbyname("hw.instruction_sse", &num, &len, NULL, 0);
|
||||
if (!ret)
|
||||
SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = num;*/
|
||||
|
||||
len = sizeof(num);
|
||||
ret = sysctlbyname("hw.ncpu", &num, &len, NULL, 0);
|
||||
if (!ret)
|
||||
cachedsi.dwNumberOfProcessors = num;
|
||||
}
|
||||
#elif defined(__sun)
|
||||
{
|
||||
int num = sysconf( _SC_NPROCESSORS_ONLN );
|
||||
|
||||
if (num == -1) num = 1;
|
||||
get_cpuinfo( &cachedsi );
|
||||
cachedsi.dwNumberOfProcessors = num;
|
||||
}
|
||||
#elif defined (__APPLE__)
|
||||
{
|
||||
size_t valSize;
|
||||
unsigned long long longVal;
|
||||
int value;
|
||||
int cputype;
|
||||
char buffer[256];
|
||||
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("hw.optional.floatingpoint", &value, &valSize, NULL, 0) == 0)
|
||||
{
|
||||
if (value)
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE;
|
||||
else
|
||||
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
|
||||
}
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("hw.ncpu", &value, &valSize, NULL, 0) == 0)
|
||||
cachedsi.dwNumberOfProcessors = value;
|
||||
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("hw.activecpu", &value, &valSize, NULL, 0) == 0)
|
||||
cachedsi.dwActiveProcessorMask = ((ULONG_PTR)1 << value) - 1;
|
||||
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("hw.cputype", &cputype, &valSize, NULL, 0) == 0)
|
||||
{
|
||||
switch (cputype)
|
||||
{
|
||||
case CPU_TYPE_POWERPC:
|
||||
cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_PPC;
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("hw.cpusubtype", &value, &valSize, NULL, 0) == 0)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case CPU_SUBTYPE_POWERPC_601:
|
||||
case CPU_SUBTYPE_POWERPC_602:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_601;
|
||||
cachedsi.wProcessorLevel = 1;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_603:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_603;
|
||||
cachedsi.wProcessorLevel = 3;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_603e:
|
||||
case CPU_SUBTYPE_POWERPC_603ev:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_603;
|
||||
cachedsi.wProcessorLevel = 6;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_604:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_604;
|
||||
cachedsi.wProcessorLevel = 4;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_604e:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_604;
|
||||
cachedsi.wProcessorLevel = 9;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_620:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_620;
|
||||
cachedsi.wProcessorLevel = 20;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_750:
|
||||
case CPU_SUBTYPE_POWERPC_7400:
|
||||
case CPU_SUBTYPE_POWERPC_7450:
|
||||
/* G3/G4 derive from 603 so ... */
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_603;
|
||||
cachedsi.wProcessorLevel = 6;
|
||||
break;
|
||||
case CPU_SUBTYPE_POWERPC_970:
|
||||
cachedsi.dwProcessorType = PROCESSOR_PPC_604;
|
||||
cachedsi.wProcessorLevel = 9;
|
||||
/* :o) SHARED_DATA->ProcessorFeatures[PF_ALTIVEC_INSTRUCTIONS_AVAILABLE] ;-) */
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
break; /* CPU_TYPE_POWERPC */
|
||||
case CPU_TYPE_I386:
|
||||
cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("machdep.cpu.family", &value, &valSize, NULL, 0) == 0)
|
||||
{
|
||||
cachedsi.wProcessorLevel = value;
|
||||
switch (value)
|
||||
{
|
||||
case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386; break;
|
||||
case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486; break;
|
||||
default: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
|
||||
}
|
||||
}
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("machdep.cpu.model", &value, &valSize, NULL, 0) == 0)
|
||||
cachedsi.wProcessorRevision = (value << 8);
|
||||
valSize = sizeof(int);
|
||||
if (sysctlbyname ("machdep.cpu.stepping", &value, &valSize, NULL, 0) == 0)
|
||||
cachedsi.wProcessorRevision |= value;
|
||||
valSize = sizeof(buffer);
|
||||
if (sysctlbyname ("machdep.cpu.features", buffer, &valSize, NULL, 0) == 0)
|
||||
{
|
||||
cachedsi.wProcessorRevision |= value;
|
||||
if (strstr(buffer,"CX8")) SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||
if (strstr(buffer,"MMX")) SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(buffer,"TSC")) SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||
if (strstr(buffer,"3DNOW")) SHARED_DATA->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(buffer,"SSE")) SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(buffer,"SSE2")) SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||
if (strstr(buffer,"PAE")) SHARED_DATA->ProcessorFeatures[PF_PAE_ENABLED] = TRUE;
|
||||
}
|
||||
break; /* CPU_TYPE_I386 */
|
||||
default: break;
|
||||
} /* switch (cputype) */
|
||||
}
|
||||
valSize = sizeof(longVal);
|
||||
if (!sysctlbyname("hw.cpufrequency", &longVal, &valSize, NULL, 0))
|
||||
cpuHz = longVal;
|
||||
}
|
||||
#else
|
||||
FIXME("not yet supported on this system\n");
|
||||
#endif
|
||||
if (!cachedsi.dwActiveProcessorMask)
|
||||
cachedsi.dwActiveProcessorMask = ((ULONG_PTR)1 << cachedsi.dwNumberOfProcessors) - 1;
|
||||
|
||||
*si = cachedsi;
|
||||
|
||||
TRACE("<- CPU arch %d, res'd %d, pagesize %d, minappaddr %p, maxappaddr %p,"
|
||||
" act.cpumask %lx, numcpus %d, CPU type %d, allocgran. %d, CPU level %d, CPU rev %d\n",
|
||||
si->u.s.wProcessorArchitecture, si->u.s.wReserved, si->dwPageSize,
|
||||
si->lpMinimumApplicationAddress, si->lpMaximumApplicationAddress,
|
||||
si->dwActiveProcessorMask, si->dwNumberOfProcessors, si->dwProcessorType,
|
||||
si->dwAllocationGranularity, si->wProcessorLevel, si->wProcessorRevision);
|
||||
break;
|
||||
case PROCESSOR_ARCHITECTURE_PPC:
|
||||
switch (sci.Level)
|
||||
{
|
||||
case 1: si->dwProcessorType = PROCESSOR_PPC_601; break;
|
||||
case 3:
|
||||
case 6: si->dwProcessorType = PROCESSOR_PPC_603; break;
|
||||
case 4: si->dwProcessorType = PROCESSOR_PPC_604; break;
|
||||
case 9: si->dwProcessorType = PROCESSOR_PPC_604; break;
|
||||
case 20: si->dwProcessorType = PROCESSOR_PPC_620; break;
|
||||
default: si->dwProcessorType = 0;
|
||||
}
|
||||
break;
|
||||
default: FIXME("Unknown processor architecture %x\n", sci.Architecture);
|
||||
}
|
||||
si->dwAllocationGranularity = sbi.AllocationGranularity;
|
||||
si->wProcessorLevel = sci.Level;
|
||||
si->wProcessorRevision = sci.Revision;
|
||||
}
|
||||
|
||||
|
||||
|
@ -681,9 +187,6 @@ VOID WINAPI GetNativeSystemInfo(
|
|||
BOOL WINAPI IsProcessorFeaturePresent (
|
||||
DWORD feature /* [in] Feature number, (PF_ constants from "winnt.h") */)
|
||||
{
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo (&si); /* To ensure the information is loaded and cached */
|
||||
|
||||
if (feature < 64)
|
||||
return SHARED_DATA->ProcessorFeatures[feature];
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue