Author: ion
Date: Tue Feb 20 23:02:52 2007
New Revision: 25860
URL:
http://svn.reactos.org/svn/reactos?rev=25860&view=rev
Log:
- Get rid of a bunch of multiboot crap FreeLDR was still doing for ReactOS.
- Remove some of the sixtuplicated routines to load a PE file. We're now down to a
single function which takes an ImageType parameter for DLL/EXE/SYS, but even this is still
temporary as the parameter will soon go away.
- We now load drivers in the same nice way that we load the kernel and DLLs, but we
don't yet process their imports and relocate them in FreeLDR, because FreeLDR
doesn't handle forwarders yet.
- We don't need a large hack in KiRosPrepareForSystemStartup anymore since the driver
base addresses are now proper.
- Don't free boot-drivers anymore, since we'll load them in place soon.
- Don't load bootvid twice.
- Remove PAE stuff in FreeLDR since we don't support PAE anyway in the kernel and when
we do, might as well implement it cleanly instead of relying on the broken FreeLDR stuff.
Modified:
trunk/reactos/boot/bootdata/hivesys.inf
trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c
trunk/reactos/ntoskrnl/io/iomgr/driver.c
trunk/reactos/ntoskrnl/ke/freeldr.c
trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/boot/bootdata/hivesys.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesys.inf (original)
+++ trunk/reactos/boot/bootdata/hivesys.inf Tue Feb 20 23:02:52 2007
@@ -492,13 +492,6 @@
HKLM,"SYSTEM\CurrentControlSet\Services\Blue","Start",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\Blue","Type",0x00010001,0x00000001
-; Boot Video Driver
-HKLM,"SYSTEM\CurrentControlSet\Services\BootVideo","ErrorControl",0x00010001,0x00000000
-HKLM,"SYSTEM\CurrentControlSet\Services\BootVideo","Group",0x00000000,"Base"
-HKLM,"SYSTEM\CurrentControlSet\Services\BootVideo","ImagePath",0x00020000,"system32\drivers\bootvid.dll"
-HKLM,"SYSTEM\CurrentControlSet\Services\BootVideo","Start",0x00010001,0x00000000
-HKLM,"SYSTEM\CurrentControlSet\Services\BootVideo","Type",0x00010001,0x00000002
-
; Cdfs (ISO96660) filesystem driver
HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","ErrorControl",0x00010001,0x00000000
HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","Group",0x00000000,"File
System"
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Tue Feb 20 23:02:52 2007
@@ -34,7 +34,6 @@
#define PDE_SHIFT 22
#define PDE_SHIFT_PAE 18
-
/* Converts a Relative Address read from the Kernel into a Physical Address */
#define RaToPa(p) \
(ULONG_PTR)((ULONG_PTR)p + KERNEL_BASE_PHYS)
@@ -59,26 +58,16 @@
#define KpcrPageTableIndex (KPCR_BASE >> 22)
#define ApicPageTableIndex (APIC_BASE >> 22)
-#define LowMemPageTableIndexPae 0
-#define StartupPageTableIndexPae (STARTUP_BASE >> 21)
-#define HyperspacePageTableIndexPae (HYPERSPACE_PAE_BASE >> 21)
-#define KpcrPageTableIndexPae (KPCR_BASE >> 21)
-#define ApicPageTableIndexPae (APIC_BASE >> 21)
-
-
#define KernelEntryPoint (KernelEntry - KERNEL_BASE_PHYS) + KernelBase
/* Load Address of Next Module */
-ULONG_PTR NextModuleBase = 0;
+ULONG_PTR NextModuleBase = KERNEL_BASE_PHYS;
/* Currently Opened Module */
PLOADER_MODULE CurrentModule = NULL;
/* Unrelocated Kernel Base in Virtual Memory */
ULONG_PTR KernelBase;
-
-/* Whether PAE is to be used or not */
-BOOLEAN PaeModeEnabled;
/* Kernel Entrypoint in Physical Memory */
ULONG_PTR KernelEntry;
@@ -135,7 +124,8 @@
BOOLEAN
NTAPI
FrLdrLoadImage(IN PCHAR szFileName,
- IN INT nPos);
+ IN INT nPos,
+ IN BOOLEAN IsKernel);
/* FUNCTIONS *****************************************************************/
@@ -164,9 +154,6 @@
/* Re-initalize EFLAGS */
Ke386EraseFlags();
-
- /* Get the PAE Mode */
- FrLdrGetPaeMode();
/* Initialize the page directory */
FrLdrSetupPageDirectory();
@@ -199,14 +186,6 @@
ULONG_PTR PageDirectoryBaseAddress = (ULONG_PTR)&startup_pagedirectory;
ASMCODE PagedJump;
- if (PaeModeEnabled)
- {
- PageDirectoryBaseAddress = (ULONG_PTR)&startup_pagedirectorytable_pae;
-
- /* Enable PAE */
- __writecr4(__readcr4() | X86_CR4_PAE);
- }
-
/* Set the PDBR */
__writecr3(PageDirectoryBaseAddress);
@@ -216,110 +195,6 @@
/* Jump to Kernel */
PagedJump = (ASMCODE)(PVOID)(KernelEntryPoint);
PagedJump(Magic, &LoaderBlock);
-}
-
-/*++
- * FrLdrGetKernelBase
- * INTERNAL
- *
- * Gets the Kernel Base to use.
- *
- * Params:
- *
- * Returns:
- * None.
- *
- * Remarks:
- * Sets both the FreeLdr internal variable as well as the one which
- * will be used by the Kernel.
- *
- *--*/
-static VOID
-FASTCALL
-FrLdrGetKernelBase(VOID)
-{
- PCHAR p;
-
- /* Set KernelBase */
- LoaderBlock.KernelBase = KernelBase;
-
- /* Read Command Line */
- p = (PCHAR)LoaderBlock.CommandLine;
- while ((p = strchr(p, '/')) != NULL) {
-
- /* Find "/3GB" */
- if (!_strnicmp(p + 1, "3GB", 3)) {
-
- /* Make sure there's nothing following it */
- if (p[4] == ' ' || p[4] == 0) {
-
- /* Use 3GB */
- KernelBase = 0xE0000000;
- LoaderBlock.KernelBase = 0xC0000000;
- }
- }
-
- p++;
- }
-}
-
-/*++
- * FrLdrGetPaeMode
- * INTERNAL
- *
- * Determines whether PAE mode should be enabled or not.
- *
- * Params:
- * None.
- *
- * Returns:
- * None.
- *
- * Remarks:
- * None.
- *
- *--*/
-VOID
-FASTCALL
-FrLdrGetPaeMode(VOID)
-{
- BOOLEAN PaeModeSupported;
-
- PaeModeSupported = FALSE;
- PaeModeEnabled = FALSE;
-
- if (CpuidSupported() & 1)
- {
- ULONG eax, ebx, ecx, FeatureBits;
- GetCpuid(1, &eax, &ebx, &ecx, &FeatureBits);
- if (FeatureBits & X86_FEATURE_PAE)
- {
- PaeModeSupported = TRUE;
- }
- }
-
- if (PaeModeSupported)
- {
- PCHAR p;
-
- /* Read Command Line */
- p = (PCHAR)LoaderBlock.CommandLine;
- while ((p = strchr(p, '/')) != NULL) {
-
- p++;
- /* Find "PAE" */
- if (!_strnicmp(p, "PAE", 3)) {
-
- /* Make sure there's nothing following it */
- if (p[3] == ' ' || p[3] == 0) {
-
- /* Use Pae */
- PaeModeEnabled = TRUE;
- break;
- }
- }
- }
- }
}
/*++
@@ -344,192 +219,85 @@
FrLdrSetupPageDirectory(VOID)
{
PPAGE_DIRECTORY_X86 PageDir;
- PPAGE_DIRECTORY_TABLE_X64 PageDirTablePae;
- PPAGE_DIRECTORY_X64 PageDirPae;
ULONG KernelPageTableIndex;
ULONG i;
- if (PaeModeEnabled) {
-
- /* Get the Kernel Table Index */
- KernelPageTableIndex = (KernelBase >> 21);
-
- /* Get the Startup Page Directory Table */
- PageDirTablePae =
(PPAGE_DIRECTORY_TABLE_X64)&startup_pagedirectorytable_pae;
-
- /* Get the Startup Page Directory */
- PageDirPae = (PPAGE_DIRECTORY_X64)&startup_pagedirectory_pae;
-
- /* Set the Startup page directory table */
- for (i = 0; i < 4; i++)
- {
- PageDirTablePae->Pde[i].Valid = 1;
- PageDirTablePae->Pde[i].PageFrameNumber =
PaPtrToPfn(startup_pagedirectory_pae) + i;
- }
-
- /* Set up the Low Memory PDE */
- for (i = 0; i < 2; i++)
- {
- PageDirPae->Pde[LowMemPageTableIndexPae + i].Valid = 1;
- PageDirPae->Pde[LowMemPageTableIndexPae + i].Write = 1;
- PageDirPae->Pde[LowMemPageTableIndexPae + i].PageFrameNumber =
PaPtrToPfn(lowmem_pagetable_pae) + i;
- }
-
- /* Set up the Kernel PDEs */
- for (i = 0; i < 3; i++)
- {
- PageDirPae->Pde[KernelPageTableIndex + i].Valid = 1;
- PageDirPae->Pde[KernelPageTableIndex + i].Write = 1;
- PageDirPae->Pde[KernelPageTableIndex + i].PageFrameNumber =
PaPtrToPfn(kernel_pagetable_pae) + i;
- }
-
- /* Set up the Startup PDE */
- for (i = 0; i < 4; i++)
- {
- PageDirPae->Pde[StartupPageTableIndexPae + i].Valid = 1;
- PageDirPae->Pde[StartupPageTableIndexPae + i].Write = 1;
- PageDirPae->Pde[StartupPageTableIndexPae + i].PageFrameNumber =
PaPtrToPfn(startup_pagedirectory_pae) + i;
- }
-
- /* Set up the Hyperspace PDE */
- for (i = 0; i < 2; i++)
- {
- PageDirPae->Pde[HyperspacePageTableIndexPae + i].Valid = 1;
- PageDirPae->Pde[HyperspacePageTableIndexPae + i].Write = 1;
- PageDirPae->Pde[HyperspacePageTableIndexPae + i].PageFrameNumber =
PaPtrToPfn(hyperspace_pagetable_pae) + i;
- }
-
- /* Set up the Apic PDE */
- for (i = 0; i < 2; i++)
- {
- PageDirPae->Pde[ApicPageTableIndexPae + i].Valid = 1;
- PageDirPae->Pde[ApicPageTableIndexPae + i].Write = 1;
- PageDirPae->Pde[ApicPageTableIndexPae + i].PageFrameNumber =
PaPtrToPfn(apic_pagetable_pae) + i;
- }
-
- /* Set up the KPCR PDE */
- PageDirPae->Pde[KpcrPageTableIndexPae].Valid = 1;
- PageDirPae->Pde[KpcrPageTableIndexPae].Write = 1;
- PageDirPae->Pde[KpcrPageTableIndexPae].PageFrameNumber =
PaPtrToPfn(kpcr_pagetable_pae);
-
- /* Set up Low Memory PTEs */
- PageDirPae = (PPAGE_DIRECTORY_X64)&lowmem_pagetable_pae;
- for (i=0; i<1024; i++) {
-
- PageDirPae->Pde[i].Valid = 1;
- PageDirPae->Pde[i].Write = 1;
- PageDirPae->Pde[i].Owner = 1;
- PageDirPae->Pde[i].PageFrameNumber = i;
- }
-
- /* Set up Kernel PTEs */
- PageDirPae = (PPAGE_DIRECTORY_X64)&kernel_pagetable_pae;
- for (i=0; i<1536; i++) {
-
- PageDirPae->Pde[i].Valid = 1;
- PageDirPae->Pde[i].Write = 1;
- PageDirPae->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS) + i;
- }
-
- /* Set up APIC PTEs */
- PageDirPae = (PPAGE_DIRECTORY_X64)&apic_pagetable_pae;
- PageDirPae->Pde[0].Valid = 1;
- PageDirPae->Pde[0].Write = 1;
- PageDirPae->Pde[0].CacheDisable = 1;
- PageDirPae->Pde[0].WriteThrough = 1;
- PageDirPae->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
- PageDirPae->Pde[0x200].Valid = 1;
- PageDirPae->Pde[0x200].Write = 1;
- PageDirPae->Pde[0x200].CacheDisable = 1;
- PageDirPae->Pde[0x200].WriteThrough = 1;
- PageDirPae->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE +
KERNEL_BASE_PHYS);
-
- /* Set up KPCR PTEs */
- PageDirPae = (PPAGE_DIRECTORY_X64)&kpcr_pagetable_pae;
- PageDirPae->Pde[0].Valid = 1;
- PageDirPae->Pde[0].Write = 1;
- PageDirPae->Pde[0].PageFrameNumber = 1;
-
- } else {
-
- /* Get the Kernel Table Index */
- KernelPageTableIndex = KernelBase >> PDE_SHIFT;
-
- /* Get the Startup Page Directory */
- PageDir = (PPAGE_DIRECTORY_X86)&startup_pagedirectory;
-
- /* Set up the Low Memory PDE */
- PageDir->Pde[LowMemPageTableIndex].Valid = 1;
- PageDir->Pde[LowMemPageTableIndex].Write = 1;
- PageDir->Pde[LowMemPageTableIndex].PageFrameNumber =
PaPtrToPfn(lowmem_pagetable);
-
- /* Set up the Kernel PDEs */
- PageDir->Pde[KernelPageTableIndex].Valid = 1;
- PageDir->Pde[KernelPageTableIndex].Write = 1;
- PageDir->Pde[KernelPageTableIndex].PageFrameNumber =
PaPtrToPfn(kernel_pagetable);
- PageDir->Pde[KernelPageTableIndex + 1].Valid = 1;
- PageDir->Pde[KernelPageTableIndex + 1].Write = 1;
- PageDir->Pde[KernelPageTableIndex + 1].PageFrameNumber =
PaPtrToPfn(kernel_pagetable + 4096);
-
- /* Set up the Startup PDE */
- PageDir->Pde[StartupPageTableIndex].Valid = 1;
- PageDir->Pde[StartupPageTableIndex].Write = 1;
- PageDir->Pde[StartupPageTableIndex].PageFrameNumber =
PaPtrToPfn(startup_pagedirectory);
-
- /* Set up the Hyperspace PDE */
- PageDir->Pde[HyperspacePageTableIndex].Valid = 1;
- PageDir->Pde[HyperspacePageTableIndex].Write = 1;
- PageDir->Pde[HyperspacePageTableIndex].PageFrameNumber =
PaPtrToPfn(hyperspace_pagetable);
-
- /* Set up the Apic PDE */
- PageDir->Pde[ApicPageTableIndex].Valid = 1;
- PageDir->Pde[ApicPageTableIndex].Write = 1;
- PageDir->Pde[ApicPageTableIndex].PageFrameNumber =
PaPtrToPfn(apic_pagetable);
-
- /* Set up the KPCR PDE */
- PageDir->Pde[KpcrPageTableIndex].Valid = 1;
- PageDir->Pde[KpcrPageTableIndex].Write = 1;
- PageDir->Pde[KpcrPageTableIndex].PageFrameNumber =
PaPtrToPfn(kpcr_pagetable);
-
- /* Set up Low Memory PTEs */
- PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
- for (i=0; i<1024; i++) {
-
- PageDir->Pde[i].Valid = 1;
- PageDir->Pde[i].Write = 1;
- PageDir->Pde[i].Owner = 1;
- PageDir->Pde[i].PageFrameNumber = PaToPfn(i * PAGE_SIZE);
- }
-
- /* Set up Kernel PTEs */
- PageDir = (PPAGE_DIRECTORY_X86)&kernel_pagetable;
- for (i=0; i<1536; i++) {
-
- PageDir->Pde[i].Valid = 1;
- PageDir->Pde[i].Write = 1;
- PageDir->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS + i *
PAGE_SIZE);
- }
-
- /* Set up APIC PTEs */
- PageDir = (PPAGE_DIRECTORY_X86)&apic_pagetable;
- PageDir->Pde[0].Valid = 1;
- PageDir->Pde[0].Write = 1;
- PageDir->Pde[0].CacheDisable = 1;
- PageDir->Pde[0].WriteThrough = 1;
- PageDir->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
- PageDir->Pde[0x200].Valid = 1;
- PageDir->Pde[0x200].Write = 1;
- PageDir->Pde[0x200].CacheDisable = 1;
- PageDir->Pde[0x200].WriteThrough = 1;
- PageDir->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE + KERNEL_BASE_PHYS);
-
- /* Set up KPCR PTEs */
- PageDir = (PPAGE_DIRECTORY_X86)&kpcr_pagetable;
- PageDir->Pde[0].Valid = 1;
- PageDir->Pde[0].Write = 1;
- PageDir->Pde[0].PageFrameNumber = 1;
- }
- return;
+ /* Get the Kernel Table Index */
+ KernelPageTableIndex = KernelBase >> PDE_SHIFT;
+
+ /* Get the Startup Page Directory */
+ PageDir = (PPAGE_DIRECTORY_X86)&startup_pagedirectory;
+
+ /* Set up the Low Memory PDE */
+ PageDir->Pde[LowMemPageTableIndex].Valid = 1;
+ PageDir->Pde[LowMemPageTableIndex].Write = 1;
+ PageDir->Pde[LowMemPageTableIndex].PageFrameNumber =
PaPtrToPfn(lowmem_pagetable);
+
+ /* Set up the Kernel PDEs */
+ PageDir->Pde[KernelPageTableIndex].Valid = 1;
+ PageDir->Pde[KernelPageTableIndex].Write = 1;
+ PageDir->Pde[KernelPageTableIndex].PageFrameNumber =
PaPtrToPfn(kernel_pagetable);
+ PageDir->Pde[KernelPageTableIndex + 1].Valid = 1;
+ PageDir->Pde[KernelPageTableIndex + 1].Write = 1;
+ PageDir->Pde[KernelPageTableIndex + 1].PageFrameNumber =
PaPtrToPfn(kernel_pagetable + 4096);
+
+ /* Set up the Startup PDE */
+ PageDir->Pde[StartupPageTableIndex].Valid = 1;
+ PageDir->Pde[StartupPageTableIndex].Write = 1;
+ PageDir->Pde[StartupPageTableIndex].PageFrameNumber =
PaPtrToPfn(startup_pagedirectory);
+
+ /* Set up the Hyperspace PDE */
+ PageDir->Pde[HyperspacePageTableIndex].Valid = 1;
+ PageDir->Pde[HyperspacePageTableIndex].Write = 1;
+ PageDir->Pde[HyperspacePageTableIndex].PageFrameNumber =
PaPtrToPfn(hyperspace_pagetable);
+
+ /* Set up the Apic PDE */
+ PageDir->Pde[ApicPageTableIndex].Valid = 1;
+ PageDir->Pde[ApicPageTableIndex].Write = 1;
+ PageDir->Pde[ApicPageTableIndex].PageFrameNumber = PaPtrToPfn(apic_pagetable);
+
+ /* Set up the KPCR PDE */
+ PageDir->Pde[KpcrPageTableIndex].Valid = 1;
+ PageDir->Pde[KpcrPageTableIndex].Write = 1;
+ PageDir->Pde[KpcrPageTableIndex].PageFrameNumber = PaPtrToPfn(kpcr_pagetable);
+
+ /* Set up Low Memory PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
+ for (i=0; i<1024; i++) {
+
+ PageDir->Pde[i].Valid = 1;
+ PageDir->Pde[i].Write = 1;
+ PageDir->Pde[i].Owner = 1;
+ PageDir->Pde[i].PageFrameNumber = PaToPfn(i * PAGE_SIZE);
+ }
+
+ /* Set up Kernel PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&kernel_pagetable;
+ for (i=0; i<1536; i++) {
+
+ PageDir->Pde[i].Valid = 1;
+ PageDir->Pde[i].Write = 1;
+ PageDir->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS + i * PAGE_SIZE);
+ }
+
+ /* Set up APIC PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&apic_pagetable;
+ PageDir->Pde[0].Valid = 1;
+ PageDir->Pde[0].Write = 1;
+ PageDir->Pde[0].CacheDisable = 1;
+ PageDir->Pde[0].WriteThrough = 1;
+ PageDir->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
+ PageDir->Pde[0x200].Valid = 1;
+ PageDir->Pde[0x200].Write = 1;
+ PageDir->Pde[0x200].CacheDisable = 1;
+ PageDir->Pde[0x200].WriteThrough = 1;
+ PageDir->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE + KERNEL_BASE_PHYS);
+
+ /* Set up KPCR PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&kpcr_pagetable;
+ PageDir->Pde[0].Valid = 1;
+ PageDir->Pde[0].Write = 1;
+ PageDir->Pde[0].PageFrameNumber = 1;
}
PVOID
@@ -723,10 +491,6 @@
return NULL;
}
-BOOLEAN
-NTAPI
-FrLdrLoadHal(PCHAR szFileName, INT nPos);
-
NTSTATUS
NTAPI
LdrPEGetOrLoadModule(IN PCHAR ModuleName,
@@ -748,7 +512,7 @@
!_stricmp(ImportedName, "bootvid.dll"))
{
/* Load the HAL */
- FrLdrLoadImage(ImportedName, 10);
+ FrLdrLoadImage(ImportedName, 10, FALSE);
/* Return the new module */
*ImportedModule = LdrGetModuleObject(ImportedName);
@@ -847,91 +611,11 @@
}
}
-/*++
- * FrLdrMapKernel
- * INTERNAL
- *
- * Maps the Kernel into memory, does PE Section Mapping, initalizes the
- * uninitialized data sections, and relocates the image.
- *
- * Params:
- * KernelImage - FILE Structure representing the ntoskrnl image file.
- *
- * Returns:
- * TRUE if the Kernel was mapped.
- *
- * Remarks:
- * None.
- *
- *--*/
BOOLEAN
NTAPI
-FrLdrMapKernel(FILE *KernelImage)
-{
- PIMAGE_NT_HEADERS NtHeader;
- ULONG ImageSize;
- PVOID LoadBase;
-
- /* Set the virtual (image) and physical (load) addresses */
- LoadBase = (PVOID)KERNEL_BASE_PHYS;
-
- /* Load the first 1024 bytes of the kernel image so we can read the PE header */
- if (!FsReadFile(KernelImage, 1024, NULL, LoadBase)) return FALSE;
-
- /* Now read the MZ header to get the offset to the PE Header */
- NtHeader = RtlImageNtHeader(LoadBase);
-
- /* Get Kernel Base */
- KernelBase = NtHeader->OptionalHeader.ImageBase;
- FrLdrGetKernelBase();
-
- /* Save Entrypoint */
- KernelEntry = RaToPa(NtHeader->OptionalHeader.AddressOfEntryPoint);
-
- /* Save the Image Size */
- ImageSize = NtHeader->OptionalHeader.SizeOfImage;
-
- /* Set the file pointer to zero */
- FsSetFilePointer(KernelImage, 0);
-
- /* Load the file image */
- FsReadFile(KernelImage, ImageSize, NULL, LoadBase);
-
- /* Map it */
- FrLdrReMapImage(NtHeader, LoadBase);
-
- /* Calculate Difference between Real Base and Compiled Base*/
- LdrRelocateImageWithBias(LoadBase,
- KernelBase - (ULONG_PTR)LoadBase,
- "FreeLdr",
- STATUS_SUCCESS,
- STATUS_UNSUCCESSFUL,
- STATUS_UNSUCCESSFUL);
-
- /* Fill out Module Data Structure */
- reactos_modules[0].ModStart = KernelBase;
- reactos_modules[0].ModEnd = KernelBase + ImageSize;
- strcpy(reactos_module_strings[0], "ntoskrnl.exe");
- reactos_modules[0].String = (ULONG_PTR)reactos_module_strings[0];
- LoaderBlock.ModsCount++;
-
- /* Increase the next Load Base */
- NextModuleBase = ROUND_UP(LoadBase + ImageSize, PAGE_SIZE);
-
- /* Load the HAL now (name will be changed internally if needed) */
- FrLdrLoadImage("hal.dll", 10);
-
- /* Perform import fixups */
- LdrPEFixupImports(LoadBase, "ntoskrnl.exe");
-
- /* Return Success */
- return TRUE;
-}
-
-BOOLEAN
-NTAPI
-FrLdrMapImage(IN FILE *HalImage,
- IN PCHAR Name)
+FrLdrMapImage(IN FILE *Image,
+ IN PCHAR Name,
+ IN ULONG ImageType)
{
PIMAGE_NT_HEADERS NtHeader;
PVOID ImageBase, LoadBase;
@@ -940,10 +624,10 @@
/* Set the virtual (image) and physical (load) addresses */
LoadBase = (PVOID)NextModuleBase;
- ImageBase = RVA(LoadBase , -KERNEL_BASE_PHYS + KSEG0_BASE);
+ ImageBase = RVA(LoadBase , -KERNEL_BASE_PHYS + KSEG0_BASE);
/* Load the first 1024 bytes of the HAL image so we can read the PE header */
- if (!FsReadFile(HalImage, 1024, NULL, LoadBase)) return FALSE;
+ if (!FsReadFile(Image, 1024, NULL, LoadBase)) return FALSE;
/* Now read the MZ header to get the offset to the PE Header */
NtHeader = RtlImageNtHeader(LoadBase);
@@ -952,21 +636,22 @@
ImageSize = NtHeader->OptionalHeader.SizeOfImage;
/* Set the file pointer to zero */
- FsSetFilePointer(HalImage, 0);
+ FsSetFilePointer(Image, 0);
/* Load the file image */
- FsReadFile(HalImage, ImageSize, NULL, LoadBase);
+ FsReadFile(Image, ImageSize, NULL, LoadBase);
/* Map it into virtual memory */
- FrLdrReMapImage(NtHeader, LoadBase);
+ if (ImageType != 2) FrLdrReMapImage(NtHeader, LoadBase);
/* Calculate Difference between Real Base and Compiled Base*/
- LdrRelocateImageWithBias(LoadBase,
- (ULONG_PTR)ImageBase - (ULONG_PTR)LoadBase,
- "FreeLdr",
- STATUS_SUCCESS,
- STATUS_UNSUCCESSFUL,
- STATUS_UNSUCCESSFUL);
+ if (ImageType != 2) LdrRelocateImageWithBias(LoadBase,
+ (ULONG_PTR)ImageBase -
+ (ULONG_PTR)LoadBase,
+ "FreeLdr",
+ STATUS_SUCCESS,
+ STATUS_UNSUCCESSFUL,
+ STATUS_UNSUCCESSFUL);
/* Fill out Module Data Structure */
reactos_modules[ImageId].ModStart = (ULONG_PTR)ImageBase;
@@ -978,9 +663,20 @@
/* Increase the next Load Base */
NextModuleBase = ROUND_UP(NextModuleBase + ImageSize, PAGE_SIZE);
- /* Perform import fixups */
- //DbgPrint("Fixing up: %s loaded at: %p\n", Name, ImageBase);
- LdrPEFixupImports(LoadBase, Name);
+ /* Successful load! */
+ //DbgPrint("Image: %s loaded at: %p\n", Name, ImageBase);
+
+ /* Load HAL if this is the kernel */
+ if (ImageType == 1)
+ {
+ KernelBase = NtHeader->OptionalHeader.ImageBase;
+ KernelEntry = RaToPa(NtHeader->OptionalHeader.AddressOfEntryPoint);
+ FrLdrLoadImage("hal.dll", 10, FALSE);
+ LoaderBlock.KernelBase = KernelBase;
+ }
+
+ /* Perform import fixups */
+ if (ImageType != 2) LdrPEFixupImports(LoadBase, Name);
/* Return Success */
return TRUE;
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c Tue Feb 20 23:02:52 2007
@@ -38,65 +38,19 @@
static CHAR szLoadingMsg[] = "Loading ReactOS...";
BOOLEAN FrLdrBootType;
-static BOOLEAN
-NTAPI
-FrLdrLoadKernel(PCHAR szFileName,
- INT nPos)
-{
- PFILE FilePointer;
- PCHAR szShortName;
- CHAR szBuffer[256];
-
- /* Extract Kernel filename without path */
- szShortName = strrchr(szFileName, '\\');
- if (szShortName == NULL) {
-
- /* No path, leave it alone */
- szShortName = szFileName;
-
- } else {
-
- /* Skip the path */
- szShortName = szShortName + 1;
- }
-
- /* Open the Kernel */
- FilePointer = FsOpenFile(szFileName);
-
- /* Make sure it worked */
- if (FilePointer == NULL) {
-
- /* Return failure on the short name */
- strcpy(szBuffer, szShortName);
- strcat(szBuffer, " not found.");
- UiMessageBox(szBuffer);
- return(FALSE);
- }
-
- /* Update the status bar with the current file */
- strcpy(szBuffer, "Reading ");
- strcat(szBuffer, szShortName);
- UiDrawStatusText(szBuffer);
-
- /* Do the actual loading */
- FrLdrMapKernel(FilePointer);
-
- /* Update Processbar and return success */
- UiDrawProgressBarCenter(nPos, 100, szLoadingMsg);
- return(TRUE);
-}
-
BOOLEAN
NTAPI
FrLdrMapImage(
IN FILE *Image,
- IN PCHAR ShortName
+ IN PCHAR ShortName,
+ IN ULONG ImageType
);
BOOLEAN
NTAPI
FrLdrLoadImage(IN PCHAR szFileName,
- IN INT nPos)
+ IN INT nPos,
+ IN ULONG ImageType)
{
PFILE FilePointer;
PCHAR szShortName;
@@ -153,74 +107,11 @@
UiDrawStatusText(szBuffer);
/* Do the actual loading */
- FrLdrMapImage(FilePointer, szShortName);
+ FrLdrMapImage(FilePointer, szShortName, ImageType);
/* Update Processbar and return success */
if (!FrLdrBootType) UiDrawProgressBarCenter(nPos, 100, szLoadingMsg);
return TRUE;
-}
-
-static VOID
-FreeldrFreeMem(PVOID Area)
-{
- MmFreeMemory(Area);
-}
-
-static PVOID
-FreeldrAllocMem(ULONG_PTR Size)
-{
- return MmAllocateMemory((ULONG) Size);
-}
-
-static BOOLEAN
-FreeldrReadFile(PVOID FileContext, PVOID Buffer, ULONG Size)
-{
- ULONG BytesRead;
-
- return FsReadFile((PFILE) FileContext, (ULONG) Size, &BytesRead, Buffer)
- && Size == BytesRead;
-}
-
-static BOOLEAN
-FreeldrSeekFile(PVOID FileContext, ULONG_PTR Position)
-{
- FsSetFilePointer((PFILE) FileContext, (ULONG) Position);
- return TRUE;
-}
-
-static BOOLEAN
-LoadKernelSymbols(PCHAR szKernelName, int nPos)
-{
- static ROSSYM_CALLBACKS FreeldrCallbacks =
- {
- FreeldrAllocMem,
- FreeldrFreeMem,
- FreeldrReadFile,
- FreeldrSeekFile
- };
- PFILE FilePointer;
- PROSSYM_INFO RosSymInfo;
- ULONG Size;
- ULONG_PTR Base;
- //return TRUE;
-
- RosSymInit(&FreeldrCallbacks);
-
- FilePointer = FsOpenFile(szKernelName);
- if (FilePointer == NULL)
- {
- return FALSE;
- }
- if (! RosSymCreateFromFile(FilePointer, &RosSymInfo))
- {
- return FALSE;
- }
- Base = FrLdrCreateModule("NTOSKRNL.SYM");
- Size = RosSymGetRawDataLength(RosSymInfo);
- RosSymGetRawData(RosSymInfo, (PVOID)Base);
- FrLdrCloseModule(Base, Size);
- RosSymDelete(RosSymInfo);
- return TRUE;
}
static BOOLEAN
@@ -371,49 +262,6 @@
return(FALSE);
}
- return(TRUE);
-}
-
-static BOOLEAN
-FrLdrLoadDriver(PCHAR szFileName,
- INT nPos)
-{
- PFILE FilePointer;
- CHAR value[256];
- LPSTR p;
-
- /* Open the Driver */
- FilePointer = FsOpenFile(szFileName);
-
- /* Make sure we did */
- if (FilePointer == NULL) {
-
- /* Fail if file wasn't opened */
- strcpy(value, szFileName);
- strcat(value, " not found.");
- UiMessageBox(value);
- return(FALSE);
- }
-
- /* Update the status bar with the current file */
- strcpy(value, "Reading ");
- p = strrchr(szFileName, '\\');
- if (p == NULL) {
-
- strcat(value, szFileName);
-
- } else {
-
- strcat(value, p + 1);
-
- }
- UiDrawStatusText(value);
-
- /* Load the driver */
- FrLdrLoadModule(FilePointer, szFileName, NULL);
-
- /* Update status and return */
- UiDrawProgressBarCenter(nPos, 100, szLoadingMsg);
return(TRUE);
}
@@ -552,7 +400,7 @@
/* Update the position if needed */
if (nPos < 100) nPos += 5;
- FrLdrLoadDriver(ImagePath, nPos);
+ FrLdrLoadImage(ImagePath, nPos, 2);
} else {
@@ -621,7 +469,7 @@
if (nPos < 100) nPos += 5;
- FrLdrLoadDriver(ImagePath, nPos);
+ FrLdrLoadImage(ImagePath, nPos, 2);
} else {
@@ -647,15 +495,12 @@
CHAR SystemPath[255];
CHAR szKernelName[255];
CHAR szFileName[255];
- UINT i;
CHAR MsgBuffer[256];
ULONG SectionId;
ULONG_PTR Base;
ULONG Size;
- extern ULONG PageDirectoryStart;
- extern ULONG PageDirectoryEnd;
extern BOOLEAN AcpiPresent;
//
@@ -676,47 +521,36 @@
/*
* Setup multiboot information structure
*/
- LoaderBlock.Flags = MB_FLAGS_BOOT_DEVICE | MB_FLAGS_COMMAND_LINE |
MB_FLAGS_MODULE_INFO;
- LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart;
- LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd;
- LoaderBlock.BootDevice = 0xffffffff;
LoaderBlock.CommandLine = reactos_kernel_cmdline;
LoaderBlock.ModsCount = 0;
LoaderBlock.ModsAddr = reactos_modules;
LoaderBlock.DrivesAddr = reactos_arc_disk_info;
- LoaderBlock.MmapLength = (unsigned
long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&reactos_memory_map, 32) *
sizeof(memory_map_t);
- if (LoaderBlock.MmapLength)
- {
- LoaderBlock.MmapAddr = (unsigned long)&reactos_memory_map;
- LoaderBlock.Flags |= MB_FLAGS_MEM_INFO | MB_FLAGS_MMAP_INFO;
- reactos_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap uses a
fixed value of 24
- DbgPrint((DPRINT_REACTOS, "memory map length: %d\n",
LoaderBlock.MmapLength));
- DbgPrint((DPRINT_REACTOS, "dumping memory map:\n"));
- for (i=0; i<(LoaderBlock.MmapLength/sizeof(memory_map_t)); i++)
- {
- if (BiosMemoryUsable == reactos_memory_map[i].type &&
- 0 == reactos_memory_map[i].base_addr_low)
- {
- LoaderBlock.MemLower = (reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low) / 1024;
- if (640 < LoaderBlock.MemLower)
- {
- LoaderBlock.MemLower = 640;
- }
- }
- if (BiosMemoryUsable == reactos_memory_map[i].type &&
- reactos_memory_map[i].base_addr_low <= 1024 * 1024 &&
- 1024 * 1024 <= reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low)
- {
- LoaderBlock.MemHigher = (reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low) / 1024 - 1024;
- }
- DbgPrint((DPRINT_REACTOS, "start: %x\t size: %x\t type %d\n",
- reactos_memory_map[i].base_addr_low,
- reactos_memory_map[i].length_low,
- reactos_memory_map[i].type));
- }
- }
- DbgPrint((DPRINT_REACTOS, "low_mem = %d\n", LoaderBlock.MemLower));
- DbgPrint((DPRINT_REACTOS, "high_mem = %d\n", LoaderBlock.MemHigher));
+ LoaderBlock.MmapLength = (unsigned
long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&reactos_memory_map, 32) *
sizeof(memory_map_t);
+ if (LoaderBlock.MmapLength)
+ {
+ ULONG i;
+
+ LoaderBlock.MmapAddr = (unsigned long)&reactos_memory_map;
+ reactos_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap
uses a fixed value of 24
+ for (i=0; i<(LoaderBlock.MmapLength/sizeof(memory_map_t)); i++)
+ {
+ if (BiosMemoryUsable == reactos_memory_map[i].type &&
+ 0 == reactos_memory_map[i].base_addr_low)
+ {
+ LoaderBlock.MemLower = (reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low) / 1024;
+ if (640 < LoaderBlock.MemLower)
+ {
+ LoaderBlock.MemLower = 640;
+ }
+ }
+ if (BiosMemoryUsable == reactos_memory_map[i].type &&
+ reactos_memory_map[i].base_addr_low <= 1024 * 1024 &&
+ 1024 * 1024 <= reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low)
+ {
+ LoaderBlock.MemHigher = (reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low) / 1024 - 1024;
+ }
+ }
+ }
/*
* Initialize the registry
@@ -848,7 +682,7 @@
}
/* Load the kernel */
- if (!FrLdrLoadKernel(szKernelName, 5)) return;
+ if (!FrLdrLoadImage(szKernelName, 5, 1)) return;
/*
* Load the System hive from disk
@@ -915,12 +749,6 @@
return;
}
UiDrawProgressBarCenter(30, 100, szLoadingMsg);
-
- /*
- * Load kernel symbols
- */
- LoadKernelSymbols(szKernelName, 30);
- UiDrawProgressBarCenter(40, 100, szLoadingMsg);
/*
* Load boot drivers
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c Tue Feb 20 23:02:52 2007
@@ -31,21 +31,13 @@
#define USE_UI
-static BOOLEAN
-FreeldrReadFile(PVOID FileContext, PVOID Buffer, ULONG Size)
-{
- ULONG BytesRead;
-
- return FsReadFile((PFILE) FileContext, (ULONG) Size, &BytesRead, Buffer)
- && Size == BytesRead;
-}
-
-static BOOLEAN
-FreeldrSeekFile(PVOID FileContext, ULONG_PTR Position)
-{
- FsSetFilePointer((PFILE) FileContext, (ULONG) Position);
- return TRUE;
-}
+BOOLEAN
+NTAPI
+FrLdrMapImage(
+ IN FILE *Image,
+ IN PCHAR ShortName,
+ IN ULONG ImageType
+);
BOOLEAN
NTAPI
@@ -86,65 +78,10 @@
UiDrawStatusText(szBuffer);
/* Do the actual loading */
- FrLdrMapKernel(FilePointer);
+ FrLdrMapImage(FilePointer, szShortName, 1);
/* Update Processbar and return success */
return TRUE;
-}
-
-static BOOLEAN
-LoadKernelSymbols(PCSTR szSourcePath, PCSTR szFileName)
-{
- static ROSSYM_CALLBACKS FreeldrCallbacks =
- {
- MmAllocateMemory,
- MmFreeMemory,
- FreeldrReadFile,
- FreeldrSeekFile
- };
- CHAR szFullName[256];
- PFILE FilePointer;
- PROSSYM_INFO RosSymInfo;
- ULONG Size;
- ULONG_PTR Base;
-
- if (szSourcePath[0] != '\\')
- {
- strcpy(szFullName, "\\");
- strcat(szFullName, szSourcePath);
- }
- else
- {
- strcpy(szFullName, szSourcePath);
- }
-
- if (szFullName[strlen(szFullName)] != '\\')
- {
- strcat(szFullName, "\\");
- }
-
- if (szFileName[0] != '\\')
- {
- strcat(szFullName, szFileName);
- }
- else
- {
- strcat(szFullName, szFileName + 1);
- }
-
- RosSymInit(&FreeldrCallbacks);
-
- FilePointer = FsOpenFile(szFullName);
- if (FilePointer && RosSymCreateFromFile(FilePointer, &RosSymInfo))
- {
- Base = FrLdrCreateModule("NTOSKRNL.SYM");
- Size = RosSymGetRawDataLength(RosSymInfo);
- RosSymGetRawData(RosSymInfo, (PVOID)Base);
- FrLdrCloseModule(Base, Size);
- RosSymDelete(RosSymInfo);
- return TRUE;
- }
- return FALSE;
}
static BOOLEAN
@@ -206,7 +143,7 @@
#endif
/* Load the driver */
- FrLdrLoadModule(FilePointer, szFileName, NULL);
+ FrLdrMapImage(FilePointer, (LPSTR)szFileName, 2);
return(TRUE);
}
@@ -282,60 +219,42 @@
ULONG Size;
const char *SourcePath;
const char *LoadOptions;
- UINT i;
char szKernelName[256];
HINF InfHandle;
ULONG ErrorLine;
INFCONTEXT InfContext;
- extern ULONG PageDirectoryStart;
- extern ULONG PageDirectoryEnd;
-
/* Setup multiboot information structure */
- LoaderBlock.Flags = MB_FLAGS_BOOT_DEVICE | MB_FLAGS_COMMAND_LINE |
MB_FLAGS_MODULE_INFO;
- LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart;
- LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd;
- LoaderBlock.BootDevice = 0xffffffff;
LoaderBlock.CommandLine = reactos_kernel_cmdline;
LoaderBlock.ModsCount = 0;
LoaderBlock.ModsAddr = reactos_modules;
LoaderBlock.MmapLength = (unsigned
long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&reactos_memory_map, 32) *
sizeof(memory_map_t);
if (LoaderBlock.MmapLength)
- {
+ {
+ ULONG i;
+
LoaderBlock.MmapAddr = (unsigned long)&reactos_memory_map;
- LoaderBlock.Flags |= MB_FLAGS_MEM_INFO | MB_FLAGS_MMAP_INFO;
reactos_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap uses
a fixed value of 24
- for (i = 0; i < (LoaderBlock.MmapLength / sizeof(memory_map_t)); i++)
- {
+ for (i=0; i<(LoaderBlock.MmapLength/sizeof(memory_map_t)); i++)
+ {
if (BiosMemoryUsable == reactos_memory_map[i].type &&
0 == reactos_memory_map[i].base_addr_low)
- {
+ {
LoaderBlock.MemLower = (reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low) / 1024;
if (640 < LoaderBlock.MemLower)
- {
+ {
LoaderBlock.MemLower = 640;
- }
- }
+ }
+ }
if (BiosMemoryUsable == reactos_memory_map[i].type &&
reactos_memory_map[i].base_addr_low <= 1024 * 1024 &&
1024 * 1024 <= reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low)
- {
+ {
LoaderBlock.MemHigher = (reactos_memory_map[i].base_addr_low +
reactos_memory_map[i].length_low) / 1024 - 1024;
- }
-#if 0
- printf("start: %x\t size: %x\t type %d\n",
- reactos_memory_map[i].base_addr_low,
- reactos_memory_map[i].length_low,
- reactos_memory_map[i].type);
-#endif
- }
- }
-#if 0
- printf("low_mem = %d\n", LoaderBlock.MemLower);
- printf("high_mem = %d\n", LoaderBlock.MemHigher);
- MachConsGetCh();
-#endif
+ }
+ }
+ }
#ifdef USE_UI
SetupUiInitialize();
@@ -431,9 +350,6 @@
/* Load the kernel */
if (!FrLdrLoadKernel(szKernelName, 5)) return;
- /* Create ntoskrnl.sym */
- LoadKernelSymbols(SourcePath, "ntoskrnl.exe");
-
/* Export the hardware hive */
Base = FrLdrCreateModule ("HARDWARE");
RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PVOID)Base,
&Size);
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c Tue Feb 20 23:02:52 2007
@@ -803,17 +803,6 @@
}
return STATUS_SUCCESS;
-}
-
-static VOID INIT_FUNCTION
-MiFreeBootDriverMemory(PVOID StartAddress, ULONG Length)
-{
- ULONG i;
-
- for (i = 0; i < PAGE_ROUND_UP(Length) / PAGE_SIZE; i++)
- {
- MmDeleteVirtualMapping(NULL, (char*)StartAddress + i * PAGE_SIZE, TRUE, NULL,
NULL);
- }
}
/*
@@ -1028,7 +1017,7 @@
}
/* Loop modules again */
- NextEntry = ListHead->Flink->Flink->Flink->Flink;
+ NextEntry = ListHead->Flink;
while (ListHead != NextEntry)
{
/* Get the entry */
@@ -1037,11 +1026,10 @@
InLoadOrderLinks);
/* Free memory */
- DPRINT("Freeing memory at: %p of size: %lx for module: %wZ\n",
+ DPRINT("Driver at: %p ending at: %p for module: %wZ\n",
LdrEntry->DllBase,
- LdrEntry->SizeOfImage,
+ (ULONG_PTR)LdrEntry->DllBase+ LdrEntry->SizeOfImage,
&LdrEntry->FullDllName);
- MiFreeBootDriverMemory(LdrEntry->DllBase, LdrEntry->SizeOfImage);
/* Go to the next driver */
NextEntry = NextEntry->Flink;
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 Tue Feb 20 23:02:52 2007
@@ -98,6 +98,7 @@
if (!_stricmp(DriverName, "ansi.nls"))
{
/* ANSI Code page */
+ ModStart = (PVOID)((ULONG_PTR)ModStart + (KSEG0_BASE - 0x200000));
LoaderBlock->NlsData->AnsiCodePageData = ModStart;
/* Create an MD for it */
@@ -112,6 +113,7 @@
else if (!_stricmp(DriverName, "oem.nls"))
{
/* OEM Code page */
+ ModStart = (PVOID)((ULONG_PTR)ModStart + (KSEG0_BASE - 0x200000));
LoaderBlock->NlsData->OemCodePageData = ModStart;
/* Create an MD for it */
@@ -126,6 +128,7 @@
else if (!_stricmp(DriverName, "casemap.nls"))
{
/* Unicode Code page */
+ ModStart = (PVOID)((ULONG_PTR)ModStart + (KSEG0_BASE - 0x200000));
LoaderBlock->NlsData->UnicodeCodePageData = ModStart;
/* Create an MD for it */
@@ -143,6 +146,7 @@
!(_stricmp(DriverName, "system.hiv")))
{
/* Save registry data */
+ ModStart = (PVOID)((ULONG_PTR)ModStart + (KSEG0_BASE - 0x200000));
LoaderBlock->RegistryBase = ModStart;
LoaderBlock->RegistryLength = ModSize;
@@ -164,6 +168,7 @@
!(_stricmp(DriverName, "hardware.hiv")))
{
/* Create an MD for it */
+ ModStart = (PVOID)((ULONG_PTR)ModStart + (KSEG0_BASE - 0x200000));
MdEntry = &BldrMemoryDescriptors[i];
MdEntry->MemoryType = LoaderRegistryData;
MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT;
@@ -315,7 +320,6 @@
KiRosPrepareForSystemStartup(IN ULONG Dummy,
IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
{
- ULONG i;
PLOADER_PARAMETER_BLOCK NtLoaderBlock;
PKTSS Tss;
PKGDTENTRY TssEntry;
@@ -337,25 +341,6 @@
/* Save pointer to ROS Block */
KeRosLoaderBlock = LoaderBlock;
- /* Save the Base Address */
- MmSystemRangeStart = (PVOID)KeRosLoaderBlock->KernelBase;
-
- /* Convert every driver address to virtual memory */
- for (i = 3; i < KeRosLoaderBlock->ModsCount; i++)
- {
- /* Subtract the base Address in Physical Memory */
- KeRosLoaderBlock->ModsAddr[i].ModStart -= 0x200000;
-
- /* Add the Kernel Base Address in Virtual Memory */
- KeRosLoaderBlock->ModsAddr[i].ModStart += KSEG0_BASE;
-
- /* Subtract the base Address in Physical Memory */
- KeRosLoaderBlock->ModsAddr[i].ModEnd -= 0x200000;
-
- /* Add the Kernel Base Address in Virtual Memory */
- KeRosLoaderBlock->ModsAddr[i].ModEnd += KSEG0_BASE;
- }
-
/* Save memory manager data */
MmFreeLdrLastKernelAddress = PAGE_ROUND_UP(KeRosLoaderBlock->
ModsAddr[KeRosLoaderBlock->
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c Tue Feb 20 23:02:52 2007
@@ -350,6 +350,7 @@
}
/* Set memory limits */
+ MmSystemRangeStart = (PVOID)KSEG0_BASE;
MmUserProbeAddress = (ULONG_PTR)MmSystemRangeStart - 0x10000;
MmHighestUserAddress = (PVOID)(MmUserProbeAddress - 1);