Files
reactos/reactos/setupldr.c
Aleksey Bragin 9177998d8e Commit my initial work on getting Windows NT booting.
Right now, if stars on the sky get in proper places and you are lucky, it will load Windows NT 4.0 to GUI (it will be unusable due to absence of mouse/keyboard though).

Here are log messages from my local tree which I used to develop this initial version (just for reference):
Revision: 8
Author: alekseyb
Date: 22:56:15, 24 íîÿáðÿ 2006 ã.
Message:
- Initialize "ValidBootPartition" field of ArcDiskInfo (without it Windows thinks the partition is not good)
- Zero ArcDiskInfo before usage
- Load filesystem driver (fastfat.sys for now)

Windows NT4 now boots, but of course there are no mouse/keyboard.
----
Modified : /freeldr/arch/i386/hardware.c
Modified : /freeldr/windows/winldr.c
Modified : /freeldr/windows/wlregistry.c


Revision: 7
Author: alekseyb
Date: 15:37:37, 24 íîÿáðÿ 2006 ã.
Message:
- Fix Disk Peripheral entries to really be of DiskPeripheral type and PeripheralClass
- Add to PcHwDetect() proper Child/Sibling-isation (depending on what has been found)
- Fixed PCI information recognizing (changed structure + properly filling HardwareMechanism field)
- Creating of actual configuration descriptor for PCI bus added
- Fix conversion of hardware configuration list to virtual addressing, also adding better debug prints
- Remove annoying DbgPrints from PE loader
- Remove memory map dumping
----
Modified : /freeldr/arch/i386/hardware.c
Modified : /freeldr/arch/i386/hwpci.c
Modified : /freeldr/include/arch/i386/hardware.h
Modified : /freeldr/windows/conversion.c
Modified : /freeldr/windows/peloader.c
Modified : /freeldr/windows/winldr.c


Revision: 6
Author: alekseyb
Date: 1:42:20, 23 íîÿáðÿ 2006 ã.
Message:
- Add ISA bus configuration entry, Disk Controller and Peripherals
- Comment about number of GDT entries
- Changed order of boot drivers - now they should correspond to what NT awaits

The compatibility with ReactOS booting is broken at this point, because hardware detection results are being placed into configuration list and not in-memory registry.
----
Modified : /freeldr/arch/i386/hardware.c
Modified : /freeldr/include/winldr.h
Modified : /freeldr/windows/wlregistry.c


Revision: 5
Author: alekseyb
Date: 23:37:40, 18 íîÿáðÿ 2006 ã.
Message:
- Modify number of GDT descriptors, since NT Kernel assumes space for 128 GDT descriptors, and if it is less - it overwrites IDT entries following them, which lead to a major fsckup, and how kernel booted to some stage is a mystery.
- Slightly modified comments, removed unnecessary TODO

WinDBG connects now and seems to work (don't forget to disable debug output of freeldr, otherwise WinDBG can't connect).
----
Modified : /freeldr/include/winldr.h
Modified : /freeldr/windows/winldr.c


Revision: 4
Author: alekseyb
Date: 18:25:49, 16 íîÿáðÿ 2006 ã.
Message:
- Fix RegistryPath in boot drivers (appended service name)
- Convert RegistryPath.Buffer and pointer to DTE to VirtualAddresses (fixes KMODE_EXCEPTION)
----
Modified : /freeldr/windows/winldr.c
Modified : /freeldr/windows/wlregistry.c


Revision: 3
Author: alekseyb
Date: 17:10:21, 15 íîÿáðÿ 2006 ã.
Message:
- Implemented storing configuration data of disks.
- Moved hardware detection to a later stage so that it doesn't write to an unitialized pointer and actually stores the data in LoaderBlock->ConfigurationRoot.

InitializeHWConfig() function should go away soon.
----
Modified : /freeldr/arch/i386/hardware.c
Modified : /freeldr/windows/conversion.c
Modified : /freeldr/windows/winldr.c


Revision: 2
Author: alekseyb
Date: 16:54:12, 13 íîÿáðÿ 2006 ã.
Message:
Import of what has been already done so far by me (WinNT 4.0 says INACCESSIBLE_BOOT_DEVICE). Just started working on Configuration List.
----
Modified : /freeldr/arch/i386/hardware.c
Modified : /freeldr/arch/i386/i386idt.S
Modified : /freeldr/arch/i386/i386trap.S
Modified : /freeldr/arch/i386/xboxhw.c
Modified : /freeldr/debug.c
Modified : /freeldr/freeldr_arch.rbuild
Modified : /freeldr/freeldr_base.rbuild
Modified : /freeldr/freeldr_base64k.rbuild
Modified : /freeldr/freeldr_main.rbuild
Modified : /freeldr/include/arch/i386/machpc.h
Modified : /freeldr/include/arch/i386/machxbox.h
Modified : /freeldr/include/machine.h
Modified : /freeldr/include/mm.h
Modified : /freeldr/include/winldr.h
Modified : /freeldr/linuxboot.c
Modified : /freeldr/machine.c
Modified : /freeldr/mm/meminit.c
Modified : /freeldr/mm/mm.c
Modified : /freeldr/reactos/binhive.c
Modified : /freeldr/reactos/reactos.c
Modified : /freeldr/reactos/setupldr.c
Modified : /freeldr/windows/peloader.c
Modified : /freeldr/windows/winldr.c
Modified : /freeldr/windows/wlmemory.c
Modified : /freeldr/windows/wlregistry.c


Revision: 1
Author: alekseyb
Date: 16:45:55, 13 íîÿáðÿ 2006 ã.
Message:
FreeLdr import from ReactOS trunk r24725
----
Added : /freeldr
Added : /freeldr/CHANGELOG
Added : /freeldr/arch
Added : /freeldr/arch/i386
Added : /freeldr/arch/i386/_alloca.S
Added : /freeldr/arch/i386/arch.S
Added : /freeldr/arch/i386/archmach.c
Added : /freeldr/arch/i386/boot.S
Added : /freeldr/arch/i386/drvmap.S
Added : /freeldr/arch/i386/fathelp.asm
Added : /freeldr/arch/i386/hardware.c
Added : /freeldr/arch/i386/hwacpi.c
Added : /freeldr/arch/i386/hwapm.c
Added : /freeldr/arch/i386/hwcpu.c
Added : /freeldr/arch/i386/hwpci.c
Added : /freeldr/arch/i386/i386cpu.S
Added : /freeldr/arch/i386/i386disk.c
Added : /freeldr/arch/i386/i386idt.S
Added : /freeldr/arch/i386/i386pnp.S
Added : /freeldr/arch/i386/i386rtl.c
Added : /freeldr/arch/i386/i386trap.S
Added : /freeldr/arch/i386/i386vid.c
Added : /freeldr/arch/i386/int386.S
Added : /freeldr/arch/i386/linux.S
Added : /freeldr/arch/i386/loader.c
Added : /freeldr/arch/i386/machpc.c
Added : /freeldr/arch/i386/machxbox.c
Added : /freeldr/arch/i386/mb.S
Added : /freeldr/arch/i386/pccons.c
Added : /freeldr/arch/i386/pcdisk.c
Added : /freeldr/arch/i386/pcmem.c
Added : /freeldr/arch/i386/pcrtc.c
Added : /freeldr/arch/i386/pcvideo.c
Added : /freeldr/arch/i386/portio.c
Added : /freeldr/arch/i386/xboxcons.c
Added : /freeldr/arch/i386/xboxdisk.c
Added : /freeldr/arch/i386/xboxfont.c
Added : /freeldr/arch/i386/xboxhw.c
Added : /freeldr/arch/i386/xboxi2c.c
Added : /freeldr/arch/i386/xboxmem.c
Added : /freeldr/arch/i386/xboxrtc.c
Added : /freeldr/arch/i386/xboxvideo.c
Added : /freeldr/arch/powerpc
Added : /freeldr/arch/powerpc/boot.s
Added : /freeldr/arch/powerpc/mach.c
Added : /freeldr/arch/powerpc/mboot.c
Added : /freeldr/bootmgr.c
Added : /freeldr/cache
Added : /freeldr/cache/blocklist.c
Added : /freeldr/cache/cache.c
Added : /freeldr/cmdline.c
Added : /freeldr/comm
Added : /freeldr/comm/rs232.c
Added : /freeldr/custom.c
Added : /freeldr/debug.c
Added : /freeldr/disk
Added : /freeldr/disk/disk.c
Added : /freeldr/disk/partition.c
Added : /freeldr/drivemap.c
Added : /freeldr/freeldr.c
Added : /freeldr/freeldr.rbuild
Added : /freeldr/freeldr_arch.rbuild
Added : /freeldr/freeldr_base.rbuild
Added : /freeldr/freeldr_base64k.rbuild
Added : /freeldr/freeldr_main.rbuild
Added : /freeldr/freeldr_startup.rbuild
Added : /freeldr/fs
Added : /freeldr/fs/ext2.c
Added : /freeldr/fs/fat.c
Added : /freeldr/fs/fs.c
Added : /freeldr/fs/fsrec.c
Added : /freeldr/fs/iso.c
Added : /freeldr/fs/ntfs.c
Added : /freeldr/include
Added : /freeldr/include/arch
Added : /freeldr/include/arch/i386
Added : /freeldr/include/arch/i386/hardware.h
Added : /freeldr/include/arch/i386/i386.h
Added : /freeldr/include/arch/i386/machpc.h
Added : /freeldr/include/arch/i386/machxbox.h
Added : /freeldr/include/arch.h
Added : /freeldr/include/bootmgr.h
Added : /freeldr/include/cache.h
Added : /freeldr/include/cmdline.h
Added : /freeldr/include/comm.h
Added : /freeldr/include/debug.h
Added : /freeldr/include/disk.h
Added : /freeldr/include/drivemap.h
Added : /freeldr/include/freeldr.h
Added : /freeldr/include/fs
Added : /freeldr/include/fs/ext2.h
Added : /freeldr/include/fs/fat.h
Added : /freeldr/include/fs/iso.h
Added : /freeldr/include/fs/ntfs.h
Added : /freeldr/include/fs.h
Added : /freeldr/include/fsrec.h
Added : /freeldr/include/inffile.h
Added : /freeldr/include/inifile.h
Added : /freeldr/include/keycodes.h
Added : /freeldr/include/linux.h
Added : /freeldr/include/machine.h
Added : /freeldr/include/miscboot.h
Added : /freeldr/include/mm.h
Added : /freeldr/include/multiboot.h
Added : /freeldr/include/of.h
Added : /freeldr/include/options.h
Added : /freeldr/include/oslist.h
Added : /freeldr/include/portio.h
Added : /freeldr/include/reactos.h
Added : /freeldr/include/registry.h
Added : /freeldr/include/rtl.h
Added : /freeldr/include/ui
Added : /freeldr/include/ui/gui.h
Added : /freeldr/include/ui/tui.h
Added : /freeldr/include/ui.h
Added : /freeldr/include/ver.h
Added : /freeldr/include/video.h
Added : /freeldr/include/winldr.h
Added : /freeldr/inffile
Added : /freeldr/inffile/inffile.c
Added : /freeldr/inifile
Added : /freeldr/inifile/ini_init.c
Added : /freeldr/inifile/inifile.c
Added : /freeldr/inifile/parse.c
Added : /freeldr/linuxboot.c
Added : /freeldr/machine.c
Added : /freeldr/math
Added : /freeldr/math/i386.h
Added : /freeldr/math/libgcc2.c
Added : /freeldr/math/libgcc2.h
Added : /freeldr/math/longlong.h
Added : /freeldr/math/powerpc.h
Added : /freeldr/miscboot.c
Added : /freeldr/mm
Added : /freeldr/mm/meminit.c
Added : /freeldr/mm/mm.c
Added : /freeldr/options.c
Added : /freeldr/oslist.c
Added : /freeldr/reactos
Added : /freeldr/reactos/arcname.c
Added : /freeldr/reactos/binhive.c
Added : /freeldr/reactos/reactos.c
Added : /freeldr/reactos/registry.c
Added : /freeldr/reactos/setupldr.c
Added : /freeldr/rtl
Added : /freeldr/rtl/libsupp.c
Added : /freeldr/rtl/list.c
Added : /freeldr/setupldr.rbuild
Added : /freeldr/setupldr_main.rbuild
Added : /freeldr/ui
Added : /freeldr/ui/gui.c
Added : /freeldr/ui/tui.c
Added : /freeldr/ui/tuimenu.c
Added : /freeldr/ui/ui.c
Added : /freeldr/version.c
Added : /freeldr/video
Added : /freeldr/video/bank.c
Added : /freeldr/video/fade.c
Added : /freeldr/video/palette.c
Added : /freeldr/video/pixel.c
Added : /freeldr/video/video.c
Added : /freeldr/windows
Added : /freeldr/windows/conversion.c
Added : /freeldr/windows/peloader.c
Added : /freeldr/windows/winldr.c
Added : /freeldr/windows/wlmemory.c
Added : /freeldr/windows/wlregistry.c




svn path=/branches/winldr/; revision=25067
2006-12-04 22:08:02 +00:00

642 lines
14 KiB
C

/*
* FreeLoader
*
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <freeldr.h>
ROS_LOADER_PARAMETER_BLOCK LoaderBlock;
char reactos_kernel_cmdline[255]; // Command line passed to kernel
LOADER_MODULE reactos_modules[64]; // Array to hold boot module info loaded for the kernel
char reactos_module_strings[64][256]; // Array to hold module names
unsigned long reactos_memory_map_descriptor_size;
memory_map_t reactos_memory_map[32]; // Memory map
char szBootPath[256];
char szHalName[256];
#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
static FrLdrLoadKernel(IN PCHAR szFileName,
IN INT nPos)
{
PFILE FilePointer;
PCHAR szShortName;
CHAR szBuffer[256];
/* Extract Kernel filename without path */
szShortName = strrchr(szFileName, '\\');
if (!szShortName)
{
/* No path, leave it alone */
szShortName = szFileName;
}
else
{
/* Skip the path */
szShortName = szShortName + 1;
}
/* Open the Kernel */
FilePointer = FsOpenFile(szFileName);
if (!FilePointer)
{
/* 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 */
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
LoadDriver(PCSTR szSourcePath, PCSTR szFileName)
{
CHAR szFullName[256];
#ifdef USE_UI
CHAR szBuffer[80];
#endif
PFILE FilePointer;
PCSTR szShortName;
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);
}
szShortName = strrchr(szFileName, '\\');
if (szShortName == NULL)
szShortName = szFileName;
else
szShortName = szShortName + 1;
FilePointer = FsOpenFile(szFullName);
if (FilePointer == NULL)
{
printf("Could not find %s\n", szFileName);
return(FALSE);
}
/*
* Update the status bar with the current file
*/
#ifdef USE_UI
sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
UiDrawStatusText(szBuffer);
#else
printf("Reading %s\n", szShortName);
#endif
/* Load the driver */
FrLdrLoadModule(FilePointer, szFileName, NULL);
return(TRUE);
}
static BOOLEAN
LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName)
{
CHAR szFullName[256];
#ifdef USE_UI
CHAR szBuffer[80];
#endif
PFILE FilePointer;
PCSTR szShortName;
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);
}
szShortName = strrchr(szFileName, '\\');
if (szShortName == NULL)
szShortName = szFileName;
else
szShortName = szShortName + 1;
FilePointer = FsOpenFile(szFullName);
if (FilePointer == NULL)
{
printf("Could not find %s\n", szFileName);
return(FALSE);
}
/*
* Update the status bar with the current file
*/
#ifdef USE_UI
sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
UiDrawStatusText(szBuffer);
#else
printf("Reading %s\n", szShortName);
#endif
/* Load the driver */
FrLdrLoadModule(FilePointer, szModuleName, NULL);
return(TRUE);
}
VOID RunLoader(VOID)
{
ULONG_PTR Base;
ULONG Size;
const char *SourcePath;
const char *LoadOptions;
UINT i;
char szKernelName[256];
PCONFIGURATION_COMPONENT_DATA ConfigRoot;
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)
{
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++)
{
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();
UiDrawStatusText("");
#endif
extern BOOLEAN FrLdrBootType;
FrLdrBootType = TRUE;
/* Initialize registry */
RegInitializeRegistry();
/* Detect hardware */
#ifdef USE_UI
UiDrawStatusText("Detecting hardware...");
#else
printf("Detecting hardware...\n\n");
#endif
MachHwDetect(&ConfigRoot);
#ifdef USE_UI
UiDrawStatusText("");
#endif
/* set boot device */
MachDiskGetBootDevice(&LoaderBlock.BootDevice);
/* Open boot drive */
if (!FsOpenBootVolume())
{
#ifdef USE_UI
UiMessageBox("Failed to open boot drive.");
#else
printf("Failed to open boot drive.");
#endif
return;
}
/* Open 'txtsetup.sif' */
if (!InfOpenFile (&InfHandle,
MachDiskBootingFromFloppy() ? "\\txtsetup.sif" : "\\reactos\\txtsetup.sif",
&ErrorLine))
{
printf("Failed to open 'txtsetup.sif'\n");
return;
}
/* Get load options */
if (!InfFindFirstLine (InfHandle,
"SetupData",
"OsLoadOptions",
&InfContext))
{
printf("Failed to find 'SetupData/OsLoadOptions'\n");
return;
}
if (!InfGetDataField (&InfContext,
1,
&LoadOptions))
{
printf("Failed to get load options\n");
return;
}
#if 0
printf("LoadOptions: '%s'\n", LoadOptions);
#endif
if (MachDiskBootingFromFloppy())
{
/* Boot from floppy disk */
SourcePath = "\\";
}
else
{
/* Boot from cdrom */
SourcePath = "\\reactos";
}
/* Set kernel command line */
MachDiskGetBootPath(reactos_kernel_cmdline, sizeof(reactos_kernel_cmdline));
strcat(strcat(strcat(reactos_kernel_cmdline, SourcePath), " "),
LoadOptions);
/* Setup the boot path and kernel path */
strcpy(szBootPath, SourcePath);
strcpy(szKernelName, szBootPath);
strcat(szKernelName, "\\ntoskrnl.exe");
/* Setup the HAL path */
strcpy(szHalName, szBootPath);
strcat(szHalName, "\\hal.dll");
/* 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);
FrLdrCloseModule (Base, Size);
#if 0
printf("Base: %x\n", Base);
printf("Size: %u\n", Size);
printf("*** System stopped ***\n");
for(;;);
#endif
/* Insert boot disk 2 */
if (MachDiskBootingFromFloppy())
{
#ifdef USE_UI
UiMessageBox("Please insert \"ReactOS Boot Disk 2\" and press ENTER");
#else
printf("\n\n Please insert \"ReactOS Boot Disk 2\" and press ENTER\n");
MachConsGetCh();
#endif
/* Open boot drive */
if (!FsOpenBootVolume())
{
#ifdef USE_UI
UiMessageBox("Failed to open boot drive.");
#else
printf("Failed to open boot drive.");
#endif
return;
}
/* FIXME: check volume label or disk marker file */
}
/* Get ANSI codepage file */
if (!InfFindFirstLine (InfHandle,
"NLS",
"AnsiCodepage",
&InfContext))
{
printf("Failed to find 'NLS/AnsiCodepage'\n");
return;
}
if (!InfGetDataField (&InfContext,
1,
&LoadOptions))
{
printf("Failed to get load options\n");
return;
}
/* Load ANSI codepage file */
if (!LoadNlsFile(SourcePath, LoadOptions, "ansi.nls"))
{
#ifdef USE_UI
UiMessageBox("Failed to load the ANSI codepage file.");
#else
printf("Failed to load the ANSI codepage file.");
#endif
return;
}
/* Get OEM codepage file */
if (!InfFindFirstLine (InfHandle,
"NLS",
"OemCodepage",
&InfContext))
{
printf("Failed to find 'NLS/AnsiCodepage'\n");
return;
}
if (!InfGetDataField (&InfContext,
1,
&LoadOptions))
{
printf("Failed to get load options\n");
return;
}
/* Load OEM codepage file */
if (!LoadNlsFile(SourcePath, LoadOptions, "oem.nls"))
{
#ifdef USE_UI
UiMessageBox("Failed to load the OEM codepage file.");
#else
printf("Failed to load the OEM codepage file.");
#endif
return;
}
/* Get Unicode Casemap file */
if (!InfFindFirstLine (InfHandle,
"NLS",
"UnicodeCasetable",
&InfContext))
{
printf("Failed to find 'NLS/AnsiCodepage'\n");
return;
}
if (!InfGetDataField (&InfContext,
1,
&LoadOptions))
{
printf("Failed to get load options\n");
return;
}
/* Load Unicode casemap file */
if (!LoadNlsFile(SourcePath, LoadOptions, "casemap.nls"))
{
#ifdef USE_UI
UiMessageBox("Failed to load the Unicode casemap file.");
#else
printf("Failed to load the Unicode casemap file.");
#endif
return;
}
#if 0
/* Load acpi.sys */
if (!LoadDriver(SourcePath, "acpi.sys"))
return;
#endif
#if 0
/* Load isapnp.sys */
if (!LoadDriver(SourcePath, "isapnp.sys"))
return;
#endif
#if 0
/* Load pci.sys */
if (!LoadDriver(SourcePath, "pci.sys"))
return;
#endif
/* Load scsiport.sys */
if (!LoadDriver(SourcePath, "scsiport.sys"))
return;
/* Load atapi.sys (depends on hardware detection) */
if (!LoadDriver(SourcePath, "atapi.sys"))
return;
/* Load buslogic.sys (depends on hardware detection) */
if (!LoadDriver(SourcePath, "buslogic.sys"))
return;
/* Load class2.sys */
if (!LoadDriver(SourcePath, "class2.sys"))
return;
/* Load cdrom.sys */
if (!LoadDriver(SourcePath, "cdrom.sys"))
return;
/* Load cdfs.sys */
if (!LoadDriver(SourcePath, "cdfs.sys"))
return;
/* Load disk.sys */
if (!LoadDriver(SourcePath, "disk.sys"))
return;
/* Load floppy.sys */
if (!LoadDriver(SourcePath, "floppy.sys"))
return;
/* Load vfatfs.sys (could be loaded by the setup prog!) */
if (!LoadDriver(SourcePath, "vfatfs.sys"))
return;
/* Load keyboard driver */
#if 0
if (!LoadDriver(SourcePath, "keyboard.sys"))
return;
#endif
if (!LoadDriver(SourcePath, "i8042prt.sys"))
return;
if (!LoadDriver(SourcePath, "kbdclass.sys"))
return;
/* Load screen driver */
if (!LoadDriver(SourcePath, "blue.sys"))
return;
#ifdef USE_UI
UiUnInitialize("Booting ReactOS...");
#endif
/* Now boot the kernel */
DiskStopFloppyMotor();
MachVideoPrepareForReactOS();
FrLdrStartup(0x2badb002);
}
/* EOF */