kernel32: Store the process features flag in the KUSER_SHARED_DATA structure.
This commit is contained in:
parent
f6ceedf6dd
commit
0bf33d6ac2
@ -47,15 +47,20 @@
|
|||||||
|
|
||||||
#define NONAMELESSUNION
|
#define NONAMELESSUNION
|
||||||
#define NONAMELESSSTRUCT
|
#define NONAMELESSSTRUCT
|
||||||
|
#include "ntstatus.h"
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winnt.h"
|
#include "winnt.h"
|
||||||
#include "winternl.h"
|
#include "winternl.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
#include "ddk/wdm.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
||||||
|
|
||||||
|
#define SHARED_DATA ((KSHARED_USER_DATA*)0x7ffe0000)
|
||||||
|
|
||||||
#define AUTH 0x68747541 /* "Auth" */
|
#define AUTH 0x68747541 /* "Auth" */
|
||||||
#define ENTI 0x69746e65 /* "enti" */
|
#define ENTI 0x69746e65 /* "enti" */
|
||||||
#define CAMD 0x444d4163 /* "cAMD" */
|
#define CAMD 0x444d4163 /* "cAMD" */
|
||||||
@ -98,7 +103,6 @@ static inline int have_cpuid(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static BYTE PF[64] = {0,};
|
|
||||||
static ULONGLONG cpuHz = 1000000000; /* default to a 1GHz */
|
static ULONGLONG cpuHz = 1000000000; /* default to a 1GHz */
|
||||||
|
|
||||||
static void create_system_registry_keys( const SYSTEM_INFO *info )
|
static void create_system_registry_keys( const SYSTEM_INFO *info )
|
||||||
@ -279,10 +283,10 @@ static inline void get_cpuinfo( SYSTEM_INFO *info )
|
|||||||
(regs2[0] >> 8)&0xf);
|
(regs2[0] >> 8)&0xf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PF[PF_FLOATING_POINT_EMULATED] = !(regs2[3] & 1);
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !(regs2[3] & 1);
|
||||||
PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] & (1 << 4 )) >> 4;
|
SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] & (1 << 4 )) >> 4;
|
||||||
PF[PF_COMPARE_EXCHANGE_DOUBLE] = (regs2[3] & (1 << 8 )) >> 8;
|
SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = (regs2[3] & (1 << 8 )) >> 8;
|
||||||
PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 23)) >> 23;
|
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 23)) >> 23;
|
||||||
|
|
||||||
if (regs[1] == AUTH &&
|
if (regs[1] == AUTH &&
|
||||||
regs[3] == ENTI &&
|
regs[3] == ENTI &&
|
||||||
@ -290,7 +294,7 @@ static inline void get_cpuinfo( SYSTEM_INFO *info )
|
|||||||
do_cpuid(0x80000000, regs); /* get vendor cpuid level */
|
do_cpuid(0x80000000, regs); /* get vendor cpuid level */
|
||||||
if (regs[0]>=0x80000001) {
|
if (regs[0]>=0x80000001) {
|
||||||
do_cpuid(0x80000001, regs2); /* get vendor features */
|
do_cpuid(0x80000001, regs2); /* get vendor features */
|
||||||
PF[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 31 )) >> 31;
|
SHARED_DATA->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 31 )) >> 31;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +380,7 @@ VOID WINAPI GetSystemInfo(
|
|||||||
*si = cachedsi;
|
*si = cachedsi;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(PF,0,sizeof(PF));
|
memset(SHARED_DATA->ProcessorFeatures,0,sizeof(SHARED_DATA->ProcessorFeatures));
|
||||||
|
|
||||||
NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL );
|
NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL );
|
||||||
cachedsi.dwPageSize = sbi.PageSize;
|
cachedsi.dwPageSize = sbi.PageSize;
|
||||||
@ -510,34 +514,34 @@ VOID WINAPI GetSystemInfo(
|
|||||||
}
|
}
|
||||||
if (!strcasecmp(line,"fdiv_bug")) {
|
if (!strcasecmp(line,"fdiv_bug")) {
|
||||||
if (!strncasecmp(value,"yes",3))
|
if (!strncasecmp(value,"yes",3))
|
||||||
PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcasecmp(line,"fpu")) {
|
if (!strcasecmp(line,"fpu")) {
|
||||||
if (!strncasecmp(value,"no",2))
|
if (!strncasecmp(value,"no",2))
|
||||||
PF[PF_FLOATING_POINT_EMULATED] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !strcasecmp(line,"flags") ||
|
if ( !strcasecmp(line,"flags") ||
|
||||||
!strcasecmp(line,"features")) {
|
!strcasecmp(line,"features")) {
|
||||||
if (strstr(value,"cx8"))
|
if (strstr(value,"cx8"))
|
||||||
PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||||
if (strstr(value,"mmx"))
|
if (strstr(value,"mmx"))
|
||||||
PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(value,"tsc"))
|
if (strstr(value,"tsc"))
|
||||||
PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||||
if (strstr(value,"3dnow"))
|
if (strstr(value,"3dnow"))
|
||||||
PF[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
/* This will also catch sse2, but we have sse itself
|
/* This will also catch sse2, but we have sse itself
|
||||||
* if we have sse2, so no problem */
|
* if we have sse2, so no problem */
|
||||||
if (strstr(value,"sse"))
|
if (strstr(value,"sse"))
|
||||||
PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(value,"sse2"))
|
if (strstr(value,"sse2"))
|
||||||
PF[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(value,"pae"))
|
if (strstr(value,"pae"))
|
||||||
PF[PF_PAE_ENABLED] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_PAE_ENABLED] = TRUE;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -559,19 +563,19 @@ VOID WINAPI GetSystemInfo(
|
|||||||
mib[1] = CPU_FPU_PRESENT;
|
mib[1] = CPU_FPU_PRESENT;
|
||||||
val_len = sizeof(value);
|
val_len = sizeof(value);
|
||||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||||
PF[PF_FLOATING_POINT_EMULATED] = !value;
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !value;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CPU_SSE
|
#ifdef CPU_SSE
|
||||||
mib[1] = CPU_SSE; /* this should imply MMX */
|
mib[1] = CPU_SSE; /* this should imply MMX */
|
||||||
val_len = sizeof(value);
|
val_len = sizeof(value);
|
||||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||||
if (value) PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
if (value) SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CPU_SSE2
|
#ifdef CPU_SSE2
|
||||||
mib[1] = CPU_SSE2; /* this should imply MMX */
|
mib[1] = CPU_SSE2; /* this should imply MMX */
|
||||||
val_len = sizeof(value);
|
val_len = sizeof(value);
|
||||||
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
|
||||||
if (value) PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
if (value) SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
#endif
|
#endif
|
||||||
mib[0] = CTL_HW;
|
mib[0] = CTL_HW;
|
||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
@ -602,7 +606,7 @@ VOID WINAPI GetSystemInfo(
|
|||||||
cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
||||||
cachedsi.wProcessorLevel= 6;
|
cachedsi.wProcessorLevel= 6;
|
||||||
/* this should imply MMX */
|
/* this should imply MMX */
|
||||||
PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -619,13 +623,13 @@ VOID WINAPI GetSystemInfo(
|
|||||||
/* we could scan the string but it is easier
|
/* we could scan the string but it is easier
|
||||||
to test the bits directly */
|
to test the bits directly */
|
||||||
if (features & 0x1)
|
if (features & 0x1)
|
||||||
PF[PF_FLOATING_POINT_EMULATED] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
|
||||||
if (features & 0x10)
|
if (features & 0x10)
|
||||||
PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||||
if (features & 0x100)
|
if (features & 0x100)
|
||||||
PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||||
if (features & 0x800000)
|
if (features & 0x800000)
|
||||||
PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -645,7 +649,7 @@ VOID WINAPI GetSystemInfo(
|
|||||||
/*len = sizeof(num);
|
/*len = sizeof(num);
|
||||||
ret = sysctlbyname("hw.instruction_sse", &num, &len, NULL, 0);
|
ret = sysctlbyname("hw.instruction_sse", &num, &len, NULL, 0);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = num;*/
|
SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = num;*/
|
||||||
|
|
||||||
len = sizeof(num);
|
len = sizeof(num);
|
||||||
ret = sysctlbyname("hw.ncpu", &num, &len, NULL, 0);
|
ret = sysctlbyname("hw.ncpu", &num, &len, NULL, 0);
|
||||||
@ -672,9 +676,9 @@ VOID WINAPI GetSystemInfo(
|
|||||||
if (sysctlbyname ("hw.optional.floatingpoint", &value, &valSize, NULL, 0) == 0)
|
if (sysctlbyname ("hw.optional.floatingpoint", &value, &valSize, NULL, 0) == 0)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
PF[PF_FLOATING_POINT_EMULATED] = FALSE;
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE;
|
||||||
else
|
else
|
||||||
PF[PF_FLOATING_POINT_EMULATED] = TRUE;
|
SHARED_DATA->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
|
||||||
}
|
}
|
||||||
valSize = sizeof(int);
|
valSize = sizeof(int);
|
||||||
if (sysctlbyname ("hw.ncpu", &value, &valSize, NULL, 0) == 0)
|
if (sysctlbyname ("hw.ncpu", &value, &valSize, NULL, 0) == 0)
|
||||||
@ -732,7 +736,7 @@ VOID WINAPI GetSystemInfo(
|
|||||||
case CPU_SUBTYPE_POWERPC_970:
|
case CPU_SUBTYPE_POWERPC_970:
|
||||||
cachedsi.dwProcessorType = PROCESSOR_PPC_604;
|
cachedsi.dwProcessorType = PROCESSOR_PPC_604;
|
||||||
cachedsi.wProcessorLevel = 9;
|
cachedsi.wProcessorLevel = 9;
|
||||||
/* :o) PF[PF_ALTIVEC_INSTRUCTIONS_AVAILABLE] ;-) */
|
/* :o) SHARED_DATA->ProcessorFeatures[PF_ALTIVEC_INSTRUCTIONS_AVAILABLE] ;-) */
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -761,13 +765,13 @@ VOID WINAPI GetSystemInfo(
|
|||||||
if (sysctlbyname ("machdep.cpu.features", buffer, &valSize, NULL, 0) == 0)
|
if (sysctlbyname ("machdep.cpu.features", buffer, &valSize, NULL, 0) == 0)
|
||||||
{
|
{
|
||||||
cachedsi.wProcessorRevision |= value;
|
cachedsi.wProcessorRevision |= value;
|
||||||
if (strstr(buffer,"CX8")) PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
if (strstr(buffer,"CX8")) SHARED_DATA->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||||
if (strstr(buffer,"MMX")) PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
if (strstr(buffer,"MMX")) SHARED_DATA->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(buffer,"TSC")) PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
if (strstr(buffer,"TSC")) SHARED_DATA->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||||
if (strstr(buffer,"3DNOW")) PF[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
|
if (strstr(buffer,"3DNOW")) SHARED_DATA->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(buffer,"SSE")) PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
|
if (strstr(buffer,"SSE")) SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(buffer,"SSE2")) PF[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
|
if (strstr(buffer,"SSE2")) SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
|
||||||
if (strstr(buffer,"PAE")) PF[PF_PAE_ENABLED] = TRUE;
|
if (strstr(buffer,"PAE")) SHARED_DATA->ProcessorFeatures[PF_PAE_ENABLED] = TRUE;
|
||||||
}
|
}
|
||||||
break; /* CPU_TYPE_I386 */
|
break; /* CPU_TYPE_I386 */
|
||||||
default: break;
|
default: break;
|
||||||
@ -828,7 +832,7 @@ BOOL WINAPI IsProcessorFeaturePresent (
|
|||||||
GetSystemInfo (&si); /* To ensure the information is loaded and cached */
|
GetSystemInfo (&si); /* To ensure the information is loaded and cached */
|
||||||
|
|
||||||
if (feature < 64)
|
if (feature < 64)
|
||||||
return PF[feature];
|
return SHARED_DATA->ProcessorFeatures[feature];
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user