Author: ion Date: Sun Oct 8 08:05:27 2006 New Revision: 24438
URL: http://svn.reactos.org/svn/reactos?rev=24438&view=rev Log: - Inline and make some slight correctiions to KiInitailizeSystemClock, since it's based on the Ex subsystem, not Ke. Add code for boot-time timezone bias, but currently disabled because I need to implement a function to read configuration registry data at startup. - Improve Init bugchecks to give the exact module that failed. Add Kd initilization in the same block as the other subsystems. - Rename and re-arrange some initlization calls.
Modified: trunk/reactos/ntoskrnl/cc/cacheman.c trunk/reactos/ntoskrnl/cm/registry.c trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/ex/sysinfo.c trunk/reactos/ntoskrnl/ex/time.c trunk/reactos/ntoskrnl/fs/filelock.c trunk/reactos/ntoskrnl/include/internal/cc.h trunk/reactos/ntoskrnl/include/internal/ex.h trunk/reactos/ntoskrnl/include/internal/fsrtl.h trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h trunk/reactos/ntoskrnl/kd/kdinit.c trunk/reactos/ntoskrnl/ke/clock.c
Modified: trunk/reactos/ntoskrnl/cc/cacheman.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/cacheman.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/cc/cacheman.c (original) +++ trunk/reactos/ntoskrnl/cc/cacheman.c Sun Oct 8 08:05:27 2006 @@ -18,7 +18,7 @@
VOID NTAPI -CcInit(VOID) +CcInitializeCacheManager(VOID) { CcInitView(); }
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 Sun Oct 8 08:05:27 2006 @@ -188,7 +188,8 @@
VOID INIT_FUNCTION -CmInitializeRegistry(VOID) +NTAPI +CmInitSystem1(VOID) { OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName;
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=2443... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Sun Oct 8 08:05:27 2006 @@ -14,6 +14,9 @@ #include <internal/debug.h>
/* DATA **********************************************************************/ + +/* HACK */ +extern BOOLEAN KiClockSetupComplete;
#define BUILD_OSCSDVERSION(major, minor) (((major & 0xFF) << 8) | (minor & 0xFF))
@@ -858,6 +861,8 @@ HANDLE ProcessHandle; HANDLE ThreadHandle; NTSTATUS Status; + TIME_FIELDS TimeFields; + LARGE_INTEGER SystemBootTime, UniversalBootTime;
/* Set to phase 1 */ ExpInitializationPhase = 1; @@ -868,54 +873,88 @@ /* Do Phase 1 HAL Initialization */ HalInitSystem(1, KeLoaderBlock);
- /* Setup system time */ - KiInitializeSystemClock(); + /* Check if GUI Boot is enabled */ + if (strstr(KeLoaderBlock->LoadOptions, "NOGUIBOOT")) NoGuiBoot = TRUE; + + /* Query the clock */ + if (HalQueryRealTimeClock(&TimeFields)) + { + /* Convert to time fields */ + RtlTimeFieldsToTime(&TimeFields, &SystemBootTime); + UniversalBootTime = SystemBootTime; + +#if 0 // FIXME: Won't work until we can read registry data here + /* FIXME: This assumes that the RTC is not already in GMT */ + ExpTimeZoneBias.QuadPart = Int32x32To64(ExpLastTimeZoneBias * 60, + 10000000); + + /* Set the boot time-zone bias */ + SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.HighPart; + SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.LowPart; + SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.HighPart; + + /* Convert the boot time to local time, and set it */ + UniversalBootTime.QuadPart = SystemBootTime.QuadPart + + ExpTimeZoneBias.QuadPart; +#endif + KiSetSystemTime(&UniversalBootTime); + + /* Remember this as the boot time */ + KeBootTime = UniversalBootTime; + } + + /* The clock is ready now (FIXME: HACK FOR OLD HAL) */ + KiClockSetupComplete = TRUE;
/* Initialize all processors */ HalAllProcessorsStarted();
/* Call OB initialization again */ - if (!ObInit()) KEBUGCHECK(OBJECT1_INITIALIZATION_FAILED); + if (!ObInit()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED);
/* Initialize Basic System Objects and Worker Threads */ - if (!ExInitSystem()) KEBUGCHECK(PHASE1_INITIALIZATION_FAILED); + if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 1, 0, 0, 0);
/* Initialize the later stages of the kernel */ - if (!KeInitSystem()) KEBUGCHECK(PHASE1_INITIALIZATION_FAILED); + if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 2, 0, 0, 0); + + /* Call KD Providers at Phase 1 */ + if (!KdInitSystem(ExpInitializationPhase, KeLoaderBlock)) + { + /* Failed, bugcheck */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 3, 0, 0, 0); + }
/* Create NLS section */ ExpInitNls(KeLoaderBlock);
- /* Call KD Providers at Phase 1 */ - KdInitSystem(1, KeLoaderBlock); - /* Initialize I/O Objects, Filesystems, Error Logging and Shutdown */ IoInit();
+ /* Initialize Cache Views */ + CcInitializeCacheManager(); + + /* Initialize the Registry (Hives are NOT yet loaded!) */ + CmInitSystem1(); + + /* Update timezone information */ + ExRefreshTimeZoneInformation(&SystemBootTime); + /* TBD */ PoInit(AcpiTableDetected, KeLoaderBlock);
- /* Initialize the Registry (Hives are NOT yet loaded!) */ - CmInitializeRegistry(); - /* Unmap Low memory, and initialize the MPW and Balancer Thread */ MmInit3();
- /* Initialize Cache Views */ - CcInit(); - - /* Initialize File Locking */ - FsRtlpInitFileLockingImplementation(); - - /* Report all resources used by hal */ + /* Initialize the File System Runtime Library */ + FsRtlInitSystem(); + + /* Report all resources used by HAL */ HalReportResourceUsage();
/* 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();
@@ -930,9 +969,6 @@
/* Initialize VDM support */ KeI386VdmInitialize(); - - /* Initialize the time zone information from the registry */ - ExpInitTimeZoneInfo();
/* Enter the kernel debugger before starting up the boot drivers */ if (KdDebuggerEnabled && KdpEarlyBreak) @@ -953,7 +989,7 @@ /* Initialize shared user page. Set dos system path, dos device map, etc. */ InitSystemSharedUserPage(KeLoaderBlock);
- /* Initailize the Process Manager at Phase 1 */ + /* Initialize the Process Manager at Phase 1 */ if (!PsInitSystem()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
/* Launch initial process */
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/ex/sysinfo.c (original) +++ trunk/reactos/ntoskrnl/ex/sysinfo.c Sun Oct 8 08:05:27 2006 @@ -548,7 +548,7 @@
KeQuerySystemTime(&CurrentTime);
- Sti->BootTime= SystemBootTime; + Sti->BootTime= KeBootTime; Sti->CurrentTime = CurrentTime; Sti->TimeZoneBias.QuadPart = ExpTimeZoneBias.QuadPart; Sti->TimeZoneId = ExpTimeZoneId;
Modified: trunk/reactos/ntoskrnl/ex/time.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/time.c?rev=2443... ============================================================================== --- trunk/reactos/ntoskrnl/ex/time.c (original) +++ trunk/reactos/ntoskrnl/ex/time.c Sun Oct 8 08:05:27 2006 @@ -23,21 +23,21 @@
/* Note: Bias[minutes] = UTC - local time */ TIME_ZONE_INFORMATION ExpTimeZoneInfo; +ULONG ExpLastTimeZoneBias = -1; LARGE_INTEGER ExpTimeZoneBias; ULONG ExpTimeZoneId; ULONG ExpTickCountMultiplier;
/* FUNCTIONS ****************************************************************/
-VOID -INIT_FUNCTION -NTAPI -ExpInitTimeZoneInfo(VOID) +BOOLEAN +NTAPI +ExRefreshTimeZoneInformation(IN PLARGE_INTEGER CurrentBootTime) { LARGE_INTEGER CurrentTime; NTSTATUS Status;
- /* Read time zone information from the registry */ + /* Read time zone information from the registry */ Status = RtlQueryTimeZoneInformation(&ExpTimeZoneInfo); if (!NT_SUCCESS(Status)) { @@ -52,8 +52,8 @@
/* Set bias and ID */ ExpTimeZoneBias.QuadPart = ((LONGLONG)(ExpTimeZoneInfo.Bias + - ExpTimeZoneInfo.StandardBias)) * - TICKSPERMINUTE; + ExpTimeZoneInfo.StandardBias)) * + TICKSPERMINUTE; ExpTimeZoneId = TIME_ZONE_ID_STANDARD; }
@@ -64,7 +64,7 @@ SharedUserData->TimeZoneId = ExpTimeZoneId;
/* Convert boot time from local time to UTC */ - SystemBootTime.QuadPart += ExpTimeZoneBias.QuadPart; + KeBootTime.QuadPart += ExpTimeZoneBias.QuadPart;
/* Convert system time from local time to UTC */ do @@ -78,6 +78,9 @@ SharedUserData->SystemTime.LowPart = CurrentTime.u.LowPart; SharedUserData->SystemTime.High1Time = CurrentTime.u.HighPart; SharedUserData->SystemTime.High2Time = CurrentTime.u.HighPart; + + /* Return success */ + return TRUE; }
NTSTATUS
Modified: trunk/reactos/ntoskrnl/fs/filelock.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fs/filelock.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/fs/filelock.c (original) +++ trunk/reactos/ntoskrnl/fs/filelock.c Sun Oct 8 08:05:27 2006 @@ -77,7 +77,7 @@ */ VOID STDCALL INIT_FUNCTION -FsRtlpInitFileLockingImplementation(VOID) +FsRtlInitSystem(VOID) { ExInitializeNPagedLookasideList( &LockTocLookaside, NULL,
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/c... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cc.h (original) +++ trunk/reactos/ntoskrnl/include/internal/cc.h Sun Oct 8 08:05:27 2006 @@ -112,7 +112,7 @@
VOID NTAPI -CcInit(VOID); +CcInitializeCacheManager(VOID);
NTSTATUS NTAPI
Modified: trunk/reactos/ntoskrnl/include/internal/ex.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/e... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ex.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ex.h Sun Oct 8 08:05:27 2006 @@ -7,6 +7,7 @@ extern LARGE_INTEGER ExpTimeZoneBias; extern ULONG ExpTimeZoneId; extern ULONG ExpTickCountMultiplier; +extern ULONG ExpLastTimeZoneBias; extern POBJECT_TYPE ExEventPairObjectType; extern ULONG NtBuildNumber; extern ULONG NtMajorVersion; @@ -66,9 +67,11 @@ NTAPI ExpInitializePushLocks(VOID);
-VOID -NTAPI -ExpInitTimeZoneInfo(VOID); +BOOLEAN +NTAPI +ExRefreshTimeZoneInformation( + IN PLARGE_INTEGER SystemBootTime +);
VOID NTAPI
Modified: trunk/reactos/ntoskrnl/include/internal/fsrtl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/f... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/fsrtl.h (original) +++ trunk/reactos/ntoskrnl/include/internal/fsrtl.h Sun Oct 8 08:05:27 2006 @@ -22,7 +22,7 @@
VOID NTAPI -FsRtlpInitFileLockingImplementation(VOID); +FsRtlInitSystem(VOID);
VOID NTAPI
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/k... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h Sun Oct 8 08:05:27 2006 @@ -66,7 +66,7 @@ extern PVOID KeUserCallbackDispatcher; extern PVOID KeUserExceptionDispatcher; extern PVOID KeRaiseUserExceptionDispatcher; -extern LARGE_INTEGER SystemBootTime; +extern LARGE_INTEGER KeBootTime; extern ULONG KeI386NpxPresent; extern ULONG KeI386XMMIPresent; extern ULONG KeI386FxsrPresent;
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 Sun Oct 8 08:05:27 2006 @@ -64,13 +64,13 @@ VOID IoInit2(BOOLEAN BootLog); VOID NTAPI IoInit3(VOID); BOOLEAN NTAPI ObInit(VOID); -VOID CmInitializeRegistry(VOID); +VOID NTAPI CmInitSystem1(VOID); VOID NTAPI CmInitHives(BOOLEAN SetupBoot); VOID CmInit2(PCHAR CommandLine); VOID CmShutdownRegistry(VOID); BOOLEAN CmImportSystemHive(PCHAR ChunkBase, ULONG ChunkSize); BOOLEAN CmImportHardwareHive(PCHAR ChunkBase, ULONG ChunkSize); -VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock); +BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
/* FIXME - RtlpCreateUnicodeString is obsolete and should be removed ASAP! */ BOOLEAN FASTCALL
Modified: trunk/reactos/ntoskrnl/kd/kdinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdinit.c?rev=24... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdinit.c (original) +++ trunk/reactos/ntoskrnl/kd/kdinit.c Sun Oct 8 08:05:27 2006 @@ -159,8 +159,9 @@ WrapperTable.KdpInitRoutine(&WrapperTable, BootPhase); }
-VOID +BOOLEAN INIT_FUNCTION +NTAPI KdInitSystem(ULONG BootPhase, PLOADER_PARAMETER_BLOCK LoaderBlock) { @@ -253,11 +254,14 @@
/* Call Wrapper at Phase 0 */ if (WrapperInitRoutine) WrapperInitRoutine(&WrapperTable, 0); - return; + return TRUE; }
/* Call the Initialization Routines of the Registered Providers */ KdpCallInitRoutine(BootPhase); + + /* Return success */ + return TRUE; }
/* EOF */
Modified: trunk/reactos/ntoskrnl/ke/clock.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/clock.c?rev=244... ============================================================================== --- trunk/reactos/ntoskrnl/ke/clock.c (original) +++ trunk/reactos/ntoskrnl/ke/clock.c Sun Oct 8 08:05:27 2006 @@ -26,15 +26,7 @@
/* GLOBALS ****************************************************************/
-/* - * Current time - */ -#if defined(__GNUC__) -LARGE_INTEGER SystemBootTime = (LARGE_INTEGER)0LL; -#else -LARGE_INTEGER SystemBootTime = { 0 }; -#endif - +LARGE_INTEGER KeBootTime, KeBootTimeBias; KDPC KiExpireTimerDpc; BOOLEAN KiClockSetupComplete = FALSE; ULONG KiTimeLimitIsrMicroseconds; @@ -65,28 +57,6 @@ #define CALIBRATE_PERIOD (MICROSECONDS_PER_TICK * TICKS_TO_CALIBRATE)
/* FUNCTIONS **************************************************************/ - -/* - * FUNCTION: Initializes timer irq handling - * NOTE: This is only called once from main() - */ -VOID -INIT_FUNCTION -NTAPI -KiInitializeSystemClock(VOID) -{ - TIME_FIELDS TimeFields; - - /* Calculate the starting time for the system clock */ - HalQueryRealTimeClock(&TimeFields); - RtlTimeFieldsToTime(&TimeFields, &SystemBootTime); - - /* Set up the Used Shared Data */ - SharedUserData->SystemTime.High2Time = SystemBootTime.u.HighPart; - SharedUserData->SystemTime.LowPart = SystemBootTime.u.LowPart; - SharedUserData->SystemTime.High1Time = SystemBootTime.u.HighPart; - KiClockSetupComplete = TRUE; -}
VOID NTAPI @@ -116,7 +86,7 @@ DeltaTime.QuadPart = NewSystemTime->QuadPart - OldSystemTime.QuadPart;
/* Update system boot time */ - SystemBootTime.QuadPart += DeltaTime.QuadPart; + KeBootTime.QuadPart += DeltaTime.QuadPart;
/* Update absolute timers */ DPRINT1("FIXME: TIMER UPDATE NOT DONE!!!\n");