Remove init.s and put Thomas's code into boot.s, so we don't have 2 files for the same purpose.

Write the few lines of C code that were part of the "final" code into boot.S as 
well, to avoid yet another trampoline jump. and
Thanks again to Thomas for finding and fixing the bug.

svn path=/trunk/; revision=28205
This commit is contained in:
Magnus Olsen
2007-08-06 23:55:35 +00:00
parent 67759e297b
commit e7b5eb420f
6 changed files with 55 additions and 83 deletions
+2
View File
@@ -113,6 +113,7 @@ Author:
#define KTHREAD_WAIT_IRQL 0x4E
#define KTHREAD_NEXT_PROCESSOR 0x40
#define KTHREAD_WAIT_REASON 0x5A
#define KTHREAD_PRIORITY 0x5B
#define KTHREAD_SWAP_BUSY 0x5D
#define KTHREAD_SERVICE_TABLE 0x118
#define KTHREAD_PREVIOUS_MODE 0xD7
@@ -611,3 +612,4 @@ Author:
#endif // !_ASM_H
+11
View File
@@ -829,6 +829,17 @@ KiFlushNPXState(
IN FLOATING_SAVE_AREA *SaveArea
);
VOID
NTAPI
KiSetupStackAndInitializeKernel(
IN PKPROCESS InitProcess,
IN PKTHREAD InitThread,
IN PVOID IdleStack,
IN PKPRCB Prcb,
IN CCHAR Number,
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
VOID
NTAPI
KiInitSpinLocks(
+41 -2
View File
@@ -1,8 +1,9 @@
/*
* FILE: ntoskrnl/ke/i386/boot.S
* COPYRIGHT: See COPYING in the top level directory
* PURPOSE: FreeLDR Wrapper Bootstrap Code
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
* PURPOSE: FreeLDR Wrapper Bootstrap Code and Bootstrap Trampoline
* PROGRAMMERs: Alex Ionescu (alex@relsoft.net)
* Thomas Weidenmueller <w3seek@reactos.org>
*/
/* INCLUDES ******************************************************************/
@@ -38,3 +39,41 @@ _NtProcessStartup:
/* FREELDR Boot: Cal the FreeLDR wrapper */
jmp @KiRosPrepareForSystemStartup@8
.endfunc
.globl _KiSetupStackAndInitializeKernel@24
.func KiSetupStackAndInitializeKernel@24
_KiSetupStackAndInitializeKernel@24:
/* Save current stack */
mov esi, esp
/* Setup the new stack */
mov esp, [esp+12]
sub esp, NPX_FRAME_LENGTH + KTRAP_FRAME_ALIGN + KTRAP_FRAME_LENGTH
push CR0_EM + CR0_TS + CR0_MP
/* Copy all parameters to the new stack */
push [esi+24]
push [esi+20]
push [esi+16]
push [esi+12]
push [esi+8]
push [esi+4]
xor ebp, ebp
call _KiInitializeKernel@24
/* Set the priority of this thread to 0 */
mov ebx, PCR[KPCR_CURRENT_THREAD]
mov byte ptr [ebx+KTHREAD_PRIORITY], 0
/* Force interrupts enabled and lower IRQL back to DISPATCH_LEVEL */
sti
mov ecx, DISPATCH_LEVEL
call @KfLowerIrql@4
/* Set the right wait IRQL */
mov byte ptr [ebx+KTHREAD_WAIT_IRQL], DISPATCH_LEVEL;
/* Jump into the idle loop */
jmp @KiIdleLoop@0
.endfunc
-39
View File
@@ -1,39 +0,0 @@
/*
* FILE: ntoskrnl/ke/i386/init.S
* COPYRIGHT: See COPYING in the top level directory
* PURPOSE: Kernel Initialization
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.org>
*/
/* INCLUDES ******************************************************************/
#include <asm.h>
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
/* FUNCTIONS ******************************************************************/
.text
.globl _KiSetupStackAndInitializeKernel@24
.func KiSetupStackAndInitializeKernel@24
_KiSetupStackAndInitializeKernel@24:
mov esi, esp
/* Setup the new stack */
mov esp, [esp + 12]
sub esp, NPX_FRAME_LENGTH + KTRAP_FRAME_ALIGN + KTRAP_FRAME_LENGTH
push CR0_EM + CR0_TS + CR0_MP
/* Copy all parameters to the new stack */
push [esi + 24]
push [esi + 20]
push [esi + 16]
push [esi + 12]
push [esi + 8]
push [esi + 4]
xor ebp, ebp
call _KiInitializeKernel@24
jmp _KiSystemStartupFinal@0
.endfunc
+1 -41
View File
@@ -12,16 +12,6 @@
#define NDEBUG
#include <debug.h>
VOID
NTAPI
KiSetupStackAndInitializeKernel(IN PKPROCESS InitProcess,
IN PKTHREAD InitThread,
IN PVOID IdleStack,
IN PKPRCB Prcb,
IN CCHAR Number,
IN PLOADER_PARAMETER_BLOCK LoaderBlock);
/* GLOBALS *******************************************************************/
/* Spinlocks used only on X86 */
@@ -765,41 +755,11 @@ AppCpuInit:
/* Align stack and make space for the trap frame and NPX frame */
InitialStack &= ~(KTRAP_FRAME_ALIGN - 1);
/* NOTE: We cannot setup the stack using inline assembly and then later assume
that the compiler is smart enough to figure out how the stack layout
changed! This is to avoid generating wrong code. We cannot directly
call KiInitializeKernel from here! */
/* Switch to new kernel stack and start kernel bootstrapping */
KiSetupStackAndInitializeKernel(&KiInitialProcess.Pcb,
InitialThread,
(PVOID)InitialStack,
(PKPRCB)__readfsdword(KPCR_PRCB),
(CCHAR)Cpu,
KeLoaderBlock);
/* NOTE: KiSetupStackAndInitializeKernel never returns! Do NOT add any code here! */
ASSERT(FALSE);
}
VOID
NTAPI
KiSystemStartupFinal(VOID)
{
/* NOTE: This routine is called after setting up the stack in KiSystemStartup!
This code cannot be moved to KiSystemStartup because it cannot be assumed
that the compiler can generate working code after modifying ESP/EBP
using inline assembly! */
/* Set the priority of this thread to 0 */
KeGetCurrentThread()->Priority = 0;
/* Force interrupts enabled and lower IRQL back to DISPATCH_LEVEL */
_enable();
KfLowerIrql(DISPATCH_LEVEL);
/* Set the right wait IRQL */
KeGetCurrentThread()->WaitIrql = DISPATCH_LEVEL;
/* Jump into the idle loop */
KiIdleLoop();
}
-1
View File
@@ -37,7 +37,6 @@
<file>cpu.c</file>
<file>ctxswitch.S</file>
<file>exp.c</file>
<file>init.S</file>
<file>irqobj.c</file>
<file>kiinit.c</file>
<file>ldt.c</file>