Author: tkreuzer
Date: Wed Aug 31 13:47:25 2011
New Revision: 53510
URL:
http://svn.reactos.org/svn/reactos?rev=53510&view=rev
Log:
[FREELDR]
- Massively refactor the winldr code
- move common parts of LoadReactOSSetup and LoadAndBootWindows into
LoadAndBootWindowsCommon
- Combine architecture specific code into 2 functions: WinLdrSetupMachineDependent
prepares the main stuff and WinLdrSetProcessorContext is the last thing done before
transferring control to the kernel.
- rename WinLdrTunOnPaging to WinLdrSetupMemoryLayout
- Stop wasting stack space by decreasing the number of huge text buffers used
- Don't handle x86 specific data like Tss in portable code
- Add the progressbar for reactos setup as well
- Add missing DPRINT_PELOADER to DEBUG_ALL
Modified:
trunk/reactos/boot/bootdata/bootcd.ini
trunk/reactos/boot/freeldr/freeldr/arch/amd64/wlmemory.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/ntsetup.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/wlmemory.c
trunk/reactos/boot/freeldr/freeldr/bootmgr.c
trunk/reactos/boot/freeldr/freeldr/debug.c
trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
trunk/reactos/boot/freeldr/freeldr/include/winldr.h
trunk/reactos/boot/freeldr/freeldr/windows/setupldr.c
trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c
Modified: trunk/reactos/boot/bootdata/bootcd.ini
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/bootcd.ini?r…
==============================================================================
--- trunk/reactos/boot/bootdata/bootcd.ini [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/bootcd.ini [iso-8859-1] Wed Aug 31 13:47:25 2011
@@ -13,15 +13,20 @@
TitleBoxColor=Red
MessageBoxTextColor=White
MessageBoxColor=Blue
-MenuTextColor=White
-MenuColor=Blue
-TextColor=Yellow
+MenuTextColor=Gray
+MenuColor=Black
+TextColor=Gray
SelectedTextColor=Black
SelectedColor=Gray
+ShowTime=No
+MenuBox=No
+CenterMenu=No
+MinimalUI=Yes
+TimeText=Seconds until highlighted choice will be started automatically:
[Operating Systems]
Setup="Setup"
[Setup]
-BootType=ReactOSSetup2
+BootType=ReactOSSetup
Modified: trunk/reactos/boot/freeldr/freeldr/arch/amd64/wlmemory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/amd64/wlmemory.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/wlmemory.c [iso-8859-1] Wed Aug 31
13:47:25 2011
@@ -22,6 +22,9 @@
PHARDWARE_PTE PxeBase;
//PHARDWARE_PTE HalPageTable;
+PVOID GdtIdt;
+ULONG PcrBasePage;
+ULONG TssBasePage;
/* FUNCTIONS **************************************************************/
@@ -43,8 +46,8 @@
/* Zero the PML4 */
RtlZeroMemory(PxeBase, PAGE_SIZE);
- /* The page tables are located at 0xfffff68000000000
- * We create a recursive self mapping through all 4 levels at
+ /* The page tables are located at 0xfffff68000000000
+ * We create a recursive self mapping through all 4 levels at
* virtual address 0xfffff6fb7dbedf68 */
PxeBase[VAtoPXI(PXE_BASE)].Valid = 1;
PxeBase[VAtoPXI(PXE_BASE)].Write = 1;
@@ -117,7 +120,7 @@
{
PHARDWARE_PTE PpeBase, PdeBase, PteBase;
ULONG Index;
-
+
Index = VAtoPXI(VirtualAddress);
if (!PxeBase[Index].Valid)
return FALSE;
@@ -161,7 +164,7 @@
MempSetupPaging(IN ULONG StartPage,
IN ULONG NumberOfPages)
{
- DPRINTM(DPRINT_WINDOWS,">>> MempSetupPaging(0x%lx, %ld, %p)\n",
+ DPRINTM(DPRINT_WINDOWS,">>> MempSetupPaging(0x%lx, %ld, %p)\n",
StartPage, NumberOfPages, StartPage * PAGE_SIZE + KSEG0_BASE);
/* Identity mapping */
@@ -247,7 +250,7 @@
}
VOID
-WinLdrSetupGdt(PVOID GdtBase, ULONG64 TssBase)
+Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
{
PKGDTENTRY64 Entry;
KDESCRIPTOR GdtDesc;
@@ -295,7 +298,7 @@
}
VOID
-WinLdrSetupIdt(PVOID IdtBase)
+Amd64SetupIdt(PVOID IdtBase)
{
KDESCRIPTOR IdtDesc, OldIdt;
@@ -316,9 +319,9 @@
}
VOID
-WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG64 Pcr, IN ULONG64 Tss)
-{
- DPRINTM(DPRINT_WINDOWS, "WinLdrSetProcessorContext %p\n", Pcr);
+WinLdrSetProcessorContext(void)
+{
+ DPRINTM(DPRINT_WINDOWS, "WinLdrSetProcessorContext\n");
/* Disable Interrupts */
_disable();
@@ -333,10 +336,10 @@
GdtIdt = (PVOID)((ULONG64)GdtIdt + KSEG0_BASE);
/* Create gdt entries and load gdtr */
- WinLdrSetupGdt(GdtIdt, Tss);
+ Amd64SetupGdt(GdtIdt, KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT));
/* Copy old Idt and set idtr */
- WinLdrSetupIdt((PVOID)((ULONG64)GdtIdt + 2048)); // HACK!
+ Amd64SetupIdt((PVOID)((ULONG64)GdtIdt + 2048)); // HACK!
/* LDT is unused */
// __lldt(0);
@@ -347,6 +350,59 @@
DPRINTM(DPRINT_WINDOWS, "leave WinLdrSetProcessorContext\n");
}
+WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ ULONG TssSize;
+ ULONG_PTR KernelStack;
+ ULONG_PTR Pcr = 0;
+ ULONG_PTR Tss = 0;
+ ULONG BlockSize, NumPages;
+
+ LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
+ LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
+
+ /* Allocate 2 pages for PCR */
+ Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
+ PcrBasePage = Pcr >> MM_PAGE_SHIFT;
+ if (Pcr == 0)
+ {
+ UiMessageBox("Can't allocate PCR\n");
+ return;
+ }
+ RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE);
+
+ /* Allocate a kernel stack */
+ Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
+
+ /* Allocate TSS */
+ BlockSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
+ Tss = (ULONG_PTR)MmAllocateMemoryWithType(BlockSize, LoaderMemoryData);
+ TssBasePage = Tss >> MM_PAGE_SHIFT;
+
+ /* Allocate space for new GDT + IDT */
+ BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT
limits here?
+ NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
+ *GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE,
LoaderMemoryData);
+
+ if (*GdtIdt == NULL)
+ {
+ UiMessageBox("Can't allocate pages for GDT+IDT!\n");
+ return;
+ }
+
+ /* Zero newly prepared GDT+IDT */
+ RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
+
+ /* Write initial context information */
+ LoaderBlock->KernelStack = (ULONG_PTR)KernelStack;
+ LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
+ LoaderBlock->Prcb = (ULONG_PTR)&Pcr->Prcb;
+ LoaderBlock->Process = (ULONG_PTR)PdrPage->InitialProcess;
+ LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
+
+}
+
+
VOID
MempDump()
{
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/ntsetup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/ntsetup.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/ntsetup.c [iso-8859-1] Wed Aug 31
13:47:25 2011
@@ -33,7 +33,7 @@
#endif
/* FUNCTIONS **************************************************************/
-
+#if 0
// Last step before going virtual
void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID *GdtIdt,
@@ -81,3 +81,4 @@
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
}
+#endif
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/wlmemory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/wlmemory.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/wlmemory.c [iso-8859-1] Wed Aug 31
13:47:25 2011
@@ -13,9 +13,6 @@
#include <ndk/asm.h>
#include <debug.h>
-extern ULONG TotalNLSSize;
-extern ULONG LoaderPagesSpanned;
-
// This is needed because headers define wrong one for ReactOS
#undef KIP0PCRADDRESS
#define KIP0PCRADDRESS 0xffdff000
@@ -40,6 +37,10 @@
PUCHAR KernelPageTablesBuffer;
ULONG PhysicalPageTables;
ULONG KernelPageTables;
+
+ULONG PcrBasePage;
+ULONG TssBasePage;
+PVOID GdtIdt;
/* FUNCTIONS **************************************************************/
@@ -244,7 +245,7 @@
}
BOOLEAN
-WinLdrMapSpecialPages(ULONG PcrBasePage)
+WinLdrMapSpecialPages(void)
{
//VideoDisplayString(L"Hello from VGA, going into the kernel\n");
@@ -270,15 +271,74 @@
return TRUE;
}
+void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ ULONG TssSize;
+ //ULONG TssPages;
+ ULONG_PTR Pcr = 0;
+ ULONG_PTR Tss = 0;
+ ULONG BlockSize, NumPages;
+
+ LoaderBlock->u.I386.CommonDataArea = NULL; // Force No ABIOS support
+ LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
+
+ /* Allocate 2 pages for PCR */
+ Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
+ PcrBasePage = Pcr >> MM_PAGE_SHIFT;
+
+ if (Pcr == 0)
+ {
+ UiMessageBox("Can't allocate PCR\n");
+ return;
+ }
+
+ /* Allocate TSS */
+ TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
+ //TssPages = TssSize / MM_PAGE_SIZE;
+
+ Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData);
+
+ TssBasePage = Tss >> MM_PAGE_SHIFT;
+
+ /* Allocate space for new GDT + IDT */
+ BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT
limits here?
+ NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
+ GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE,
LoaderMemoryData);
+
+ if (GdtIdt == NULL)
+ {
+ UiMessageBox("Can't allocate pages for GDT+IDT!\n");
+ return;
+ }
+
+ /* Zero newly prepared GDT+IDT */
+ RtlZeroMemory(GdtIdt, NumPages << MM_PAGE_SHIFT);
+
+ // Before we start mapping pages, create a block of memory, which will contain
+ // PDE and PTEs
+ if (MempAllocatePageTables() == FALSE)
+ {
+ // FIXME: bugcheck
+ }
+
+ /* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
+ WinLdrMapSpecialPages();
+}
+
VOID
-WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss)
+WinLdrSetProcessorContext(void)
{
GDTIDT GdtDesc, IdtDesc, OldIdt;
PKGDTENTRY pGdt;
PKIDTENTRY pIdt;
USHORT Ldt = 0;
+ ULONG Pcr;
+ ULONG Tss;
//ULONG i;
+
+ Pcr = KIP0PCRADDRESS;
+ Tss = KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT);
DPRINTM(DPRINT_WINDOWS, "GDtIdt %p, Pcr %p, Tss 0x%08X\n",
GdtIdt, Pcr, Tss);
Modified: trunk/reactos/boot/freeldr/freeldr/bootmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/bootm…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] Wed Aug 31 13:47:25 2011
@@ -145,7 +145,7 @@
}
TimeOut = GetTimeOut();
- if (!UiInitialize(TimeOut != 0))
+ if (!UiInitialize(1))
{
UiMessageBoxCritical("Unable to initialize UI.");
return;
@@ -238,7 +238,7 @@
#ifdef FREELDR_REACTOS_SETUP
// WinLdr-style boot
- LoadReactOSSetup2();
+ LoadReactOSSetup();
#elif defined(_M_IX86)
if (_stricmp(BootType, "Windows") == 0)
{
Modified: trunk/reactos/boot/freeldr/freeldr/debug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/debug…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/debug.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/debug.c [iso-8859-1] Wed Aug 31 13:47:25 2011
@@ -32,7 +32,7 @@
#if defined (DEBUG_ALL)
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
- DPRINT_LINUX | DPRINT_HWDETECT;
+ DPRINT_LINUX | DPRINT_HWDETECT | DPRINT_PELOADER;
#elif defined (DEBUG_INIFILE)
ULONG DebugPrintMask = DPRINT_INIFILE;
#elif defined (DEBUG_REACTOS)
Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] Wed Aug 31 13:47:25
2011
@@ -121,8 +121,4 @@
VOID BootMain(LPSTR CmdLine);
VOID RunLoader(VOID);
-/* Special hack for ReactOS setup OS type */
-VOID LoadReactOSSetup(VOID);
-VOID LoadReactOSSetup2(VOID);
-
#endif // defined __FREELDR_H
Modified: trunk/reactos/boot/freeldr/freeldr/include/winldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/winldr.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/winldr.h [iso-8859-1] Wed Aug 31 13:47:25
2011
@@ -20,15 +20,6 @@
#pragma once
-///////////////////////////////////////////////////////////////////////////////////////
-//
-// ReactOS Loading Functions
-//
-///////////////////////////////////////////////////////////////////////////////////////
-VOID LoadAndBootWindows(PCSTR OperatingSystemName,
- PSTR SettingsValue,
- USHORT OperatingSystemVersion);
-
/* Entry-point to kernel */
typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
@@ -39,6 +30,38 @@
// Descriptors
#define NUM_GDT 128 // Must be 128
#define NUM_IDT 0x100 // only 16 are used though. Must be 0x100
+
+/* FIXME: Should be moved to NDK, and respective ACPI header files */
+typedef struct _ACPI_BIOS_DATA
+{
+ PHYSICAL_ADDRESS RSDTAddress;
+ ULONGLONG Count;
+ BIOS_MEMORY_MAP MemoryMap[1]; /* Count of BIOS memory map entries */
+} ACPI_BIOS_DATA, *PACPI_BIOS_DATA;
+
+#include <pshpack1.h>
+typedef struct /* Root System Descriptor Pointer */
+{
+ CHAR signature [8]; /* contains "RSD PTR " */
+ UCHAR checksum; /* to make sum of struct == 0 */
+ CHAR oem_id [6]; /* OEM identification */
+ UCHAR revision; /* Must be 0 for 1.0, 2 for 2.0 */
+ ULONG rsdt_physical_address; /* 32-bit physical address of RSDT */
+ ULONG length; /* XSDT Length in bytes including hdr */
+ ULONGLONG xsdt_physical_address; /* 64-bit physical address of XSDT */
+ UCHAR extended_checksum; /* Checksum of entire table */
+ CHAR reserved [3]; /* reserved field must be 0 */
+} RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
+#include <poppack.h>
+
+///////////////////////////////////////////////////////////////////////////////////////
+//
+// ReactOS Loading Functions
+//
+///////////////////////////////////////////////////////////////////////////////////////
+VOID LoadAndBootWindows(PCSTR OperatingSystemName,
+ PSTR SettingsValue,
+ USHORT OperatingSystemVersion);
// conversion.c
PVOID VaToPa(PVOID Va);
@@ -71,10 +94,7 @@
// wlmemory.c
BOOLEAN
-WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- ULONG PcrBasePage,
- ULONG TssBasePage,
- PVOID GdtIdt);
+WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock);
// wlregistry.c
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
@@ -84,25 +104,67 @@
IN LPCSTR DirectoryPath);
-/* FIXME: Should be moved to NDK, and respective ACPI header files */
-typedef struct _ACPI_BIOS_DATA
-{
- PHYSICAL_ADDRESS RSDTAddress;
- ULONGLONG Count;
- BIOS_MEMORY_MAP MemoryMap[1]; /* Count of BIOS memory map entries */
-} ACPI_BIOS_DATA, *PACPI_BIOS_DATA;
+BOOLEAN
+WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock,
+ IN PCH DllName,
+ OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
-#include <pshpack1.h>
-typedef struct /* Root System Descriptor Pointer */
-{
- CHAR signature [8]; /* contains "RSD PTR " */
- UCHAR checksum; /* to make sum of struct == 0 */
- CHAR oem_id [6]; /* OEM identification */
- UCHAR revision; /* Must be 0 for 1.0, 2 for 2.0 */
- ULONG rsdt_physical_address; /* 32-bit physical address of RSDT */
- ULONG length; /* XSDT Length in bytes including hdr */
- ULONGLONG xsdt_physical_address; /* 64-bit physical address of XSDT */
- UCHAR extended_checksum; /* Checksum of entire table */
- CHAR reserved [3]; /* reserved field must be 0 */
-} RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
-#include <poppack.h>
+BOOLEAN
+WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, LPSTR BootPath);
+
+VOID
+WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
+ LPCSTR Options,
+ LPCSTR SystemPath,
+ LPCSTR BootPath,
+ USHORT VersionToBoot);
+BOOLEAN
+WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN LPCSTR DirectoryPath,
+ IN LPCSTR AnsiFileName,
+ IN LPCSTR OemFileName,
+ IN LPCSTR LanguageFileName);
+BOOLEAN
+WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
+ LPWSTR RegistryPath,
+ LPWSTR ImagePath,
+ LPWSTR ServiceName);
+
+VOID
+WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
+
+VOID
+WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
+
+VOID
+WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
+
+BOOLEAN
+MempAllocatePageTables();
+
+BOOLEAN
+MempSetupPaging(IN ULONG StartPage,
+ IN ULONG NumberOfPages);
+
+VOID
+MempUnmapPage(ULONG Page);
+
+VOID
+MempDump();
+
+VOID
+LoadAndBootWindowsCommon(
+ USHORT OperatingSystemVersion,
+ PLOADER_PARAMETER_BLOCK LoaderBlock,
+ LPCSTR BootOptions,
+ LPCSTR BootPath,
+ BOOLEAN Setup);
+
+VOID LoadReactOSSetup(VOID);
+
+VOID
+WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
+
+VOID
+WinLdrSetProcessorContext(VOID);
+
Modified: trunk/reactos/boot/freeldr/freeldr/windows/setupldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/setupldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/setupldr.c [iso-8859-1] Wed Aug 31 13:47:25
2011
@@ -25,31 +25,14 @@
#include <debug.h>
+void
+WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
+
+VOID
+WinLdrSetProcessorContext(void);
+
// TODO: Move to .h
VOID AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock);
-BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, LPSTR BootPath);
-void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
- PVOID *GdtIdt,
- ULONG *PcrBasePage,
- ULONG *TssBasePage);
-VOID
-WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
- PCHAR Options,
- PCHAR SystemPath,
- PCHAR BootPath,
- USHORT VersionToBoot);
-BOOLEAN
-WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN LPCSTR DirectoryPath,
- IN LPCSTR AnsiFileName,
- IN LPCSTR OemFileName,
- IN LPCSTR LanguageFileName);
-BOOLEAN
-WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
- LPWSTR RegistryPath,
- LPWSTR ImagePath,
- LPWSTR ServiceName);
-
//FIXME: Do a better way to retrieve Arc disk information
extern ULONG reactos_disk_count;
@@ -157,72 +140,59 @@
} while (InfFindNextLine(&InfContext, &InfContext));
}
-VOID LoadReactOSSetup2(VOID)
+VOID LoadReactOSSetup(VOID)
{
- CHAR SystemPath[512], SearchPath[512];
- CHAR FileName[512];
- CHAR BootPath[512];
+ CHAR FileName[512];
+ CHAR BootPath[512];
LPCSTR LoadOptions, BootOptions;
BOOLEAN BootFromFloppy;
-#if DBG
- LPCSTR DbgOptions;
-#endif
- PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL;
- BOOLEAN Status;
ULONG i, ErrorLine;
HINF InfHandle;
INFCONTEXT InfContext;
- PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA;
+ PLOADER_PARAMETER_BLOCK LoaderBlock;
PSETUP_LOADER_BLOCK SetupBlock;
- KERNEL_ENTRY_POINT KiSystemStartup;
- PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL;
- // Mm-related things
- PVOID GdtIdt;
- ULONG PcrBasePage=0;
- ULONG TssBasePage=0;
- LPCSTR SourcePath;
+ LPCSTR SystemPath;
LPCSTR SourcePaths[] =
{
- "", /* Only for floppy boot */
+ "\\", /* Only for floppy boot */
#if defined(_M_IX86)
- "\\I386",
+ "\\I386\\",
#elif defined(_M_MPPC)
- "\\PPC",
+ "\\PPC\\",
#elif defined(_M_MRX000)
- "\\MIPS",
+ "\\MIPS\\",
#endif
- "\\reactos",
+ "\\reactos\\",
NULL
};
/* Get boot path */
- MachDiskGetBootPath(SystemPath, sizeof(SystemPath));
+ MachDiskGetBootPath(BootPath, sizeof(BootPath));
/* And check if we booted from floppy */
- BootFromFloppy = strstr(SystemPath, "fdisk") != NULL;
+ BootFromFloppy = strstr(BootPath, "fdisk") != NULL;
/* Open 'txtsetup.sif' from any of source paths */
for (i = BootFromFloppy ? 0 : 1; ; i++)
{
- SourcePath = SourcePaths[i];
- if (!SourcePath)
+ SystemPath = SourcePaths[i];
+ if (!SystemPath)
{
printf("Failed to open 'txtsetup.sif'\n");
return;
}
- sprintf(FileName, "%s\\txtsetup.sif", SourcePath);
+ sprintf(FileName, "%stxtsetup.sif", SystemPath);
if (InfOpenFile (&InfHandle, FileName, &ErrorLine))
{
- sprintf(BootPath, "%s%s\\", SystemPath, SourcePath);
+ strcat(BootPath, SystemPath);
break;
}
}
+ DPRINTM(DPRINT_WINDOWS,"BootPath: '%s', SystemPath:
'%s'\n", BootPath, SystemPath);
+
/* Get Load options - debug and non-debug */
- if (!InfFindFirstLine(InfHandle,
- "SetupData",
- "OsLoadOptions",
- &InfContext))
+ if (!InfFindFirstLine(InfHandle, "SetupData", "OsLoadOptions",
&InfContext))
{
printf("Failed to find 'SetupData/OsLoadOptions'\n");
return;
@@ -238,31 +208,17 @@
#if DBG
/* Get debug load options and use them */
- if (InfFindFirstLine(InfHandle,
- "SetupData",
- "DbgOsLoadOptions",
- &InfContext))
- {
- if (!InfGetDataField(&InfContext, 1, &DbgOptions))
- DbgOptions = "";
- else
- BootOptions = DbgOptions;
+ if (InfFindFirstLine(InfHandle, "SetupData", "DbgOsLoadOptions",
&InfContext))
+ {
+ if (InfGetDataField(&InfContext, 1, &LoadOptions))
+ BootOptions = LoadOptions;
}
#endif
DPRINTM(DPRINT_WINDOWS,"BootOptions: '%s'\n", BootOptions);
- SetupUiInitialize();
+ //SetupUiInitialize();
UiDrawStatusText("");
- UiDrawStatusText("Detecting Hardware...");
-
- /* Let user know we started loading */
- UiDrawStatusText("Loading...");
-
- /* Construct the system path */
- sprintf(SystemPath, "%s\\", SourcePath);
-
- DPRINTM(DPRINT_WINDOWS,"BootPath: '%s', SystemPath:
'%s'\n", BootPath, SystemPath);
/* Allocate and minimalistic-initialize LPB */
AllocateAndInitLPB(&LoaderBlock);
@@ -275,99 +231,18 @@
/* Set textmode setup flag */
SetupBlock->Flags = SETUPLDR_TEXT_MODE;
- /* Detect hardware */
- UseRealHeap = TRUE;
- LoaderBlock->ConfigurationRoot = MachHwDetect();
-
- strcpy(FileName, "\\ArcName\\");
-
- /* Load kernel */
- strcpy(FileName+strlen("\\ArcName\\"), BootPath);
- strcat(FileName, "SYSTEM32\\NTOSKRNL.EXE");
- Status = WinLdrLoadImage(FileName+strlen("\\ArcName\\"), LoaderSystemCode,
&NtosBase);
- DPRINTM(DPRINT_WINDOWS, "Ntos loaded with status %d at %p\n", Status,
NtosBase);
- Status = WinLdrAllocateDataTableEntry(LoaderBlock, "ntoskrnl.exe",
- FileName, NtosBase, &KernelDTE);
- DPRINTM(DPRINT_WINDOWS, "Ntos Data Table Entry allocated with status %d at
%p\n", Status, KernelDTE);
-
- /* Load HAL */
- strcpy(FileName+strlen("\\ArcName\\"), BootPath);
- strcat(FileName, "SYSTEM32\\HAL.DLL");
- Status = WinLdrLoadImage(FileName+strlen("\\ArcName\\"), LoaderHalCode,
&HalBase);
- DPRINTM(DPRINT_WINDOWS, "HAL loaded with status %d at %p\n", Status,
HalBase);
- Status = WinLdrAllocateDataTableEntry(LoaderBlock, "hal.dll",
- FileName, HalBase, &HalDTE);
- DPRINTM(DPRINT_WINDOWS, "HAL Data Table Entry allocated with status %d at
%p\n", Status, HalDTE);
-
- /* Load kernel-debugger support dll */
- strcpy(FileName+strlen("\\ArcName\\"), BootPath);
- strcat(FileName, "SYSTEM32\\KDCOM.DLL");
- Status = WinLdrLoadImage(FileName+strlen("\\ArcName\\"), LoaderBootDriver,
&KdComBase);
- DPRINTM(DPRINT_WINDOWS, "KdCom loaded with status %d at %p\n", Status,
KdComBase);
- Status = WinLdrAllocateDataTableEntry(LoaderBlock, "kdcom.dll",
- FileName, KdComBase, &KdComDTE);
- DPRINTM(DPRINT_WINDOWS, "KdCom Data Table Entry allocated with status %d at
%p\n", Status, HalDTE);
-
- /* Load all referenced DLLs for kernel, HAL and kdcom.dll */
- strcpy(SearchPath, BootPath);
- strcat(SearchPath, "system32\\");
- Status = WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, KernelDTE);
- Status &= WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, HalDTE);
- if (KdComDTE)
- Status &= WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath,
KdComDTE);
-
- if (!Status)
- {
- UiMessageBox("Error loading imported dll.");
- return;
- }
-
/* Load NLS data, they are in system32 */
- SetupLdrLoadNlsData(LoaderBlock, InfHandle, SearchPath);
+ strcpy(FileName, BootPath);
+ strcat(FileName, "system32\\");
+ SetupLdrLoadNlsData(LoaderBlock, InfHandle, FileName);
/* Get a list of boot drivers */
SetupLdrScanBootDrivers(LoaderBlock, InfHandle, BootPath);
- /* Load boot drivers */
- Status = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
- DPRINTM(DPRINT_WINDOWS, "Boot drivers loaded with status %d\n", Status);
-
- /* Alloc PCR, TSS, do magic things with the GDT/IDT */
- WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage);
-
- /* Initialize Phase 1 - no drivers loading anymore */
- WinLdrInitializePhase1(LoaderBlock, (PCHAR)BootOptions, SystemPath, BootPath,
_WIN32_WINNT_WS03);
-
- /* Save entry-point pointer and Loader block VAs */
- KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint;
- LoaderBlockVA = PaToVa(LoaderBlock);
-
- /* "Stop all motors", change videomode */
- MachPrepareForReactOS(TRUE);
-
- /* Debugging... */
- //DumpMemoryAllocMap();
-
- /* Turn on paging mode of CPU*/
- WinLdrTurnOnPaging(LoaderBlock, PcrBasePage, TssBasePage, GdtIdt);
-
- /* Save final value of LoaderPagesSpanned */
- LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
-
- DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p,
LoaderBlockVA %p!\n",
- KiSystemStartup, LoaderBlockVA);
-
- //WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
- //WinLdrpDumpBootDriver(LoaderBlockVA);
- //WinLdrpDumpArcDisks(LoaderBlockVA);
-
- /*asm(".intel_syntax noprefix\n");
- asm("test1:\n");
- asm("jmp test1\n");
- asm(".att_syntax\n");*/
-
- /* Pass control */
- (*KiSystemStartup)(LoaderBlockVA);
-
- return;
+
+ LoadAndBootWindowsCommon(_WIN32_WINNT_WS03,
+ LoaderBlock,
+ BootOptions,
+ BootPath,
+ 1);
}
Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] Wed Aug 31 13:47:25
2011
@@ -24,12 +24,6 @@
#include <ndk/ldrtypes.h>
#include <debug.h>
-// TODO: Move to .h
-void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
- PVOID *GdtIdt,
- ULONG *PcrBasePage,
- ULONG *TssBasePage);
-
//FIXME: Do a better way to retrieve Arc disk information
extern ULONG reactos_disk_count;
extern ARC_DISK_SIGNATURE reactos_arc_disk_info[];
@@ -43,17 +37,8 @@
extern BOOLEAN WinLdrTerminalConnected;
extern void WinLdrSetupEms(IN PCHAR BootOptions);
-BOOLEAN
-WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock,
- IN PCH DllName,
- OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
-
// debug stuff
VOID DumpMemoryAllocMap(VOID);
-VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
-VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
-VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
-
// Init "phase 0"
VOID
@@ -85,9 +70,9 @@
// Init "phase 1"
VOID
WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
- PCHAR Options,
- PCHAR SystemRoot,
- PCHAR BootPath,
+ LPCSTR Options,
+ LPCSTR SystemRoot,
+ LPCSTR BootPath,
USHORT VersionToBoot)
{
/* Examples of correct options and paths */
@@ -435,6 +420,38 @@
return _WIN32_WINNT_WS03;
}
+PVOID
+LoadModule(
+ PLOADER_PARAMETER_BLOCK LoaderBlock,
+ PCCH Path,
+ PCCH File,
+ PLDR_DATA_TABLE_ENTRY *Dte,
+ ULONG Percentage)
+{
+ CHAR FullFileName[MAX_PATH];
+ CHAR ProgressString[256];
+ NTSTATUS Status;
+ PVOID BaseAdress;
+
+ UiDrawBackdrop();
+ sprintf(ProgressString, "Loading %s...", File);
+ UiDrawProgressBarCenter(Percentage, 100, ProgressString);
+
+ strcpy(FullFileName, Path);
+ strcat(FullFileName, "SYSTEM32\\");
+ strcat(FullFileName, File);
+
+ Status = WinLdrLoadImage(FullFileName, LoaderSystemCode, &BaseAdress);
+ DPRINTM(DPRINT_WINDOWS, "%s loaded with status %d at %p\n",
+ File, Status, BaseAdress);
+
+ strcpy(FullFileName, "WINDOWS\\SYSTEM32\\");
+ strcat(FullFileName, File);
+ WinLdrAllocateDataTableEntry(LoaderBlock, File,
+ FullFileName, BaseAdress, Dte);
+
+ return BaseAdress;
+}
VOID
LoadAndBootWindows(PCSTR OperatingSystemName,
@@ -442,51 +459,39 @@
USHORT OperatingSystemVersion)
{
BOOLEAN HasSection;
- char FullPath[MAX_PATH], SystemRoot[MAX_PATH], BootPath[MAX_PATH];
+ char BootPath[MAX_PATH];
CHAR FileName[MAX_PATH];
CHAR BootOptions[256];
PCHAR File;
- PCHAR PathSeparator;
- PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL;
BOOLEAN Status;
ULONG_PTR SectionId;
- PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA;
- KERNEL_ENTRY_POINT KiSystemStartup;
- PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL;
- // Mm-related things
- PVOID GdtIdt;
- ULONG PcrBasePage=0;
- ULONG TssBasePage=0;
- // Progress bar
- CHAR ProgressString[256];
+ PLOADER_PARAMETER_BLOCK LoaderBlock;
// Open the operating system section
// specified in the .ini file
HasSection = IniOpenSection(OperatingSystemName, &SectionId);
UiDrawBackdrop();
- UiDrawStatusText("Detecting Hardware...");
- sprintf(ProgressString, "Loading NT...");
- UiDrawProgressBarCenter(1, 100, ProgressString);
+ UiDrawProgressBarCenter(1, 100, "Loading NT...");
/* Read the system path is set in the .ini file */
- if (!HasSection || !IniReadSettingByName(SectionId, "SystemPath", FullPath,
sizeof(FullPath)))
- {
- strcpy(FullPath, OperatingSystemName);
+ if (!HasSection ||
+ !IniReadSettingByName(SectionId, "SystemPath", BootPath,
sizeof(BootPath)))
+ {
+ strcpy(BootPath, OperatingSystemName);
}
/* Special case for LiveCD */
- if (!_strnicmp(FullPath, "LiveCD", strlen("LiveCD")))
- {
- strcpy(BootPath, FullPath + strlen("LiveCD"));
- MachDiskGetBootPath(FullPath, sizeof(FullPath));
- strcat(FullPath, BootPath);
- }
-
- /* Convert FullPath to SystemRoot */
- PathSeparator = strstr(FullPath, "\\");
- strcpy(SystemRoot, PathSeparator);
- strcat(SystemRoot, "\\");
+ if (!_strnicmp(BootPath, "LiveCD", strlen("LiveCD")))
+ {
+ strcpy(FileName, BootPath + strlen("LiveCD"));
+ MachDiskGetBootPath(BootPath, sizeof(BootPath));
+ strcat(BootPath, FileName);
+ }
+
+ /* append a backslash */
+ if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\')
+ strcat(BootPath, "\\");
/* Read booting options */
if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions,
sizeof(BootOptions)))
@@ -504,36 +509,22 @@
/* Append boot-time options */
AppendBootTimeOptions(BootOptions);
- //
- // Check if a ramdisk file was given
- //
+ /* Check if a ramdisk file was given */
File = strstr(BootOptions, "/RDPATH=");
if (File)
{
- //
- // Copy the file name and everything else after it
- //
+ /* Copy the file name and everything else after it */
strcpy(FileName, File + 8);
- //
- // Null-terminate
- //
+ /* Null-terminate */
*strstr(FileName, " ") = ANSI_NULL;
- //
- // Load the ramdisk
- //
+ /* Load the ramdisk */
RamDiskLoadVirtualFile(FileName);
}
/* Let user know we started loading */
//UiDrawStatusText("Loading...");
-
- /* append a backslash */
- strcpy(BootPath, FullPath);
- if ((strlen(BootPath)==0) ||
- BootPath[strlen(BootPath)] != '\\')
- strcat(BootPath, "\\");
DPRINTM(DPRINT_WINDOWS,"BootPath: '%s'\n", BootPath);
@@ -544,86 +535,82 @@
/* Setup redirection support */
WinLdrSetupEms(BootOptions);
#endif
+
+ /* Load Hive */
+ UiDrawBackdrop();
+ UiDrawProgressBarCenter(15, 100, "Loading system hive...");
+ Status = WinLdrInitSystemHive(LoaderBlock, BootPath);
+ DPRINTM(DPRINT_WINDOWS, "SYSTEM hive loaded with status %d\n", Status);
+
+ /* Load NLS data, OEM font, and prepare boot drivers list */
+ Status = WinLdrScanSystemHive(LoaderBlock, BootPath);
+ DPRINTM(DPRINT_WINDOWS, "SYSTEM hive scanned with status %d\n", Status);
+
+
+ LoadAndBootWindowsCommon(OperatingSystemVersion,
+ LoaderBlock,
+ BootOptions,
+ BootPath,
+ 0);
+}
+
+VOID
+LoadAndBootWindowsCommon(
+ USHORT OperatingSystemVersion,
+ PLOADER_PARAMETER_BLOCK LoaderBlock,
+ LPCSTR BootOptions,
+ LPCSTR BootPath,
+ BOOLEAN Setup)
+{
+ PLOADER_PARAMETER_BLOCK LoaderBlockVA;
+ BOOLEAN Status;
+ CHAR FileName[MAX_PATH];
+ PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL;
+ PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL;
+ KERNEL_ENTRY_POINT KiSystemStartup;
+ LPCSTR SystemRoot;
+
+ /* Convert BootPath to SystemRoot */
+ SystemRoot = strstr(BootPath, "\\");
+
/* Detect hardware */
UseRealHeap = TRUE;
LoaderBlock->ConfigurationRoot = MachHwDetect();
- sprintf(ProgressString, "Loading system hive...");
- UiDrawBackdrop();
- UiDrawProgressBarCenter(15, 100, ProgressString);
-
- /* Load Hive */
- Status = WinLdrInitSystemHive(LoaderBlock, BootPath);
- DPRINTM(DPRINT_WINDOWS, "SYSTEM hive loaded with status %d\n", Status);
-
if (OperatingSystemVersion == 0)
OperatingSystemVersion = WinLdrDetectVersion();
/* Load kernel */
- strcpy(FileName, BootPath);
- strcat(FileName, "SYSTEM32\\NTOSKRNL.EXE");
- sprintf(ProgressString, "Loading %s...", strchr(FileName, '\\') + 1);
- UiDrawBackdrop();
- UiDrawProgressBarCenter(30, 100, ProgressString);
- Status = WinLdrLoadImage(FileName, LoaderSystemCode, &NtosBase);
- DPRINTM(DPRINT_WINDOWS, "Ntos loaded with status %d at %p\n", Status,
NtosBase);
+ NtosBase = LoadModule(LoaderBlock, BootPath, "NTOSKRNL.EXE", &KernelDTE,
30);
/* Load HAL */
- strcpy(FileName, BootPath);
- strcat(FileName, "SYSTEM32\\HAL.DLL");
- sprintf(ProgressString, "Loading %s...", strchr(FileName, '\\') + 1);
- UiDrawBackdrop();
- UiDrawProgressBarCenter(45, 100, ProgressString);
- Status = WinLdrLoadImage(FileName, LoaderHalCode, &HalBase);
- DPRINTM(DPRINT_WINDOWS, "HAL loaded with status %d at %p\n", Status,
HalBase);
+ HalBase = LoadModule(LoaderBlock, BootPath, "HAL.DLL", &HalDTE, 45);
/* Load kernel-debugger support dll */
if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
{
- strcpy(FileName, BootPath);
- strcat(FileName, "SYSTEM32\\KDCOM.DLL");
- sprintf(ProgressString, "Loading %s...", strchr(FileName, '\\') +
1);
- UiDrawBackdrop();
- UiDrawProgressBarCenter(60, 100, ProgressString);
- Status = WinLdrLoadImage(FileName, LoaderBootDriver, &KdComBase);
- DPRINTM(DPRINT_WINDOWS, "KdCom loaded with status %d at %p\n", Status,
KdComBase);
- }
-
- /* Allocate data table entries for above-loaded modules */
- WinLdrAllocateDataTableEntry(LoaderBlock, "ntoskrnl.exe",
- "WINDOWS\\SYSTEM32\\NTOSKRNL.EXE", NtosBase, &KernelDTE);
- WinLdrAllocateDataTableEntry(LoaderBlock, "hal.dll",
- "WINDOWS\\SYSTEM32\\HAL.DLL", HalBase, &HalDTE);
- if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
- {
- WinLdrAllocateDataTableEntry(LoaderBlock, "kdcom.dll",
- "WINDOWS\\SYSTEM32\\KDCOM.DLL", KdComBase, &KdComDTE);
+ KdComBase = LoadModule(LoaderBlock, BootPath, "KDCOM.DLL", &KdComDTE,
60);
}
/* Load all referenced DLLs for kernel, HAL and kdcom.dll */
strcpy(FileName, BootPath);
- strcat(FileName, "SYSTEM32\\");
- WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KernelDTE);
- WinLdrScanImportDescriptorTable(LoaderBlock, FileName, HalDTE);
+ strcat(FileName, "system32\\");
+ Status = WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KernelDTE);
+ Status &= WinLdrScanImportDescriptorTable(LoaderBlock, FileName, HalDTE);
if (KdComDTE)
- WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KdComDTE);
-
- sprintf(ProgressString, "Loading NLS and OEM fonts...");
+ Status &= WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KdComDTE);
+
+ if (!Status)
+ {
+ UiMessageBox("Error loading imported dll.");
+ return;
+ }
+
+ /* Load boot drivers */
UiDrawBackdrop();
- UiDrawProgressBarCenter(80, 100, ProgressString);
- /* Load NLS data, OEM font, and prepare boot drivers list */
- Status = WinLdrScanSystemHive(LoaderBlock, BootPath);
- DPRINTM(DPRINT_WINDOWS, "SYSTEM hive scanned with status %d\n", Status);
-
- /* Load boot drivers */
- sprintf(ProgressString, "Loading boot drivers...");
- UiDrawBackdrop();
- UiDrawProgressBarCenter(100, 100, ProgressString);
- Status = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
+ UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
+ Status = WinLdrLoadBootDrivers(LoaderBlock, (PCHAR)BootPath);
DPRINTM(DPRINT_WINDOWS, "Boot drivers loaded with status %d\n", Status);
-
- /* Alloc PCR, TSS, do magic things with the GDT/IDT */
- WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage);
/* Initialize Phase 1 - no drivers loading anymore */
WinLdrInitializePhase1(LoaderBlock, BootOptions, SystemRoot, BootPath,
OperatingSystemVersion);
@@ -633,19 +620,22 @@
LoaderBlockVA = PaToVa(LoaderBlock);
/* "Stop all motors", change videomode */
- if (OperatingSystemVersion < _WIN32_WINNT_WIN2K)
- MachPrepareForReactOS(TRUE);
- else
- MachPrepareForReactOS(FALSE);
+ MachPrepareForReactOS(Setup);
/* Debugging... */
//DumpMemoryAllocMap();
- /* Turn on paging mode of CPU*/
- WinLdrTurnOnPaging(LoaderBlock, PcrBasePage, TssBasePage, GdtIdt);
+ /* Do the machine specific initialization */
+ WinLdrSetupMachineDependent(LoaderBlock);
+
+ /* Turn on paging mode of CPU */
+ WinLdrSetupMemoryLayout(LoaderBlock);
/* Save final value of LoaderPagesSpanned */
- LoaderBlockVA->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
+ LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
+
+ /* Set processor context */
+ WinLdrSetProcessorContext();
DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA
%p!\n",
KiSystemStartup, LoaderBlockVA);
@@ -663,8 +653,6 @@
/* Pass control */
(*KiSystemStartup)(LoaderBlockVA);
-
- return;
}
VOID
Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] Wed Aug 31 13:47:25
2011
@@ -42,40 +42,10 @@
"BBTMemory " // == Bad
};
-VOID
-WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-
-VOID
-MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- ULONG BasePage,
- ULONG PageCount,
- ULONG Type);
-VOID
+static VOID
WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor);
-VOID
-WinLdrRemoveDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR Descriptor);
-
-VOID
-WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG_PTR Pcr, IN ULONG_PTR Tss);
-
-BOOLEAN
-MempAllocatePageTables();
-
-BOOLEAN
-MempSetupPaging(IN ULONG StartPage,
- IN ULONG NumberOfPages);
-
-BOOLEAN
-WinLdrMapSpecialPages(ULONG PcrBasePage);
-
-VOID
-MempUnmapPage(ULONG Page);
-
-VOID
-MempDump();
/* GLOBALS ***************************************************************/
@@ -188,7 +158,7 @@
return;
}
-
+
//
// Add descriptor
//
@@ -197,7 +167,7 @@
//
// Map it (don't map low 1Mb because it was already contiguously
- // mapped in WinLdrTurnOnPaging)
+ // mapped in WinLdrPrepareMemoryLayout)
//
if (BasePage >= 0x100)
{
@@ -215,10 +185,7 @@
#endif
BOOLEAN
-WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- ULONG PcrBasePage,
- ULONG TssBasePage,
- PVOID GdtIdt)
+WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG i, PagesCount, MemoryMapSizeInPages;
ULONG LastPageIndex, LastPageType, MemoryMapStartPage;
@@ -249,11 +216,6 @@
// StartPde C0300F70, EndPde C0300FF8, NumberOfPages C13, NextPhysPage 3AD
//
- // Before we start mapping pages, create a block of memory, which will contain
- // PDE and PTEs
- if (MempAllocatePageTables() == FALSE)
- return FALSE;
-
// Allocate memory for memory allocation descriptors
Mad = MmHeapAlloc(sizeof(MEMORY_ALLOCATION_DESCRIPTOR) * 1024);
@@ -350,15 +312,10 @@
return;
}*/
- /* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
- WinLdrMapSpecialPages(PcrBasePage);
-
- //Tss = (PKTSS)(KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT));
-
// Unmap what is not needed from kernel page table
MempDisablePages();
- // Fill the memory descriptor list and
+ // Fill the memory descriptor list and
//PrepareMemoryDescriptorList();
DPRINTM(DPRINT_WINDOWS, "Memory Descriptor List prepared, printing PDE\n");
List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
@@ -367,9 +324,6 @@
MempDump();
#endif
- // Set processor context
- WinLdrSetProcessorContext(GdtIdt, KIP0PCRADDRESS, KSEG0_BASE | (TssBasePage <<
MM_PAGE_SHIFT));
-
// Zero KI_USER_SHARED_DATA page
memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE);
@@ -378,7 +332,7 @@
// Two special things this func does: it sorts descriptors,
// and it merges free ones
-VOID
+static VOID
WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor)
{