https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d2a3b1c7919031154a9d4…
commit d2a3b1c7919031154a9d447b71669f1e29ce043f
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Dec 2 16:42:20 2023 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Fri Dec 8 20:16:51 2023 +0200
[NTOS:KE/x64] Factor out KiInitializeP0BootStructures
---
ntoskrnl/ke/amd64/kiinit.c | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c
index 999b09b4fbe..568eefc0384 100644
--- a/ntoskrnl/ke/amd64/kiinit.c
+++ b/ntoskrnl/ke/amd64/kiinit.c
@@ -279,6 +279,29 @@ KiInitializeTss(
Tss->Ist[3] = (ULONG64)NmiStack;
}
+CODE_SEG("INIT")
+static
+VOID
+KiInitializeP0BootStructures(
+ _Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ /* Set the initial stack, idle thread and process for processor 0 */
+ LoaderBlock->KernelStack = (ULONG_PTR)KiP0BootStack;
+ LoaderBlock->Thread = (ULONG_PTR)&KiInitialThread;
+ LoaderBlock->Process = (ULONG_PTR)&KiInitialProcess.Pcb;
+ LoaderBlock->Prcb = (ULONG_PTR)&KiInitialPcr.Prcb;
+
+ /* Initialize the PCR */
+ KiInitializePcr(&KiInitialPcr, 0, &KiInitialThread.Tcb,
KiP0DoubleFaultStack);
+
+ /* Setup the TSS descriptors and entries */
+ KiInitializeTss(&KiInitialPcr,
+ KiInitialPcr.TssBase,
+ KiP0BootStack,
+ KiP0DoubleFaultStack,
+ KiP0DoubleFaultStack);
+}
+
CODE_SEG("INIT")
VOID
NTAPI
@@ -436,21 +459,8 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
/* Save the loader block */
KeLoaderBlock = LoaderBlock;
- /* Set the initial stack, idle thread and process */
- LoaderBlock->KernelStack = (ULONG_PTR)KiP0BootStack;
- LoaderBlock->Thread = (ULONG_PTR)&KiInitialThread;
- LoaderBlock->Process = (ULONG_PTR)&KiInitialProcess.Pcb;
- LoaderBlock->Prcb = (ULONG_PTR)&KiInitialPcr.Prcb;
-
- /* Initialize the PCR */
- KiInitializePcr(&KiInitialPcr, 0, &KiInitialThread.Tcb,
KiP0DoubleFaultStack);
-
- /* Setup the TSS descriptors and entries */
- KiInitializeTss(&KiInitialPcr,
- KiInitialPcr.TssBase,
- KiP0BootStack,
- KiP0DoubleFaultStack,
- KiP0DoubleFaultStack);
+ /* Prepare LoaderBlock, PCR, TSS with the P0 boot data */
+ KiInitializeP0BootStructures(LoaderBlock);
}
/* Get Pcr from loader block */