* Removing the ARC Boot path and splitting it into the ARC Boot Device Name, the ARC HAL Device Name, and the NT Boot and HAL Path Names, saved in their respective LoaderBlock pointers.
* Converting every slash to a space. ("/DEBUGPORT" -> " DEBUGPORT")
* Now we can fully parse and read NTLDR command lines.
- Update various code in the kernel to:
* Use LoaderBlock->ArcDeviceNamePath & friends instead of the command line.
* Stop depending on slashes, and instead use strstr for parameters.
svn path=/trunk/; revision=24358
extern ULONG KeLoaderModuleCount;
extern PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages;
BOOLEAN NoGuiBoot = FALSE;
-static BOOLEAN ForceAcpiDisable = FALSE;
/* Init flags and settings */
ULONG ExpInitializationPhase;
static
VOID
INIT_FUNCTION
-InitSystemSharedUserPage (PCSZ ParameterLine)
+InitSystemSharedUserPage (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
UNICODE_STRING ArcDeviceName;
UNICODE_STRING ArcName;
UNICODE_STRING DriveDeviceName;
UNICODE_STRING DriveName;
WCHAR DriveNameBuffer[20];
- PCHAR ParamBuffer;
PWCHAR ArcNameBuffer;
- PCHAR p;
NTSTATUS Status;
ULONG Length;
OBJECT_ATTRIBUTES ObjectAttributes;
* Format: "<arc_name>\<path> [options...]"
*/
- /* Create local parameter line copy */
- ParamBuffer = ExAllocatePool(PagedPool, 256);
- strcpy (ParamBuffer, (const char *)ParameterLine);
- DPRINT("%s\n", ParamBuffer);
+ RtlCreateUnicodeStringFromAsciiz(&BootPath, LoaderBlock->NtBootPathName);
- /* Cut options off */
- p = strchr (ParamBuffer, ' ');
- if (p) *p = 0;
- DPRINT("%s\n", ParamBuffer);
-
- /* Extract path */
- p = strchr (ParamBuffer, '\\');
- if (p) {
-
- DPRINT("Boot path: %s\n", p);
- RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
- *p = 0;
-
- } else {
-
- DPRINT("Boot path: %s\n", "\\");
- RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
- }
- DPRINT("Arc name: %s\n", ParamBuffer);
+ /* Remove the trailing backslash */
+ BootPath.Length -= sizeof(WCHAR);
+ BootPath.MaximumLength -= sizeof(WCHAR);
/* Only ARC Name left - Build full ARC Name */
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
- swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer);
+ swprintf (ArcNameBuffer, L"\\ArcName\\%S", LoaderBlock->ArcBootDeviceName);
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
- DPRINT("Arc name: %wZ\n", &ArcName);
-
- /* Free ParamBuffer */
- ExFreePool (ParamBuffer);
/* Allocate ARC Device Name string */
ArcDeviceName.Length = 0;
CPRINT("NtQuerySymbolicLinkObject() failed (Status %x)\n", Status);
KEBUGCHECK(0);
}
- DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName);
/* Allocate Device Name string */
DriveDeviceName.Length = 0;
}
}
-__inline
-VOID
-STDCALL
-ParseCommandLine(PBOOLEAN NoGuiBoot,
- PBOOLEAN ForceAcpiDisable)
-{
- PCHAR p1, p2;
-
- p1 = KeLoaderBlock->LoadOptions;
- while(*p1 && (p2 = strchr(p1, '/'))) {
-
- p2++;
- if (!_strnicmp(p2, "NOGUIBOOT", 9)) {
-
- p2 += 9;
- *NoGuiBoot = TRUE;
-
- } else if (!_strnicmp(p2, "CRASHDUMP", 9)) {
-
- p2 += 9;
- if (*p2 == ':') {
-
- p2++;
- if (!_strnicmp(p2, "FULL", 4)) {
-
- MmCoreDumpType = MM_CORE_DUMP_TYPE_FULL;
-
- } else {
-
- MmCoreDumpType = MM_CORE_DUMP_TYPE_NONE;
- }
- }
- } else if (!_strnicmp(p2, "NOACPI", 6)) {
-
- p2 += 6;
- *ForceAcpiDisable = TRUE;
- }
-
- p1 = p2;
- }
-}
-
VOID
FORCEINLINE
ParseAndCacheLoadedModules(VOID)
{
PNLS_DATA_BLOCK NlsData;
- /* Parse Command Line Settings */
- ParseCommandLine(&NoGuiBoot, &ForceAcpiDisable);
-
/* FIXME: Deprecate soon */
ParseAndCacheLoadedModules();
IoInit();
/* TBD */
- PoInit(AcpiTableDetected, ForceAcpiDisable);
+ PoInit(AcpiTableDetected, KeLoaderBlock);
/* Initialize the Registry (Hives are NOT yet loaded!) */
CmInitializeRegistry();
/* Clear the screen to blue */
HalInitSystem(2, KeLoaderBlock);
+ /* Check if GUI Boot is enabled */
+ if (strstr(KeLoaderBlock->LoadOptions, "NOGUIBOOT")) NoGuiBoot = TRUE;
+
/* Display version number and copyright/warranty message */
if (NoGuiBoot) ExpDisplayNotice();
PsLocateSystemDll();
/* Initialize shared user page. Set dos system path, dos device map, etc. */
- InitSystemSharedUserPage (KeLoaderBlock->LoadOptions);
+ InitSystemSharedUserPage(KeLoaderBlock);
/* Create 'ReactOSInitDone' event */
RtlInitUnicodeString(&EventName, L"\\ReactOSInitDone");
NTSTATUS
IoCreateSystemRootLink(
- IN PCHAR ParameterLine
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
//
NTAPI
PoInit(
BOOLEAN HaveAcpiTable,
- BOOLEAN ForceAcpiDisable
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
VOID
NTSTATUS INIT_FUNCTION
-IoCreateSystemRootLink(PCHAR ParameterLine)
+IoCreateSystemRootLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
ULONG Length;
HANDLE Handle;
- /* Create local parameter line copy */
- ParamBuffer = ExAllocatePool(PagedPool, 256);
- strcpy(ParamBuffer, (char *)ParameterLine);
+ RtlCreateUnicodeStringFromAsciiz(&BootPath, LoaderBlock->NtBootPathName);
- DPRINT("%s\n", ParamBuffer);
- /* Format: <arc_name>\<path> [options...] */
+ /* Remove the trailing backslash */
+ BootPath.Length -= sizeof(WCHAR);
+ BootPath.MaximumLength -= sizeof(WCHAR);
- /* cut options off */
- p = strchr(ParamBuffer, ' ');
- if (p)
- *p = 0;
- DPRINT("%s\n", ParamBuffer);
-
- /* extract path */
- p = strchr(ParamBuffer, '\\');
- if (p)
- {
- DPRINT("Boot path: %s\n", p);
- RtlCreateUnicodeStringFromAsciiz(&BootPath, p);
- *p = 0;
- }
- else
- {
- DPRINT("Boot path: %s\n", "\\");
- RtlCreateUnicodeStringFromAsciiz(&BootPath, "\\");
- }
- DPRINT("ARC name: %s\n", ParamBuffer);
+ /* Only ARC Name left - Build full ARC Name */
+ ParamBuffer = LoaderBlock->ArcBootDeviceName;
p = strstr(ParamBuffer, "cdrom");
if (p != NULL)
DPRINT("New ARC name: %s\n", ParamBuffer);
/* Adjust original command line */
- p = strstr(ParameterLine, "cdrom");
+ p = strstr(LoaderBlock->ArcBootDeviceName, "cdrom");
if (p != NULL);
{
char temp[256];
swprintf(ArcNameBuffer,
L"\\ArcName\\%S", ParamBuffer);
RtlInitUnicodeString(&ArcName, ArcNameBuffer);
- DPRINT("Arc name: %wZ\n", &ArcName);
-
- /* free ParamBuffer */
- ExFreePool(ParamBuffer);
/* allocate device name string */
DeviceName.Length = 0;
return(Status);
}
- DPRINT("Length: %lu DeviceName: %wZ\n", Length, &DeviceName);
RtlAppendUnicodeStringToString(&DeviceName,
&BootPath);
RtlFreeUnicodeString(&BootPath);
- DPRINT("DeviceName: %wZ\n", &DeviceName);
/* create the '\SystemRoot' link */
Status = IoCreateSymbolicLink(&LinkName,
/* Create the SystemRoot symbolic link */
DPRINT("CommandLine: %s\n", KeLoaderBlock->LoadOptions);
- Status = IoCreateSystemRootLink(KeLoaderBlock->LoadOptions);
+ Status = IoCreateSystemRootLink(KeLoaderBlock);
if (!NT_SUCCESS(Status)) {
CPRINT("IoCreateSystemRootLink FAILED: (0x%x) - ", Status);
KEBUGCHECK(INACCESSIBLE_BOOT_DEVICE);
{
ULONG Value;
ULONG i;
- PCHAR p1, p2;
-
-#if 0
- /* NTLDR HACK */
- KdpSerialInit(&DispatchTable[KdSerial], 0);
- KdpDebugMode.Serial = TRUE;
- SerialPortInfo.ComPort = 1;
- KdpPort = 1;
- KdDebuggerEnabled = TRUE;
-#endif
+ PCHAR CommandLine, Port, BaudRate, Irq;
/* Set Default Port Options */
if (BootPhase == 0)
{
+ /* Get the Command Line */
+ CommandLine = LoaderBlock->LoadOptions;
- /* Parse the Command Line */
- p1 = LoaderBlock->LoadOptions;
- while (p1 && (p2 = strchr(p1, '/')))
+ /* Upcase it */
+ _strupr(CommandLine);
+
+ /* Check for settings that we support */
+ if (strstr(CommandLine, "BREAK")) KdpEarlyBreak = TRUE;
+ if (strstr(CommandLine, "NODEBUG")) KdDebuggerEnabled = FALSE;
+ if (strstr(CommandLine, "CRASHDEBUG")) KdDebuggerEnabled = FALSE;
+ if (strstr(CommandLine, "DEBUG"))
{
- /* Move past the slash */
- p2++;
+ /* Enable on the serial port */
+ KdDebuggerEnabled = TRUE;
+ KdpDebugMode.Serial = TRUE;
+ }
- /* Identify the Debug Type being Used */
- if (!_strnicmp(p2, "DEBUGPORT=", 10))
- {
- p2 += 10;
- p2 = KdpGetDebugMode(p2);
- p2 = KdpGetWrapperDebugMode(p2, LoaderBlock);
- KdDebuggerEnabled = TRUE;
- }
- /* Check for early breakpoint */
- else if (!_strnicmp(p2, "BREAK", 5))
- {
- p2 += 5;
- KdpEarlyBreak = TRUE;
- }
- /* Check for Kernel Debugging Enable */
- else if (!_strnicmp(p2, "DEBUG", 5))
- {
- /* Enable it on the Serial Port */
- p2 += 5;
- KdDebuggerEnabled = TRUE;
- KdpDebugMode.Serial = TRUE;
- }
- /* Check for Kernel Debugging Bypass */
- else if (!_strnicmp(p2, "NODEBUG", 7))
- {
- /* Disable Debugging */
- p2 += 7;
- KdDebuggerEnabled = FALSE;
- }
- /* Check for Kernel Debugging Bypass unless STOP Error */
- else if (!_strnicmp(p2, "CRASHDEBUG", 10))
+ /* Get the port and baud rate */
+ Port = strstr(CommandLine, "DEBUGPORT");
+ BaudRate = strstr(CommandLine, "BAUDRATE");
+ Irq = strstr(CommandLine, "IRQ");
+
+ /* Check if we got the /DEBUGPORT parameter */
+ if (Port)
+ {
+ /* Move past the actual string, to reach the port*/
+ Port += strlen("DEBUGPORT");
+
+ /* Now get past any spaces and skip the equal sign */
+ while (*Port == ' ') Port++;
+ Port++;
+
+ /* Get the debug mode and wrapper */
+ Port = KdpGetDebugMode(Port);
+ Port = KdpGetWrapperDebugMode(Port, LoaderBlock);
+ KdDebuggerEnabled = TRUE;
+ }
+
+ /* Check if we got a baud rate */
+ if (BaudRate)
+ {
+ /* Move past the actual string, to reach the rate */
+ BaudRate += strlen("BAUDRATE");
+
+ /* Now get past any spaces */
+ while (*BaudRate == ' ') BaudRate++;
+
+ /* And make sure we have a rate */
+ if (*BaudRate)
{
- /* Disable Debugging */
- p2 += 10;
- KdDebuggerEnabled = FALSE;
+ /* Read and set it */
+ Value = atol(BaudRate + 1);
+ if (Value) PortInfo.BaudRate = SerialPortInfo.BaudRate = Value;
}
- /* Check Serial Port Settings [Baud Rate] */
- else if (!_strnicmp(p2, "BAUDRATE=", 9))
- {
- /* Get the Baud Rate */
- p2 += 9;
- Value = (ULONG)atol(p2);
+ }
- /* Check if it's valid and Set it */
- if (0 < Value) PortInfo.BaudRate = SerialPortInfo.BaudRate = Value;
- }
- /* Check Serial Port Settings [IRQ] */
- else if (!_strnicmp(p2, "IRQ=", 4))
- {
- /* Get the IRQ */
- p2 += 3;
- Value = (ULONG)atol(p2);
+ /* Check Serial Port Settings [IRQ] */
+ if (Irq)
+ {
+ /* Move past the actual string, to reach the rate */
+ Irq += strlen("IRQ");
- /* Check if it's valid and set it */
- if (0 < Value) KdpPortIrq = Value;
- }
+ /* Now get past any spaces */
+ while (*Irq == ' ') Irq++;
- /* Move to next */
- p1 = p2;
+ /* And make sure we have an IRQ */
+ if (*Irq)
+ {
+ /* Read and set it */
+ Value = atol(Irq + 1);
+ if (Value) KdpPortIrq = Value;
+ }
}
/* Call Providers at Phase 0 */
/* Call Wrapper at Phase 0 */
if (WrapperInitRoutine) WrapperInitRoutine(&WrapperTable, 0);
-
return;
}
/* Register as a Provider */
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
-
+
/* Display separator + ReactOS version at start of the debug log */
- DPRINT1("---------------------------------------------------------------\n");
+ DPRINT1("-----------------------------------------------------\n");
DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n");
+ DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions);
+ DPRINT1("ARC Paths: %s %s %s %s\n", KeLoaderBlock->ArcBootDeviceName,
+ KeLoaderBlock->NtHalPathName,
+ KeLoaderBlock->ArcHalDeviceName,
+ KeLoaderBlock->NtBootPathName);
}
else if (BootPhase == 2)
{
LOADER_PARAMETER_BLOCK BldrLoaderBlock;
LOADER_PARAMETER_EXTENSION BldrExtensionBlock;
CHAR BldrCommandLine[256];
+CHAR BldrArcBootPath[64];
+CHAR BldrArcHalPath[64];
+CHAR BldrNtHalPath[64];
+CHAR BldrNtBootPath[64];
LDR_DATA_TABLE_ENTRY BldrModules[64];
MEMORY_ALLOCATION_DESCRIPTOR BldrMemoryDescriptors[64];
WCHAR BldrModuleStrings[64][260];
ULONG i, j, ModSize;
PVOID ModStart;
PCHAR DriverName;
+ PCHAR BootPath, HalPath;
+ CHAR CommandLine[256];
/* First get some kernel-loader globals */
AcpiTableDetected = (RosLoaderBlock->Flags & MB_FLAGS_ACPI_TABLE) ? TRUE : FALSE;
/* All we'll setup right now is the flag for text-mode setup */
LoaderBlock->SetupLdrBlock->Flags = 1;
}
+
+ /* Make a copy of the command line */
+ strcpy(CommandLine, LoaderBlock->LoadOptions);
+
+ /* Find the first \, separating the ARC path from NT path */
+ BootPath = strchr(CommandLine, '\\');
+ *BootPath = ANSI_NULL;
+ strncpy(BldrArcBootPath, CommandLine, 63);
+ LoaderBlock->ArcBootDeviceName = BldrArcBootPath;
+
+ /* The rest of the string is the NT path */
+ HalPath = strchr(BootPath + 1, ' ');
+ *HalPath = ANSI_NULL;
+ BldrNtBootPath[0] = '\\';
+ strncat(BldrNtBootPath, BootPath + 1, 63);
+ strcat(BldrNtBootPath,"\\");
+ LoaderBlock->NtBootPathName = BldrNtBootPath;
+
+ /* Set the HAL paths */
+ strncpy(BldrArcHalPath, BldrArcBootPath, 63);
+ LoaderBlock->ArcHalDeviceName = BldrArcHalPath;
+ strcpy(BldrNtHalPath, "\\");
+ LoaderBlock->NtHalPathName = BldrNtHalPath;
+
+ /* Use this new command line */
+ strncpy(LoaderBlock->LoadOptions, HalPath + 2, 255);
+
+ /* Parse it and change every slash to a space */
+ BootPath = LoaderBlock->LoadOptions;
+ do {if (*BootPath == '/') *BootPath = ' ';} while (*BootPath++);
}
VOID
INIT_FUNCTION
NTAPI
PoInit(BOOLEAN HaveAcpiTable,
- BOOLEAN ForceAcpiDisable)
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
PVOID NotificationEntry;
+ PCHAR CommandLine;
+ BOOLEAN ForceAcpiDisable = FALSE;
+
+ /* Get the Command Line */
+ CommandLine = KeLoaderBlock->LoadOptions;
+
+ /* Upcase it */
+ _strupr(CommandLine);
+
+ /* Check for ACPI disable */
+ if (strstr(CommandLine, "NOACPI")) ForceAcpiDisable = TRUE;
if (ForceAcpiDisable)
{