mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
detect hyper-threading, determine number of logical processors per phyiscal processor and it's apic id
svn path=/trunk/; revision=13864
This commit is contained in:
parent
f05c21fa3a
commit
bdf10ff3ff
2 changed files with 19 additions and 4 deletions
|
@ -99,6 +99,7 @@
|
|||
#define X86_FEATURE_FXSR 0x01000000 /* FXSAVE/FXRSTOR instructions present */
|
||||
#define X86_FEATURE_SSE 0x02000000 /* SSE extension present */
|
||||
#define X86_FEATURE_SSE2 0x04000000 /* SSE2 extension present */
|
||||
#define X86_FEATURE_HT 0x10000000 /* Hyper-Threading present */
|
||||
|
||||
#define X86_EXT_FEATURE_SSE3 0x00000001 /* SSE3 extension present */
|
||||
#define X86_EXT_FEATURE_3DNOW 0x40000000 /* 3DNOW! extension present */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
ULONG KiPcrInitDone = 0;
|
||||
static ULONG PcrsAllocated = 0;
|
||||
static ULONG Ke386CpuidFlags2, Ke386CpuidExFlags;
|
||||
static ULONG Ke386CpuidFlags2, Ke386CpuidExFlags, Ke386CpuidExMisc;
|
||||
ULONG Ke386CacheAlignment;
|
||||
CHAR Ke386CpuidModel[49] = {0,};
|
||||
ULONG Ke386L1CacheSize;
|
||||
|
@ -34,7 +34,7 @@ Ki386GetCpuId(VOID)
|
|||
{
|
||||
ULONG OrigFlags, Flags, FinalFlags;
|
||||
ULONG MaxCpuidLevel;
|
||||
ULONG Dummy, Eax, Ebx, Ecx, Edx;
|
||||
ULONG Dummy, Eax, Ecx, Edx;
|
||||
PKPCR Pcr = KeGetCurrentKPCR();
|
||||
|
||||
Ke386CpuidFlags2 = Ke386CpuidExFlags = 0;
|
||||
|
@ -45,6 +45,10 @@ Ki386GetCpuId(VOID)
|
|||
Flags = OrigFlags ^ X86_EFLAGS_ID;
|
||||
Ke386RestoreFlags(Flags);
|
||||
Ke386SaveFlags(FinalFlags);
|
||||
|
||||
Pcr->PrcbData.LogicalProcessorsPerPhysicalProcessor = 1;
|
||||
Pcr->PrcbData.InitialApicId = 0xff;
|
||||
|
||||
if ((OrigFlags & X86_EFLAGS_ID) == (FinalFlags & X86_EFLAGS_ID))
|
||||
{
|
||||
/* No cpuid supported. */
|
||||
|
@ -59,14 +63,24 @@ Ki386GetCpuId(VOID)
|
|||
if (MaxCpuidLevel > 0)
|
||||
{
|
||||
/* Get the feature flags. */
|
||||
Ki386Cpuid(1, &Eax, &Ebx, &Ke386CpuidFlags2, &Pcr->PrcbData.FeatureBits);
|
||||
Ki386Cpuid(1, &Eax, &Ke386CpuidExMisc, &Ke386CpuidFlags2, &Pcr->PrcbData.FeatureBits);
|
||||
/* Get the cache alignment, if it is available */
|
||||
if (Pcr->PrcbData.FeatureBits & (1<<19))
|
||||
{
|
||||
Ke386CacheAlignment = ((Ebx >> 8) & 0xff) * 8;
|
||||
Ke386CacheAlignment = ((Ke386CpuidExMisc >> 8) & 0xff) * 8;
|
||||
}
|
||||
Pcr->PrcbData.CpuType = (Eax >> 8) & 0xf;
|
||||
Pcr->PrcbData.CpuStep = (Eax & 0xf) | ((Eax << 4) & 0xf00);
|
||||
|
||||
Pcr->PrcbData.InitialApicId = (Ke386CpuidExMisc >> 24) & 0xff;
|
||||
|
||||
/* detect Hyper-Threading on Pentium 4 CPUs or later */
|
||||
if ((Pcr->PrcbData.CpuType == 0xf || (Eax & 0x0f00000)) &&
|
||||
!strncmp(Pcr->PrcbData.VendorString, "GenuineIntel", 12) &&
|
||||
Pcr->PrcbData.FeatureBits & X86_FEATURE_HT)
|
||||
{
|
||||
Pcr->PrcbData.LogicalProcessorsPerPhysicalProcessor = (Ke386CpuidExMisc >> 16) & 0xff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue