From 902a400b19c6388d67c822e1d4e015953c981df4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 6 Jul 2005 00:29:39 +0000 Subject: [PATCH] Put the page tables and hyperspace at the right place in memory (ie. Windows compatible). svn path=/trunk/; revision=16445 --- reactos/boot/freeldr/freeldr/arch/i386/mb.S | 2 +- reactos/boot/freeldr/freeldr/multiboot.c | 23 +++++++++++---------- reactos/ntoskrnl/mm/i386/page.c | 12 +++++------ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/mb.S b/reactos/boot/freeldr/freeldr/arch/i386/mb.S index 78a3f49aeb2..b2e0cc51fab 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/mb.S +++ b/reactos/boot/freeldr/freeldr/arch/i386/mb.S @@ -72,7 +72,7 @@ _kernel_pagetable: .fill 2*4096, 1, 0 _hyperspace_pagetable: - .fill 4096, 1, 0 + .fill 2*4096, 1, 0 _apic_pagetable: .fill 4096, 1, 0 diff --git a/reactos/boot/freeldr/freeldr/multiboot.c b/reactos/boot/freeldr/freeldr/multiboot.c index b577b747171..4ac2611b71f 100644 --- a/reactos/boot/freeldr/freeldr/multiboot.c +++ b/reactos/boot/freeldr/freeldr/multiboot.c @@ -36,20 +36,21 @@ #define PaToPfn(p) \ ((p) >> PFN_SHIFT) -#define STARTUP_BASE 0xF0000000 -#define HYPERSPACE_BASE 0xF0800000 +#define STARTUP_BASE 0xC0000000 +#define HYPERSPACE_BASE 0xC0400000 +#define HYPERSPACE_PAE_BASE 0xC0800000 #define APIC_BASE 0xFEC00000 #define KPCR_BASE 0xFF000000 #define LowMemPageTableIndex 0 -#define StartupPageTableIndex (STARTUP_BASE >> 20) / sizeof(HARDWARE_PTE_X86) -#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 20) / sizeof(HARDWARE_PTE_X86) -#define KpcrPageTableIndex (KPCR_BASE >> 20) / sizeof(HARDWARE_PTE_X86) -#define ApicPageTableIndex (APIC_BASE >> 20) / sizeof(HARDWARE_PTE_X86) +#define StartupPageTableIndex (STARTUP_BASE >> 22) +#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 22) +#define KpcrPageTableIndex (KPCR_BASE >> 22) +#define ApicPageTableIndex (APIC_BASE >> 22) #define LowMemPageTableIndexPae 0 #define StartupPageTableIndexPae (STARTUP_BASE >> 21) -#define HyperspacePageTableIndexPae (HYPERSPACE_BASE >> 21) +#define HyperspacePageTableIndexPae (HYPERSPACE_PAE_BASE >> 21) #define KpcrPageTableIndexPae (KPCR_BASE >> 21) #define ApicPageTableIndexPae (APIC_BASE >> 21) @@ -250,7 +251,7 @@ FrLdrGetKernelBase(VOID) if (p[4] == ' ' || p[4] == 0) { /* Use 3GB */ - KernelBase = 0xC0000000; + KernelBase = 0xE0000000; } } @@ -447,6 +448,9 @@ FrLdrSetupPageDirectory(VOID) PageDir->Pde[HyperspacePageTableIndex].Valid = 1; PageDir->Pde[HyperspacePageTableIndex].Write = 1; PageDir->Pde[HyperspacePageTableIndex].PageFrameNumber = PaPtrToPfn(hyperspace_pagetable); + PageDir->Pde[HyperspacePageTableIndex + 1].Valid = 1; + PageDir->Pde[HyperspacePageTableIndex + 1].Write = 1; + PageDir->Pde[HyperspacePageTableIndex + 1].PageFrameNumber = PaPtrToPfn(hyperspace_pagetable + 4096); /* Set up the Apic PDE */ PageDir->Pde[ApicPageTableIndex].Valid = 1; @@ -640,9 +644,6 @@ FrLdrMapKernel(FILE *KernelImage) ShortPtr = (PUSHORT)(Address + (*TypeOffset & 0xFFF)); - /* Don't relocate after the end of the loaded driver */ - if ((ULONG_PTR)ShortPtr >= MaxAddress) break; - switch (*TypeOffset >> 12) { case IMAGE_REL_BASED_ABSOLUTE: diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index e8d7eb63554..28ae81b4bee 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -34,13 +34,13 @@ #define PA_ACCESSED (1 << PA_BIT_ACCESSED) #define PA_GLOBAL (1 << PA_BIT_GLOBAL) -#define PAGETABLE_MAP (0xf0000000) -#define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024))) +#define PAGETABLE_MAP (0xc0000000) +#define PAGEDIRECTORY_MAP (0xc0000000 + (PAGETABLE_MAP / (1024))) -#define PAE_PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (512))) +#define PAE_PAGEDIRECTORY_MAP (0xc0000000 + (PAGETABLE_MAP / (512))) -#define HYPERSPACE (0xf0800000) -#define IS_HYPERSPACE(v) (((ULONG)(v) >= 0xF0800000 && (ULONG)(v) < 0xF0C00000)) +#define HYPERSPACE (Ke386Pae ? 0xc0800000 : 0xc0400000) +#define IS_HYPERSPACE(v) (((ULONG)(v) >= HYPERSPACE && (ULONG)(v) < 0xc0c00000)) ULONG MmGlobalKernelPageDirectory[1024]; ULONGLONG MmGlobalKernelPageDirectoryForPAE[2048]; @@ -2390,7 +2390,7 @@ MiInitPageDirectoryMap(VOID) MmGetKernelAddressSpace(), MEMORY_AREA_SYSTEM, &BaseAddress, - 0x400000, + Ke386Pae ? 0x400000 : 0x800000, 0, &hyperspace_desc, TRUE,