- 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.

svn path=/trunk/; revision=24438
This commit is contained in:
Alex Ionescu 2006-10-08 04:05:27 +00:00
parent 9088db842e
commit 4b00ba5d4d
13 changed files with 93 additions and 76 deletions

View file

@ -18,7 +18,7 @@
VOID
NTAPI
CcInit(VOID)
CcInitializeCacheManager(VOID)
{
CcInitView();
}

View file

@ -188,7 +188,8 @@ CmInitHives(BOOLEAN SetupBoot)
VOID
INIT_FUNCTION
CmInitializeRegistry(VOID)
NTAPI
CmInitSystem1(VOID)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;

View file

@ -15,6 +15,9 @@
/* DATA **********************************************************************/
/* HACK */
extern BOOLEAN KiClockSetupComplete;
#define BUILD_OSCSDVERSION(major, minor) (((major & 0xFF) << 8) | (minor & 0xFF))
/* NT Version Info */
@ -858,6 +861,8 @@ ExPhase2Init(PVOID Context)
HANDLE ProcessHandle;
HANDLE ThreadHandle;
NTSTATUS Status;
TIME_FIELDS TimeFields;
LARGE_INTEGER SystemBootTime, UniversalBootTime;
/* Set to phase 1 */
ExpInitializationPhase = 1;
@ -868,54 +873,88 @@ ExPhase2Init(PVOID Context)
/* 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 the File System Runtime Library */
FsRtlInitSystem();
/* Initialize File Locking */
FsRtlpInitFileLockingImplementation();
/* Report all resources used by hal */
/* 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();
@ -931,9 +970,6 @@ ExPhase2Init(PVOID Context)
/* 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)
DbgBreakPoint();
@ -953,7 +989,7 @@ ExPhase2Init(PVOID Context)
/* 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 */

View file

@ -548,7 +548,7 @@ QSI_DEF(SystemTimeOfDayInformation)
KeQuerySystemTime(&CurrentTime);
Sti->BootTime= SystemBootTime;
Sti->BootTime= KeBootTime;
Sti->CurrentTime = CurrentTime;
Sti->TimeZoneBias.QuadPart = ExpTimeZoneBias.QuadPart;
Sti->TimeZoneId = ExpTimeZoneId;

View file

@ -23,16 +23,16 @@
/* Note: Bias[minutes] = UTC - local time */
TIME_ZONE_INFORMATION ExpTimeZoneInfo;
ULONG ExpLastTimeZoneBias = -1;
LARGE_INTEGER ExpTimeZoneBias;
ULONG ExpTimeZoneId;
ULONG ExpTickCountMultiplier;
/* FUNCTIONS ****************************************************************/
VOID
INIT_FUNCTION
BOOLEAN
NTAPI
ExpInitTimeZoneInfo(VOID)
ExRefreshTimeZoneInformation(IN PLARGE_INTEGER CurrentBootTime)
{
LARGE_INTEGER CurrentTime;
NTSTATUS Status;
@ -64,7 +64,7 @@ ExpInitTimeZoneInfo(VOID)
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 @@ ExpInitTimeZoneInfo(VOID)
SharedUserData->SystemTime.LowPart = CurrentTime.u.LowPart;
SharedUserData->SystemTime.High1Time = CurrentTime.u.HighPart;
SharedUserData->SystemTime.High2Time = CurrentTime.u.HighPart;
/* Return success */
return TRUE;
}
NTSTATUS

View file

@ -77,7 +77,7 @@ IsSurroundingLock(
*/
VOID
STDCALL INIT_FUNCTION
FsRtlpInitFileLockingImplementation(VOID)
FsRtlInitSystem(VOID)
{
ExInitializeNPagedLookasideList( &LockTocLookaside,
NULL,

View file

@ -112,7 +112,7 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
VOID
NTAPI
CcInit(VOID);
CcInitializeCacheManager(VOID);
NTSTATUS
NTAPI

View file

@ -7,6 +7,7 @@ extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
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 @@ VOID
NTAPI
ExpInitializePushLocks(VOID);
VOID
BOOLEAN
NTAPI
ExpInitTimeZoneInfo(VOID);
ExRefreshTimeZoneInformation(
IN PLARGE_INTEGER SystemBootTime
);
VOID
NTAPI

View file

@ -22,7 +22,7 @@ FsRtlpInitNotifyImplementation(VOID);
VOID
NTAPI
FsRtlpInitFileLockingImplementation(VOID);
FsRtlInitSystem(VOID);
VOID
NTAPI

View file

@ -66,7 +66,7 @@ extern PVOID KeUserApcDispatcher;
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;

View file

@ -64,13 +64,13 @@ VOID IoInit(VOID);
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

View file

@ -159,8 +159,9 @@ KdpCallInitRoutine(ULONG BootPhase)
WrapperTable.KdpInitRoutine(&WrapperTable, BootPhase);
}
VOID
BOOLEAN
INIT_FUNCTION
NTAPI
KdInitSystem(ULONG BootPhase,
PLOADER_PARAMETER_BLOCK LoaderBlock)
{
@ -253,11 +254,14 @@ KdInitSystem(ULONG BootPhase,
/* 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 */

View file

@ -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;
@ -66,28 +58,6 @@ ULONG KeTimeAdjustment = 100000;
/* 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
KiSetSystemTime(PLARGE_INTEGER NewSystemTime)
@ -116,7 +86,7 @@ KiSetSystemTime(PLARGE_INTEGER NewSystemTime)
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");