Author: ion Date: Mon Oct 9 05:16:28 2006 New Revision: 24463
URL: http://svn.reactos.org/svn/reactos?rev=24463&view=rev Log: - Initialize the registry in one shot, and allow it to fail and do the associated CONFIG_INIT_FAILED bugcheck. - Initialize Io in one shot, with IoInitSystem. - Locate the system DLL a bit later, since on the boot CD this creates a small incompatibility due to the wrong path being in use.
Modified: trunk/reactos/ntoskrnl/KrnlFun.c trunk/reactos/ntoskrnl/cm/registry.c trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h trunk/reactos/ntoskrnl/io/iomgr/iomgr.c
Modified: trunk/reactos/ntoskrnl/KrnlFun.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/KrnlFun.c?rev=2446... ============================================================================== --- trunk/reactos/ntoskrnl/KrnlFun.c (original) +++ trunk/reactos/ntoskrnl/KrnlFun.c Mon Oct 9 05:16:28 2006 @@ -29,7 +29,6 @@ // - FIXES: // * Sanitize some context fields during conversions. // * Figure out why the DPC stack doesn't really work. -// * Try to make MmInit1 NTLDR compatible. // * Add DR macro/save and VM macro/save. // - FEATURES: // * New optimized table-based tick-hashed timer implementation.
Modified: trunk/reactos/ntoskrnl/cm/registry.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/registry.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/cm/registry.c (original) +++ trunk/reactos/ntoskrnl/cm/registry.c Mon Oct 9 05:16:28 2006 @@ -27,6 +27,8 @@ #endif
/* GLOBALS ******************************************************************/ + +extern BOOLEAN ExpInTextModeSetup;
POBJECT_TYPE CmiKeyType = NULL; PEREGISTRY_HIVE CmiVolatileHive = NULL; @@ -129,6 +131,115 @@ } }
+VOID INIT_FUNCTION +CmInit2(PCHAR CommandLine) +{ + ULONG PiceStart = 4; + BOOLEAN MiniNT = FALSE; + PWCHAR SystemBootDevice; + PWCHAR SystemStartOptions; + ULONG Position; + NTSTATUS Status; + + /* Create the 'CurrentControlSet' link. */ + Status = CmiCreateCurrentControlSetLink(); + if (!NT_SUCCESS(Status)) + KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); + + /* + * Parse the system boot device. + */ + Position = 0; + SystemBootDevice = ExAllocatePool(PagedPool, + (strlen(CommandLine) + 1) * sizeof(WCHAR)); + if (SystemBootDevice == NULL) + { + KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); + } + + while (*CommandLine != 0 && *CommandLine != ' ') + SystemBootDevice[Position++] = *(CommandLine++); + SystemBootDevice[Position++] = 0; + + /* + * Write the system boot device to registry. + */ + Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE, + L"\Registry\Machine\System\CurrentControlSet\Control", + L"SystemBootDevice", + REG_SZ, + SystemBootDevice, + Position * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); + } + + /* + * Parse the system start options. + */ + Position = 0; + SystemStartOptions = SystemBootDevice; + while ((CommandLine = strchr(CommandLine, '/')) != NULL) + { + /* Skip over the slash */ + CommandLine++; + + /* Special options */ + if (!_strnicmp(CommandLine, "MININT", 6)) + MiniNT = TRUE; + else if (!_strnicmp(CommandLine, "DEBUGPORT=PICE", 14)) + PiceStart = 1; + + /* Add a space between the options */ + if (Position != 0) + SystemStartOptions[Position++] = L' '; + + /* Copy the command */ + while (*CommandLine != 0 && *CommandLine != ' ') + SystemStartOptions[Position++] = *(CommandLine++); + } + SystemStartOptions[Position++] = 0; + + /* + * Write the system start options to registry. + */ + Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE, + L"\Registry\Machine\System\CurrentControlSet\Control", + L"SystemStartOptions", + REG_SZ, + SystemStartOptions, + Position * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); + } + + /* + * Create a CurrentControlSet\Control\MiniNT key that is used + * to detect WinPE/MiniNT systems. + */ + if (MiniNT) + { + Status = RtlCreateRegistryKey(RTL_REGISTRY_CONTROL, L"MiniNT"); + if (!NT_SUCCESS(Status)) + KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); + } + + /* Set PICE 'Start' value to 1, if PICE debugging is enabled */ + Status = RtlWriteRegistryValue( + RTL_REGISTRY_SERVICES, + L"\Pice", + L"Start", + REG_DWORD, + &PiceStart, + sizeof(ULONG)); + if (!NT_SUCCESS(Status)) + KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); + + ExFreePool(SystemBootDevice); +} +
VOID INIT_FUNCTION @@ -186,7 +297,7 @@ if (SetupBoot == FALSE) CmInit2(KeLoaderBlock->LoadOptions); }
-VOID +BOOLEAN INIT_FUNCTION NTAPI CmInitSystem1(VOID) @@ -245,10 +356,7 @@ &ThreadId, CmiWorkerThread, NULL); - if (!NT_SUCCESS(Status)) - { - KEBUGCHECK(0); - } + if (!NT_SUCCESS(Status)) return FALSE;
/* Start the timer */ DueTime.QuadPart = -1; @@ -339,117 +447,12 @@ REG_OPTION_VOLATILE, NULL); ASSERT(NT_SUCCESS(Status)); + + /* Import and Load Registry Hives */ + CmInitHives(ExpInTextModeSetup); + return TRUE; }
- -VOID INIT_FUNCTION -CmInit2(PCHAR CommandLine) -{ - ULONG PiceStart = 4; - BOOLEAN MiniNT = FALSE; - PWCHAR SystemBootDevice; - PWCHAR SystemStartOptions; - ULONG Position; - NTSTATUS Status; - - /* Create the 'CurrentControlSet' link. */ - Status = CmiCreateCurrentControlSetLink(); - if (!NT_SUCCESS(Status)) - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - - /* - * Parse the system boot device. - */ - Position = 0; - SystemBootDevice = ExAllocatePool(PagedPool, - (strlen(CommandLine) + 1) * sizeof(WCHAR)); - if (SystemBootDevice == NULL) - { - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - } - - while (*CommandLine != 0 && *CommandLine != ' ') - SystemBootDevice[Position++] = *(CommandLine++); - SystemBootDevice[Position++] = 0; - - /* - * Write the system boot device to registry. - */ - Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE, - L"\Registry\Machine\System\CurrentControlSet\Control", - L"SystemBootDevice", - REG_SZ, - SystemBootDevice, - Position * sizeof(WCHAR)); - if (!NT_SUCCESS(Status)) - { - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - } - - /* - * Parse the system start options. - */ - Position = 0; - SystemStartOptions = SystemBootDevice; - while ((CommandLine = strchr(CommandLine, '/')) != NULL) - { - /* Skip over the slash */ - CommandLine++; - - /* Special options */ - if (!_strnicmp(CommandLine, "MININT", 6)) - MiniNT = TRUE; - else if (!_strnicmp(CommandLine, "DEBUGPORT=PICE", 14)) - PiceStart = 1; - - /* Add a space between the options */ - if (Position != 0) - SystemStartOptions[Position++] = L' '; - - /* Copy the command */ - while (*CommandLine != 0 && *CommandLine != ' ') - SystemStartOptions[Position++] = *(CommandLine++); - } - SystemStartOptions[Position++] = 0; - - /* - * Write the system start options to registry. - */ - Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE, - L"\Registry\Machine\System\CurrentControlSet\Control", - L"SystemStartOptions", - REG_SZ, - SystemStartOptions, - Position * sizeof(WCHAR)); - if (!NT_SUCCESS(Status)) - { - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - } - - /* - * Create a CurrentControlSet\Control\MiniNT key that is used - * to detect WinPE/MiniNT systems. - */ - if (MiniNT) - { - Status = RtlCreateRegistryKey(RTL_REGISTRY_CONTROL, L"MiniNT"); - if (!NT_SUCCESS(Status)) - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - } - - /* Set PICE 'Start' value to 1, if PICE debugging is enabled */ - Status = RtlWriteRegistryValue( - RTL_REGISTRY_SERVICES, - L"\Pice", - L"Start", - REG_DWORD, - &PiceStart, - sizeof(ULONG)); - if (!NT_SUCCESS(Status)) - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - - ExFreePool(SystemBootDevice); -}
static NTSTATUS
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=2446... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Mon Oct 9 05:16:28 2006 @@ -654,7 +654,7 @@ if (!HalInitSystem(ExpInitializationPhase, LoaderBlock)) { /* Initialization failed */ - KEBUGCHECK(HAL_INITIALIZATION_FAILED); + KeBugCheck(HAL_INITIALIZATION_FAILED); }
/* We're done */ @@ -728,7 +728,7 @@
/* Convert to ANSI_STRING and null-terminate it */ RtlInitString(&AnsiPath, Buffer ); - Buffer[--AnsiPath.Length] = UNICODE_NULL; + Buffer[--AnsiPath.Length] = ANSI_NULL;
/* Get the string from KUSER_SHARED_DATA's buffer */ NtSystemRoot.Buffer = SharedUserData->NtSystemRoot; @@ -902,8 +902,8 @@ /* Initialize Cache Views */ CcInitializeCacheManager();
- /* Initialize the Registry (Hives are NOT yet loaded!) */ - CmInitSystem1(); + /* Initialize the Registry */ + if (!CmInitSystem1()) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
/* Update timezone information */ ExRefreshTimeZoneInformation(&SystemBootTime); @@ -917,23 +917,17 @@ /* Initialize LPC */ LpcpInitSystem();
- /* Initialize I/O Objects, Filesystems, Error Logging and Shutdown */ - IoInit(); + /* Enter the kernel debugger before starting up the boot drivers */ + if (KdDebuggerEnabled && KdpEarlyBreak) DbgBreakPoint(); + + /* Initialize the I/O Subsystem */ + if (!IoInitSystem(KeLoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED); + + /* Display the boot screen image if not disabled */ + if (!NoGuiBoot) InbvEnableBootDriver(TRUE);
/* Unmap Low memory, and initialize the MPW and Balancer Thread */ MmInit3(); - - /* Import and Load Registry Hives */ - CmInitHives(ExpInTextModeSetup); - - /* Enter the kernel debugger before starting up the boot drivers */ - if (KdDebuggerEnabled && KdpEarlyBreak) DbgBreakPoint(); - - /* Initialize the I/O Subsystem */ - if (!IoInitSystem(KeLoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED); - - /* Display the boot screen image if not disabled */ - if (!NoGuiBoot) InbvEnableBootDriver(TRUE);
/* Initialize VDM support */ KeI386VdmInitialize();
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/n... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h Mon Oct 9 05:16:28 2006 @@ -60,11 +60,8 @@ * Initalization functions (called once by main()) */ VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG LastKernelAddress); -VOID IoInit(VOID); BOOLEAN NTAPI ObInit(VOID); -VOID NTAPI CmInitSystem1(VOID); -VOID NTAPI CmInitHives(BOOLEAN SetupBoot); -VOID CmInit2(PCHAR CommandLine); +BOOLEAN NTAPI CmInitSystem1(VOID); VOID CmShutdownRegistry(VOID); BOOLEAN CmImportSystemHive(PCHAR ChunkBase, ULONG ChunkSize); BOOLEAN CmImportHardwareHive(PCHAR ChunkBase, ULONG ChunkSize);
Modified: trunk/reactos/ntoskrnl/io/iomgr/iomgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iomgr.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/iomgr.c (original) +++ trunk/reactos/ntoskrnl/io/iomgr/iomgr.c Mon Oct 9 05:16:28 2006 @@ -229,10 +229,18 @@ DPRINT("Done allocation\n"); }
-VOID + +BOOLEAN INIT_FUNCTION -IoInit (VOID) +NTAPI +IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { + PDEVICE_NODE DeviceNode; + PDRIVER_OBJECT DriverObject; + LDR_DATA_TABLE_ENTRY ModuleObject; + NTSTATUS Status; + CHAR Buffer[256]; + ANSI_STRING NtBootPath, RootString; OBJECT_TYPE_INITIALIZER ObjectTypeInitializer; UNICODE_STRING Name; OBJECT_ATTRIBUTES ObjectAttributes; @@ -297,113 +305,100 @@ ObjectTypeInitializer.UseDefaultObject = FALSE; ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoFileObjectType);
- /* - * Create the '\Driver' object directory - */ - RtlInitUnicodeString(&DirName, L"\Driver"); - InitializeObjectAttributes(&ObjectAttributes, - &DirName, - 0, - NULL, - NULL); - ZwCreateDirectoryObject(&Handle, - 0, - &ObjectAttributes); - - /* - * Create the '\FileSystem' object directory - */ - RtlInitUnicodeString(&DirName, - L"\FileSystem"); - InitializeObjectAttributes(&ObjectAttributes, - &DirName, - 0, - NULL, - NULL); - ZwCreateDirectoryObject(&Handle, - 0, - &ObjectAttributes); - - /* - * Create the '\Device' directory - */ - RtlInitUnicodeString(&DirName, - L"\Device"); - InitializeObjectAttributes(&ObjectAttributes, - &DirName, - 0, - NULL, - NULL); - ZwCreateDirectoryObject(&Handle, - 0, - &ObjectAttributes); - - /* - * Create the '??' directory - */ - RtlInitUnicodeString(&DirName, - L"\??"); - InitializeObjectAttributes(&ObjectAttributes, - &DirName, - 0, - NULL, - NULL); - ZwCreateDirectoryObject(&Handle, - 0, - &ObjectAttributes); - - /* - * Create the '\ArcName' directory - */ - RtlInitUnicodeString(&DirName, - L"\ArcName"); - InitializeObjectAttributes(&ObjectAttributes, - &DirName, - 0, - NULL, - NULL); - ZwCreateDirectoryObject(&Handle, - 0, - &ObjectAttributes); - - /* - * Initialize remaining subsubsystem - */ - IopInitDriverImplementation(); - IoInitCancelHandling(); - IoInitFileSystemImplementation(); - IoInitVpbImplementation(); - IoInitShutdownNotification(); - IopInitPnpNotificationImplementation(); - IopInitErrorLog(); - IopInitTimerImplementation(); - IopInitLookasideLists(); - - /* - * Create link from '\DosDevices' to '??' directory - */ - RtlInitUnicodeString(&DirName, - L"\??"); - IoCreateSymbolicLink(&LinkName, - &DirName); - - /* - * Initialize PnP manager - */ - PnpInit(); -} - -BOOLEAN -INIT_FUNCTION -NTAPI -IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - PDEVICE_NODE DeviceNode; - PDRIVER_OBJECT DriverObject; - LDR_DATA_TABLE_ENTRY ModuleObject; - NTSTATUS Status; - CHAR Buffer[256]; - ANSI_STRING NtBootPath, RootString; + /* + * Create the '\Driver' object directory + */ + RtlInitUnicodeString(&DirName, L"\Driver"); + InitializeObjectAttributes(&ObjectAttributes, + &DirName, + 0, + NULL, + NULL); + ZwCreateDirectoryObject(&Handle, + 0, + &ObjectAttributes); + + /* + * Create the '\FileSystem' object directory + */ + RtlInitUnicodeString(&DirName, + L"\FileSystem"); + InitializeObjectAttributes(&ObjectAttributes, + &DirName, + 0, + NULL, + NULL); + ZwCreateDirectoryObject(&Handle, + 0, + &ObjectAttributes); + + /* + * Create the '\Device' directory + */ + RtlInitUnicodeString(&DirName, + L"\Device"); + InitializeObjectAttributes(&ObjectAttributes, + &DirName, + 0, + NULL, + NULL); + ZwCreateDirectoryObject(&Handle, + 0, + &ObjectAttributes); + + /* + * Create the '??' directory + */ + RtlInitUnicodeString(&DirName, + L"\??"); + InitializeObjectAttributes(&ObjectAttributes, + &DirName, + 0, + NULL, + NULL); + ZwCreateDirectoryObject(&Handle, + 0, + &ObjectAttributes); + + /* + * Create the '\ArcName' directory + */ + RtlInitUnicodeString(&DirName, + L"\ArcName"); + InitializeObjectAttributes(&ObjectAttributes, + &DirName, + 0, + NULL, + NULL); + ZwCreateDirectoryObject(&Handle, + 0, + &ObjectAttributes); + + /* + * Initialize remaining subsubsystem + */ + IopInitDriverImplementation(); + IoInitCancelHandling(); + IoInitFileSystemImplementation(); + IoInitVpbImplementation(); + IoInitShutdownNotification(); + IopInitPnpNotificationImplementation(); + IopInitErrorLog(); + IopInitTimerImplementation(); + IopInitLookasideLists(); + + /* + * Create link from '\DosDevices' to '??' directory + */ + RtlInitUnicodeString(&DirName, + L"\??"); + IoCreateSymbolicLink(&LinkName, + &DirName); + + /* + * Initialize PnP manager + */ + PnpInit();
RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
@@ -480,9 +475,6 @@ /* Load services for devices found by PnP manager */ IopInitializePnpServices(IopRootDeviceNode, FALSE);
- /* Load the System DLL and its Entrypoints */ - if (!NT_SUCCESS(PsLocateSystemDll())) return FALSE; - /* Load system start drivers */ IopInitializeSystemDrivers();
@@ -517,6 +509,9 @@ Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &RootString, FALSE); if (!NT_SUCCESS(Status)) return FALSE;
+ /* Load the System DLL and its Entrypoints */ + if (!NT_SUCCESS(PsLocateSystemDll())) return FALSE; + /* Return success */ return TRUE; }