Author: ion
Date: Mon Oct 2 09:40:36 2006
New Revision: 24358
URL:
http://svn.reactos.org/svn/reactos?rev=24358&view=rev
Log:
- Continue implementation of KiRosFrldrLpbToNtLpb by parsing the FreeLDR command line
and:
* 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.
Modified:
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/include/internal/po.h
trunk/reactos/ntoskrnl/io/iomgr/arcname.c
trunk/reactos/ntoskrnl/io/iomgr/iomgr.c
trunk/reactos/ntoskrnl/kd/kdinit.c
trunk/reactos/ntoskrnl/kd/kdio.c
trunk/reactos/ntoskrnl/ke/freeldr.c
trunk/reactos/ntoskrnl/po/power.c
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=243…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c (original)
+++ trunk/reactos/ntoskrnl/ex/init.c Mon Oct 2 09:40:36 2006
@@ -29,7 +29,6 @@
extern ULONG KeLoaderModuleCount;
extern PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages;
BOOLEAN NoGuiBoot = FALSE;
-static BOOLEAN ForceAcpiDisable = FALSE;
/* Init flags and settings */
ULONG ExpInitializationPhase;
@@ -48,7 +47,7 @@
static
VOID
INIT_FUNCTION
-InitSystemSharedUserPage (PCSZ ParameterLine)
+InitSystemSharedUserPage (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
UNICODE_STRING ArcDeviceName;
UNICODE_STRING ArcName;
@@ -56,9 +55,7 @@
UNICODE_STRING DriveDeviceName;
UNICODE_STRING DriveName;
WCHAR DriveNameBuffer[20];
- PCHAR ParamBuffer;
PWCHAR ArcNameBuffer;
- PCHAR p;
NTSTATUS Status;
ULONG Length;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -86,39 +83,16 @@
* Format: "<arc_name>\<path> [options...]"
*/
- /* Create local parameter line copy */
- ParamBuffer = ExAllocatePool(PagedPool, 256);
- strcpy (ParamBuffer, (const char *)ParameterLine);
- DPRINT("%s\n", ParamBuffer);
-
- /* 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);
+ RtlCreateUnicodeStringFromAsciiz(&BootPath, LoaderBlock->NtBootPathName);
+
+ /* 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;
@@ -163,7 +137,6 @@
CPRINT("NtQuerySymbolicLinkObject() failed (Status %x)\n", Status);
KEBUGCHECK(0);
}
- DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName);
/* Allocate Device Name string */
DriveDeviceName.Length = 0;
@@ -228,48 +201,6 @@
DbgPrint("No system drive found!\n");
KEBUGCHECK (NO_BOOT_DEVICE);
- }
-}
-
-__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;
}
}
@@ -472,9 +403,6 @@
{
PNLS_DATA_BLOCK NlsData;
- /* Parse Command Line Settings */
- ParseCommandLine(&NoGuiBoot, &ForceAcpiDisable);
-
/* FIXME: Deprecate soon */
ParseAndCacheLoadedModules();
@@ -630,7 +558,7 @@
IoInit();
/* TBD */
- PoInit(AcpiTableDetected, ForceAcpiDisable);
+ PoInit(AcpiTableDetected, KeLoaderBlock);
/* Initialize the Registry (Hives are NOT yet loaded!) */
CmInitializeRegistry();
@@ -649,6 +577,9 @@
/* 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();
@@ -685,7 +616,7 @@
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");
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h Mon Oct 2 09:40:36 2006
@@ -568,7 +568,7 @@
NTSTATUS
IoCreateSystemRootLink(
- IN PCHAR ParameterLine
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
//
Modified: trunk/reactos/ntoskrnl/include/internal/po.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/po.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/po.h Mon Oct 2 09:40:36 2006
@@ -39,7 +39,7 @@
NTAPI
PoInit(
BOOLEAN HaveAcpiTable,
- BOOLEAN ForceAcpiDisable
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
VOID
Modified: trunk/reactos/ntoskrnl/io/iomgr/arcname.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/arcname.…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/arcname.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/arcname.c Mon Oct 2 09:40:36 2006
@@ -679,7 +679,7 @@
NTSTATUS INIT_FUNCTION
-IoCreateSystemRootLink(PCHAR ParameterLine)
+IoCreateSystemRootLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
@@ -694,33 +694,14 @@
ULONG Length;
HANDLE Handle;
- /* Create local parameter line copy */
- ParamBuffer = ExAllocatePool(PagedPool, 256);
- strcpy(ParamBuffer, (char *)ParameterLine);
-
- DPRINT("%s\n", ParamBuffer);
- /* Format: <arc_name>\<path> [options...] */
-
- /* 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);
+ RtlCreateUnicodeStringFromAsciiz(&BootPath, LoaderBlock->NtBootPathName);
+
+ /* Remove the trailing backslash */
+ BootPath.Length -= sizeof(WCHAR);
+ BootPath.MaximumLength -= sizeof(WCHAR);
+
+ /* Only ARC Name left - Build full ARC Name */
+ ParamBuffer = LoaderBlock->ArcBootDeviceName;
p = strstr(ParamBuffer, "cdrom");
if (p != NULL)
@@ -740,7 +721,7 @@
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];
@@ -763,10 +744,6 @@
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;
@@ -808,13 +785,11 @@
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,
Modified: trunk/reactos/ntoskrnl/io/iomgr/iomgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iomgr.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/iomgr.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/iomgr.c Mon Oct 2 09:40:36 2006
@@ -483,7 +483,7 @@
/* 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);
Modified: trunk/reactos/ntoskrnl/kd/kdinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdinit.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/kd/kdinit.c (original)
+++ trunk/reactos/ntoskrnl/kd/kdinit.c Mon Oct 2 09:40:36 2006
@@ -166,87 +166,83 @@
{
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)
{
-
- /* Parse the Command Line */
- p1 = LoaderBlock->LoadOptions;
- while (p1 && (p2 = strchr(p1, '/')))
- {
- /* Move past the slash */
- p2++;
-
- /* Identify the Debug Type being Used */
- if (!_strnicmp(p2, "DEBUGPORT=", 10))
+ /* Get the Command Line */
+ CommandLine = LoaderBlock->LoadOptions;
+
+ /* 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"))
+ {
+ /* Enable on the serial port */
+ KdDebuggerEnabled = TRUE;
+ KdpDebugMode.Serial = TRUE;
+ }
+
+ /* 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)
{
- p2 += 10;
- p2 = KdpGetDebugMode(p2);
- p2 = KdpGetWrapperDebugMode(p2, LoaderBlock);
- KdDebuggerEnabled = TRUE;
+ /* Read and set it */
+ Value = atol(BaudRate + 1);
+ if (Value) PortInfo.BaudRate = SerialPortInfo.BaudRate = Value;
}
- /* Check for early breakpoint */
- else if (!_strnicmp(p2, "BREAK", 5))
+ }
+
+ /* Check Serial Port Settings [IRQ] */
+ if (Irq)
+ {
+ /* Move past the actual string, to reach the rate */
+ Irq += strlen("IRQ");
+
+ /* Now get past any spaces */
+ while (*Irq == ' ') Irq++;
+
+ /* And make sure we have an IRQ */
+ if (*Irq)
{
- p2 += 5;
- KdpEarlyBreak = TRUE;
+ /* Read and set it */
+ Value = atol(Irq + 1);
+ if (Value) KdpPortIrq = Value;
}
- /* 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))
- {
- /* Disable Debugging */
- p2 += 10;
- KdDebuggerEnabled = FALSE;
- }
- /* 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 if it's valid and set it */
- if (0 < Value) KdpPortIrq = Value;
- }
-
- /* Move to next */
- p1 = p2;
}
/* Call Providers at Phase 0 */
@@ -257,7 +253,6 @@
/* Call Wrapper at Phase 0 */
if (WrapperInitRoutine) WrapperInitRoutine(&WrapperTable, 0);
-
return;
}
Modified: trunk/reactos/ntoskrnl/kd/kdio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdio.c?rev=243…
==============================================================================
--- trunk/reactos/ntoskrnl/kd/kdio.c (original)
+++ trunk/reactos/ntoskrnl/kd/kdio.c Mon Oct 2 09:40:36 2006
@@ -188,10 +188,15 @@
/* 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)
{
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c Mon Oct 2 09:40:36 2006
@@ -43,6 +43,10 @@
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];
@@ -63,6 +67,8 @@
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;
@@ -256,6 +262,36 @@
/* 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
Modified: trunk/reactos/ntoskrnl/po/power.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/power.c?rev=24…
==============================================================================
--- trunk/reactos/ntoskrnl/po/power.c (original)
+++ trunk/reactos/ntoskrnl/po/power.c Mon Oct 2 09:40:36 2006
@@ -307,9 +307,20 @@
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)
{