[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

svn path=/trunk/; revision=53510
This commit is contained in:
Timo Kreuzer 2011-08-31 13:47:25 +00:00
parent b93fdf2a65
commit 0c902fc496
11 changed files with 398 additions and 401 deletions

View file

@ -13,15 +13,20 @@ TitleBoxTextColor=White
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

View file

@ -22,6 +22,9 @@
PHARDWARE_PTE PxeBase;
//PHARDWARE_PTE HalPageTable;
PVOID GdtIdt;
ULONG PcrBasePage;
ULONG TssBasePage;
/* FUNCTIONS **************************************************************/
@ -43,8 +46,8 @@ MempAllocatePageTables()
/* 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 @@ MempIsPageMapped(PVOID VirtualAddress)
{
PHARDWARE_PTE PpeBase, PdeBase, PteBase;
ULONG Index;
Index = VAtoPXI(VirtualAddress);
if (!PxeBase[Index].Valid)
return FALSE;
@ -161,7 +164,7 @@ BOOLEAN
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 @@ WinLdrMapSpecialPages(ULONG PcrBasePage)
}
VOID
WinLdrSetupGdt(PVOID GdtBase, ULONG64 TssBase)
Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
{
PKGDTENTRY64 Entry;
KDESCRIPTOR GdtDesc;
@ -295,7 +298,7 @@ WinLdrSetupGdt(PVOID GdtBase, ULONG64 TssBase)
}
VOID
WinLdrSetupIdt(PVOID IdtBase)
Amd64SetupIdt(PVOID IdtBase)
{
KDESCRIPTOR IdtDesc, OldIdt;
@ -316,9 +319,9 @@ WinLdrSetupIdt(PVOID IdtBase)
}
VOID
WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG64 Pcr, IN ULONG64 Tss)
WinLdrSetProcessorContext(void)
{
DPRINTM(DPRINT_WINDOWS, "WinLdrSetProcessorContext %p\n", Pcr);
DPRINTM(DPRINT_WINDOWS, "WinLdrSetProcessorContext\n");
/* Disable Interrupts */
_disable();
@ -333,10 +336,10 @@ WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG64 Pcr, IN ULONG64 Tss)
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 @@ WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG64 Pcr, IN ULONG64 Tss)
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()
{

View file

@ -33,7 +33,7 @@ extern ULONG_PTR i386AlignmentCheck; // exc 17
#endif
/* FUNCTIONS **************************************************************/
#if 0
// Last step before going virtual
void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID *GdtIdt,
@ -81,3 +81,4 @@ void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
}
#endif

View file

@ -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
@ -41,6 +38,10 @@ PUCHAR KernelPageTablesBuffer;
ULONG PhysicalPageTables;
ULONG KernelPageTables;
ULONG PcrBasePage;
ULONG TssBasePage;
PVOID GdtIdt;
/* FUNCTIONS **************************************************************/
BOOLEAN
@ -244,7 +245,7 @@ WinLdrpMapApic()
}
BOOLEAN
WinLdrMapSpecialPages(ULONG PcrBasePage)
WinLdrMapSpecialPages(void)
{
//VideoDisplayString(L"Hello from VGA, going into the kernel\n");
@ -270,16 +271,75 @@ WinLdrMapSpecialPages(ULONG PcrBasePage)
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);

View file

@ -145,7 +145,7 @@ VOID RunLoader(VOID)
}
TimeOut = GetTimeOut();
if (!UiInitialize(TimeOut != 0))
if (!UiInitialize(1))
{
UiMessageBoxCritical("Unable to initialize UI.");
return;
@ -238,7 +238,7 @@ VOID RunLoader(VOID)
#ifdef FREELDR_REACTOS_SETUP
// WinLdr-style boot
LoadReactOSSetup2();
LoadReactOSSetup();
#elif defined(_M_IX86)
if (_stricmp(BootType, "Windows") == 0)
{

View file

@ -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)

View file

@ -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

View file

@ -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);
@ -40,6 +31,38 @@ typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
#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);
PVOID PaToVa(PVOID Pa);
@ -71,10 +94,7 @@ PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
// 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 @@ BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
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);
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);
#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>

View file

@ -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 @@ SetupLdrScanBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, HINF InfHandle, LPC
} 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 @@ VOID LoadReactOSSetup2(VOID)
#if DBG
/* Get debug load options and use them */
if (InfFindFirstLine(InfHandle,
"SetupData",
"DbgOsLoadOptions",
&InfContext))
if (InfFindFirstLine(InfHandle, "SetupData", "DbgOsLoadOptions", &InfContext))
{
if (!InfGetDataField(&InfContext, 1, &DbgOptions))
DbgOptions = "";
else
BootOptions = DbgOptions;
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 @@ VOID LoadReactOSSetup2(VOID)
/* 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);
}

View file

@ -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 HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
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 @@ AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
// 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 @@ WinLdrDetectVersion()
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 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
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)))
if (!HasSection ||
!IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath)))
{
strcpy(FullPath, OperatingSystemName);
strcpy(BootPath, OperatingSystemName);
}
/* Special case for LiveCD */
if (!_strnicmp(FullPath, "LiveCD", strlen("LiveCD")))
if (!_strnicmp(BootPath, "LiveCD", strlen("LiveCD")))
{
strcpy(BootPath, FullPath + strlen("LiveCD"));
MachDiskGetBootPath(FullPath, sizeof(FullPath));
strcat(FullPath, BootPath);
strcpy(FileName, BootPath + strlen("LiveCD"));
MachDiskGetBootPath(BootPath, sizeof(BootPath));
strcat(BootPath, FileName);
}
/* Convert FullPath to SystemRoot */
PathSeparator = strstr(FullPath, "\\");
strcpy(SystemRoot, PathSeparator);
strcat(SystemRoot, "\\");
/* append a backslash */
if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\')
strcat(BootPath, "\\");
/* Read booting options */
if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions)))
@ -504,37 +509,23 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
/* 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);
/* Allocate and minimalistic-initialize LPB */
@ -544,87 +535,83 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
/* 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);
Status &= WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KdComDTE);
sprintf(ProgressString, "Loading NLS and OEM fonts...");
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);
if (!Status)
{
UiMessageBox("Error loading imported dll.");
return;
}
/* 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 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
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 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
/* Pass control */
(*KiSystemStartup)(LoaderBlockVA);
return;
}
VOID

View file

@ -42,40 +42,10 @@ PCHAR MemTypeDesc[] = {
"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 @@ MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
return;
}
//
// Add descriptor
//
@ -197,7 +167,7 @@ MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
//
// 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 @@ MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
#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 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
// 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 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
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 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
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 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
// 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)
{