Author: ion
Date: Sun Oct 1 10:08:05 2006
New Revision: 24333
URL:
http://svn.reactos.org/svn/reactos?rev=24333&view=rev
Log:
- Remove all the remaining code in boot.S and make KiRosPrepareForSystemStartup fastcall.
Now NtProcessStartup just does a jmp to KiRosPrepareForSystemStartup without any other
code.
- Use freeldr's stack during all of freeldr.c, and only switch to the boot stack in
KiSystemStartup before calling KiInitializeKernel. This is what NT does as well (it
piggybacks on NTLDR's stack until then). This allowed us to clean boot.S and now we
can boot from NTLDR properly.
Modified:
trunk/reactos/ntoskrnl/ke/freeldr.c
trunk/reactos/ntoskrnl/ke/i386/boot.S
trunk/reactos/ntoskrnl/ke/i386/kiinit.c
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c Sun Oct 1 10:08:05 2006
@@ -244,8 +244,9 @@
}
VOID
-NTAPI
-KiRosPrepareForSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
+FASTCALL
+KiRosPrepareForSystemStartup(IN ULONG Dummy,
+ IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG i;
ULONG size;
Modified: trunk/reactos/ntoskrnl/ke/i386/boot.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/boot.S?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/boot.S (original)
+++ trunk/reactos/ntoskrnl/ke/i386/boot.S Sun Oct 1 10:08:05 2006
@@ -1,7 +1,7 @@
/*
* FILE: ntoskrnl/ke/i386/boot.S
* COPYRIGHT: See COPYING in the top level directory
- * PURPOSE: Kernel Bootstrap Code
+ * PURPOSE: FreeLDR Wrapper Bootstrap Code
* PROGRAMMER: Alex Ionescu (alex(a)relsoft.net)
*/
@@ -30,16 +30,6 @@
.text
.func NtProcessStartup
_NtProcessStartup:
-
- /* Load the initial kernel stack */
- lea eax, _P0BootStack
- sub eax, (NPX_FRAME_LENGTH + KTRAP_FRAME_LENGTH + KTRAP_FRAME_ALIGN)
- mov esp, eax
-
- /* Save initial CR0 state */
- push CR0_EM + CR0_TS + CR0_MP
-
/* Call the main kernel initialization */
- push edx
- call _KiRosPrepareForSystemStartup@4
+ jmp @KiRosPrepareForSystemStartup@8
.endfunc
Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Sun Oct 1 10:08:05 2006
@@ -281,7 +281,7 @@
{
ULONG Cpu;
PKTHREAD InitialThread;
- PVOID InitialStack;
+ ULONG InitialStack;
PKGDTENTRY Gdt;
PKIDTENTRY Idt;
PKTSS Tss;
@@ -302,7 +302,7 @@
}
/* Save the initial thread and stack */
- InitialStack = (PVOID)LoaderBlock->KernelStack;
+ InitialStack = LoaderBlock->KernelStack;
InitialThread = (PKTHREAD)LoaderBlock->Thread;
/* Clean the APC List Head */
@@ -375,13 +375,21 @@
/* Raise to HIGH_LEVEL */
KfRaiseIrql(HIGH_LEVEL);
+ /* Align stack and make space for the trap frame and NPX frame */
+ InitialStack &= ~KTRAP_FRAME_ALIGN;
+ __asm__ __volatile__("movl %0,%%esp" : :"r" (InitialStack));
+ __asm__ __volatile__("subl %0,%%esp" : :"r" (NPX_FRAME_LENGTH +
+ KTRAP_FRAME_LENGTH +
+ KTRAP_FRAME_ALIGN));
+ __asm__ __volatile__("push %0" : :"r" (CR0_EM + CR0_TS +
CR0_MP));
+
/* Call main kernel initialization */
KiInitializeKernel(&KiInitialProcess.Pcb,
InitialThread,
- InitialStack,
+ (PVOID)InitialStack,
(PKPRCB)__readfsdword(KPCR_PRCB),
Cpu,
- LoaderBlock);
+ KeLoaderBlock);
/* Set the priority of this thread to 0 */
KeGetCurrentThread()->Priority = 0;