#include <freeldr.h>
#include <ndk/ldrtypes.h>
+#include <arc/setupblk.h>
+
#include <debug.h>
// TODO: Move to .h
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
DPRINTM(DPRINT_WINDOWS, "NLS data loaded with status %d\n", Status);
}
+VOID
+SetupLdrScanBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, HINF InfHandle, LPCSTR SearchPath)
+{
+ INFCONTEXT InfContext;
+ BOOLEAN Status;
+ LPCSTR Media, DriverName;
+ WCHAR ServiceName[256];
+ WCHAR ImagePath[256];
+
+ /* Open inf section */
+ if (!InfFindFirstLine(InfHandle, "SourceDisksFiles", NULL, &InfContext))
+ return;
+
+ /* Load all listed boot drivers */
+ do
+ {
+ if (InfGetDataField(&InfContext, 7, &Media) &&
+ InfGetDataField(&InfContext, 0, &DriverName))
+ {
+ if (strcmp(Media, "x") == 0)
+ {
+ /* Convert name to widechar */
+ swprintf(ServiceName, L"%S", DriverName);
+
+ /* Remove .sys extension */
+ ServiceName[wcslen(ServiceName) - 4] = 0;
+
+ /* Prepare image path */
+ swprintf(ImagePath, L"%S", DriverName);
+
+ /* Add it to the list */
+ Status = WinLdrAddDriverToList(&LoaderBlock->BootDriverListHead,
+ L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\",
+ ImagePath,
+ ServiceName);
+
+ if (!Status)
+ {
+ DPRINTM(DPRINT_WINDOWS, "could not add boot driver %s, %s\n", SearchPath, DriverName);
+ return;
+ }
+ }
+ }
+ } while (InfFindNextLine(&InfContext, &InfContext));
+}
+
VOID LoadReactOSSetup2(VOID)
{
CHAR SystemPath[512], SearchPath[512];
CHAR FileName[512];
CHAR BootPath[512];
- LPCSTR BootOptions;
+ LPCSTR LoadOptions, BootOptions;
+#if DBG
+ LPCSTR DbgOptions;
+#endif
PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL;
BOOLEAN Status;
- ULONG BootDevice;
ULONG i, ErrorLine;
HINF InfHandle;
INFCONTEXT InfContext;
PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA;
+ PSETUP_LOADER_BLOCK SetupBlock;
KERNEL_ENTRY_POINT KiSystemStartup;
PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL;
// Mm-related things
NULL
};
- /* Get boot device number */
- MachDiskGetBootDevice(&BootDevice);
-
/* Open 'txtsetup.sif' from any of source paths */
+ MachDiskGetBootPath(SystemPath, sizeof(SystemPath));
for (i = MachDiskBootingFromFloppy() ? 0 : 1; ; i++)
{
SourcePath = SourcePaths[i];
printf("Failed to open 'txtsetup.sif'\n");
return;
}
- sprintf(FileName,"%s\\txtsetup.sif", SourcePath);
+ sprintf(FileName, "%s\\txtsetup.sif", SourcePath);
if (InfOpenFile (&InfHandle, FileName, &ErrorLine))
+ {
+ sprintf(BootPath, "%s%s\\", SystemPath, SourcePath);
break;
+ }
}
- /* If we didn't find it anywhere, then just use root */
- if (!*SourcePath)
- SourcePath = "\\";
-
- /* Load options */
+ /* Get Load options - debug and non-debug */
if (!InfFindFirstLine(InfHandle,
"SetupData",
"OsLoadOptions",
return;
}
- if (!InfGetDataField (&InfContext, 1, &BootOptions))
+ if (!InfGetDataField (&InfContext, 1, &LoadOptions))
{
printf("Failed to get load options\n");
return;
}
- /* Save source path */
- strcpy(BootPath, SourcePath);
+ BootOptions = LoadOptions;
+
+#if DBG
+ /* Get debug load options and use them */
+ if (InfFindFirstLine(InfHandle,
+ "SetupData",
+ "DbgOsLoadOptions",
+ &InfContext))
+ {
+ if (!InfGetDataField(&InfContext, 1, &DbgOptions))
+ DbgOptions = "";
+ else
+ BootOptions = DbgOptions;
+ }
+#endif
+
+ DPRINTM(DPRINT_WINDOWS,"BootOptions: '%s'\n", BootOptions);
SetupUiInitialize();
UiDrawStatusText("");
/* Let user know we started loading */
UiDrawStatusText("Loading...");
- /* Try to open system drive */
- FsOpenBootVolume();
-
- /* Append a backslash to the bootpath if needed */
- if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\')
- {
- strcat(BootPath, "\\");
- }
-
/* Construct the system path */
- MachDiskGetBootPath(SystemPath, sizeof(SystemPath));
- strcat(SystemPath, SourcePath);
+ sprintf(SystemPath, "%s\\", SourcePath);
- DPRINTM(DPRINT_WINDOWS,"SystemRoot: '%s', SystemPath: '%s'\n", BootPath, SystemPath);
+ DPRINTM(DPRINT_WINDOWS,"BootPath: '%s', SystemPath: '%s'\n", BootPath, SystemPath);
/* Allocate and minimalistic-initialize LPB */
AllocateAndInitLPB(&LoaderBlock);
+ /* Allocate and initialize setup loader block */
+ SetupBlock = MmHeapAlloc(sizeof(SETUP_LOADER_BLOCK));
+ RtlZeroMemory(SetupBlock, sizeof(SETUP_LOADER_BLOCK));
+ LoaderBlock->SetupLdrBlock = SetupBlock;
+
+ /* Set textmode setup flag */
+ SetupBlock->Flags = SETUPLDR_TEXT_MODE;
+
/* Detect hardware */
UseRealHeap = TRUE;
LoaderBlock->ConfigurationRoot = MachHwDetect();
/* Load NLS data */
SetupLdrLoadNlsData(LoaderBlock, InfHandle, BootPath);
+ /* Get a list of boot drivers */
+ SetupLdrScanBootDrivers(LoaderBlock, InfHandle, BootPath);
+
/* Load boot drivers */
- //Status = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
+ 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 */
LoaderBlockVA = PaToVa(LoaderBlock);
/* "Stop all motors", change videomode */
- MachPrepareForReactOS(FALSE);
+ MachPrepareForReactOS(TRUE);
/* Debugging... */
//DumpMemoryAllocMap();
//WinLdrpDumpBootDriver(LoaderBlockVA);
//WinLdrpDumpArcDisks(LoaderBlockVA);
+ /*asm(".intel_syntax noprefix\n");
+ asm("test1:\n");
+ asm("jmp test1\n");
+ asm(".att_syntax\n");*/
+
/* Pass control */
(*KiSystemStartup)(LoaderBlockVA);