mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 06:46:06 +00:00
[NTOS:KE] Move CPU features detection to a separate function on i586
This commit is contained in:
parent
c199edda45
commit
705e07ce31
1 changed files with 49 additions and 37 deletions
|
@ -392,6 +392,46 @@ KiInitializePcr(IN ULONG ProcessorNumber,
|
||||||
Pcr->PrcbData.MultiThreadProcessorSet = Pcr->PrcbData.SetMember;
|
Pcr->PrcbData.MultiThreadProcessorSet = Pcr->PrcbData.SetMember;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
CODE_SEG("INIT")
|
||||||
|
VOID
|
||||||
|
KiVerifyCpuFeatures(PKPRCB Prcb)
|
||||||
|
{
|
||||||
|
ULONG FeatureBits;
|
||||||
|
|
||||||
|
/* Detect and set the CPU Type */
|
||||||
|
KiSetProcessorType();
|
||||||
|
|
||||||
|
/* Check if an FPU is present */
|
||||||
|
KeI386NpxPresent = KiIsNpxPresent();
|
||||||
|
|
||||||
|
/* Bugcheck if this is a 386 CPU */
|
||||||
|
if (Prcb->CpuType == 3)
|
||||||
|
KeBugCheckEx(UNSUPPORTED_PROCESSOR, 0x386, 0, 0, 0);
|
||||||
|
|
||||||
|
/* Get the processor features for the CPU */
|
||||||
|
FeatureBits = KiGetFeatureBits();
|
||||||
|
|
||||||
|
/* Detect 8-byte compare exchange support */
|
||||||
|
if (!(FeatureBits & KF_CMPXCHG8B))
|
||||||
|
{
|
||||||
|
ULONG Vendor[3];
|
||||||
|
|
||||||
|
/* Copy the vendor string */
|
||||||
|
RtlCopyMemory(Vendor, Prcb->VendorString, sizeof(Vendor));
|
||||||
|
|
||||||
|
/* Bugcheck the system. Windows *requires* this */
|
||||||
|
KeBugCheckEx(UNSUPPORTED_PROCESSOR,
|
||||||
|
(1 << 24 ) | (Prcb->CpuType << 16) | Prcb->CpuStep,
|
||||||
|
Vendor[0],
|
||||||
|
Vendor[1],
|
||||||
|
Vendor[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save feature bits */
|
||||||
|
Prcb->FeatureBits = FeatureBits;
|
||||||
|
}
|
||||||
|
|
||||||
CODE_SEG("INIT")
|
CODE_SEG("INIT")
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -402,27 +442,16 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
IN CCHAR Number,
|
IN CCHAR Number,
|
||||||
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
{
|
{
|
||||||
BOOLEAN NpxPresent;
|
|
||||||
ULONG FeatureBits;
|
|
||||||
ULONG PageDirectory[2];
|
ULONG PageDirectory[2];
|
||||||
PVOID DpcStack;
|
PVOID DpcStack;
|
||||||
ULONG Vendor[3];
|
|
||||||
KIRQL DummyIrql;
|
KIRQL DummyIrql;
|
||||||
|
|
||||||
/* Detect and set the CPU Type */
|
|
||||||
KiSetProcessorType();
|
|
||||||
|
|
||||||
/* Check if an FPU is present */
|
|
||||||
NpxPresent = KiIsNpxPresent();
|
|
||||||
|
|
||||||
/* Initialize the Power Management Support for this PRCB */
|
/* Initialize the Power Management Support for this PRCB */
|
||||||
PoInitializePrcb(Prcb);
|
PoInitializePrcb(Prcb);
|
||||||
|
|
||||||
/* Bugcheck if this is a 386 CPU */
|
/* Set boot-level flags */
|
||||||
if (Prcb->CpuType == 3) KeBugCheckEx(UNSUPPORTED_PROCESSOR, 0x386, 0, 0, 0);
|
if (Number == 0)
|
||||||
|
KeFeatureBits = Prcb->FeatureBits;
|
||||||
/* Get the processor features for the CPU */
|
|
||||||
FeatureBits = KiGetFeatureBits();
|
|
||||||
|
|
||||||
/* Set the default NX policy (opt-in) */
|
/* Set the default NX policy (opt-in) */
|
||||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
||||||
|
@ -432,31 +461,28 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
{
|
{
|
||||||
/* Set it always on */
|
/* Set it always on */
|
||||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSON;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSON;
|
||||||
FeatureBits |= KF_NX_ENABLED;
|
KeFeatureBits |= KF_NX_ENABLED;
|
||||||
}
|
}
|
||||||
else if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTOUT"))
|
else if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTOUT"))
|
||||||
{
|
{
|
||||||
/* Set it in opt-out mode */
|
/* Set it in opt-out mode */
|
||||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTOUT;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTOUT;
|
||||||
FeatureBits |= KF_NX_ENABLED;
|
KeFeatureBits |= KF_NX_ENABLED;
|
||||||
}
|
}
|
||||||
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTIN")) ||
|
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTIN")) ||
|
||||||
(strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE")))
|
(strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE")))
|
||||||
{
|
{
|
||||||
/* Set the feature bits */
|
/* Set the feature bits */
|
||||||
FeatureBits |= KF_NX_ENABLED;
|
KeFeatureBits |= KF_NX_ENABLED;
|
||||||
}
|
}
|
||||||
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSOFF")) ||
|
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSOFF")) ||
|
||||||
(strstr(KeLoaderBlock->LoadOptions, "EXECUTE")))
|
(strstr(KeLoaderBlock->LoadOptions, "EXECUTE")))
|
||||||
{
|
{
|
||||||
/* Set disabled mode */
|
/* Set disabled mode */
|
||||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
|
||||||
FeatureBits |= KF_NX_DISABLED;
|
KeFeatureBits |= KF_NX_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save feature bits */
|
|
||||||
Prcb->FeatureBits = FeatureBits;
|
|
||||||
|
|
||||||
/* Save CPU state */
|
/* Save CPU state */
|
||||||
KiSaveProcessorControlState(&Prcb->ProcessorState);
|
KiSaveProcessorControlState(&Prcb->ProcessorState);
|
||||||
|
|
||||||
|
@ -475,30 +501,14 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
KeNodeBlock[0]->ProcessorMask = Prcb->SetMember;
|
KeNodeBlock[0]->ProcessorMask = Prcb->SetMember;
|
||||||
|
|
||||||
/* Set boot-level flags */
|
/* Set boot-level flags */
|
||||||
KeI386NpxPresent = NpxPresent;
|
|
||||||
KeI386CpuType = Prcb->CpuType;
|
KeI386CpuType = Prcb->CpuType;
|
||||||
KeI386CpuStep = Prcb->CpuStep;
|
KeI386CpuStep = Prcb->CpuStep;
|
||||||
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
|
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
|
||||||
KeProcessorLevel = (USHORT)Prcb->CpuType;
|
KeProcessorLevel = (USHORT)Prcb->CpuType;
|
||||||
if (Prcb->CpuID) KeProcessorRevision = Prcb->CpuStep;
|
if (Prcb->CpuID) KeProcessorRevision = Prcb->CpuStep;
|
||||||
KeFeatureBits = FeatureBits;
|
|
||||||
KeI386FxsrPresent = (KeFeatureBits & KF_FXSR) ? TRUE : FALSE;
|
KeI386FxsrPresent = (KeFeatureBits & KF_FXSR) ? TRUE : FALSE;
|
||||||
KeI386XMMIPresent = (KeFeatureBits & KF_XMMI) ? TRUE : FALSE;
|
KeI386XMMIPresent = (KeFeatureBits & KF_XMMI) ? TRUE : FALSE;
|
||||||
|
|
||||||
/* Detect 8-byte compare exchange support */
|
|
||||||
if (!(KeFeatureBits & KF_CMPXCHG8B))
|
|
||||||
{
|
|
||||||
/* Copy the vendor string */
|
|
||||||
RtlCopyMemory(Vendor, Prcb->VendorString, sizeof(Vendor));
|
|
||||||
|
|
||||||
/* Bugcheck the system. Windows *requires* this */
|
|
||||||
KeBugCheckEx(UNSUPPORTED_PROCESSOR,
|
|
||||||
(1 << 24 ) | (Prcb->CpuType << 16) | Prcb->CpuStep,
|
|
||||||
Vendor[0],
|
|
||||||
Vendor[1],
|
|
||||||
Vendor[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the current MP Master KPRCB to the Boot PRCB */
|
/* Set the current MP Master KPRCB to the Boot PRCB */
|
||||||
Prcb->MultiThreadSetMaster = Prcb;
|
Prcb->MultiThreadSetMaster = Prcb;
|
||||||
|
|
||||||
|
@ -813,6 +823,8 @@ AppCpuInit:
|
||||||
__writefsdword(KPCR_SET_MEMBER_COPY, 1 << Cpu);
|
__writefsdword(KPCR_SET_MEMBER_COPY, 1 << Cpu);
|
||||||
__writefsdword(KPCR_PRCB_SET_MEMBER, 1 << Cpu);
|
__writefsdword(KPCR_PRCB_SET_MEMBER, 1 << Cpu);
|
||||||
|
|
||||||
|
KiVerifyCpuFeatures(Pcr->Prcb);
|
||||||
|
|
||||||
/* Initialize the Processor with HAL */
|
/* Initialize the Processor with HAL */
|
||||||
HalInitializeProcessor(Cpu, KeLoaderBlock);
|
HalInitializeProcessor(Cpu, KeLoaderBlock);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue