- Allocated the initial stacks page aligned.

- Add a guard page for the initial stacks.
- Fixed the size of the initial stacks.

svn path=/trunk/; revision=20897
This commit is contained in:
Hartmut Birr
2006-01-15 18:28:40 +00:00
parent 328e260852
commit d95e04f38a
3 changed files with 42 additions and 18 deletions
+28 -4
View File
@@ -3,8 +3,33 @@
#define AP_MAGIC (0x12481020)
.global _kernel_stack
.global _kernel_stack_top
.global _kernel_trap_stack
.global _kernel_trap_stack_top
.globl _NtProcessStartup
.bss
.align 4096
/* guard page for the kernel stack */
.fill 4096, 1, 0
_kernel_stack:
.fill 3*4096, 1, 0
_kernel_stack_top:
/* guard page for the trap stack */
.fill 4096, 1, 0
_kernel_trap_stack:
.fill 3*4096, 1, 0
_kernel_trap_stack_top:
.text
_NtProcessStartup:
/* FIXME: Application processors should have their own GDT/IDT */
@@ -34,13 +59,12 @@ _NtProcessStartup:
.m1:
/* Load the initial kernel stack */
lea _kernel_stack, %eax
add $0x2000, %eax
and $0xFFFFE000, %eax
add $(0x3000 - SIZEOF_FX_SAVE_AREA), %eax
lea _kernel_stack_top, %eax
sub $(SIZEOF_FX_SAVE_AREA), %eax
movl %eax, %esp
/* Call the main kernel initialization */
pushl %edx
pushl %ecx
call __main
+9 -14
View File
@@ -48,15 +48,17 @@ PVOID KeRaiseUserExceptionDispatcher = NULL;
ULONG KeLargestCacheLine = 0x40; /* FIXME: Arch-specific */
/* We allocate 5 pages, but we only use 4. The 5th is to guarantee page alignment */
ULONG kernel_stack[5120];
ULONG double_trap_stack[5120];
/* the initial stacks are declared in main_asm.S */
extern ULONG kernel_stack;
extern ULONG kernel_stack_top;
extern ULONG kernel_trap_stack;
extern ULONG kernel_trap_stack_top;
/* These point to the aligned 3 pages */
ULONG init_stack;
ULONG init_stack_top;
ULONG trap_stack;
ULONG trap_stack_top;
ULONG init_stack = (ULONG)&kernel_stack;
ULONG init_stack_top = (ULONG)&kernel_stack_top;
ULONG trap_stack = (ULONG)&kernel_trap_stack;
ULONG trap_stack_top = (ULONG)&kernel_trap_stack_top;
/* Cached modules from the loader block */
PLOADER_MODULE CachedModules[MaximumCachedModuleType];
@@ -155,13 +157,6 @@ _main(ULONG MultiBootMagic,
PIMAGE_OPTIONAL_HEADER OptHead;
CHAR* s;
/* Set up the Stacks (Initial Kernel Stack and Double Trap Stack)
and save a page for the fx savings area */
trap_stack = PAGE_ROUND_UP(&double_trap_stack) + PAGE_SIZE;
trap_stack_top = trap_stack + 3 * PAGE_SIZE;
init_stack = PAGE_ROUND_UP(&kernel_stack) + PAGE_SIZE;
init_stack_top = init_stack + 3 * PAGE_SIZE;
/* Copy the Loader Block Data locally since Low-Memory will be wiped */
memcpy(&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK));
memcpy(&KeLoaderModules[1],
+5
View File
@@ -38,6 +38,7 @@ ULONG MiNonPagedPoolLength;
extern ULONG init_stack;
extern ULONG init_stack_top;
extern ULONG trap_stack;
VOID INIT_FUNCTION NTAPI MmInitVirtualMemory(ULONG_PTR LastKernelAddress, ULONG KernelLength);
@@ -394,6 +395,10 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
AddressRangeCount);
kernel_len = LastKrnlPhysAddr - FirstKrnlPhysAddr;
/* Unmap the guard pages from the initial stacks */
MmDeleteVirtualMapping(NULL, (PVOID)(init_stack - PAGE_SIZE), FALSE, NULL, NULL);
MmDeleteVirtualMapping(NULL, (PVOID)(trap_stack - PAGE_SIZE), FALSE, NULL, NULL);
/*
* Unmap low memory
*/