- Combine SeInit1 and SeInit2 into SeInit since both can be done together now.

- Call PsInitSystem instead of PspInitPhase0, since PsInitsystem is the "external" phase-choosing routine.
- Implement ExComputeTickCountMultiplier to create a 24-bit precision remainder + whole integer of the ms/clock tick used in SharedUserData.
- Set the OS version and Machine Type (i386/PPC (<3 Arty) in SharedUserData.
- Move some HAL calls in Phase 2 (actually Phase 1...), same for KeInit2.
- Break into KDBG a bit earlier.

svn path=/trunk/; revision=24363
This commit is contained in:
Alex Ionescu 2006-10-02 15:52:58 +00:00
parent 06142d4e0d
commit 04c5f92621
8 changed files with 88 additions and 47 deletions

View file

@ -367,6 +367,38 @@ ExInit3(VOID)
ExpInitUuids(); ExpInitUuids();
} }
ULONG
NTAPI
ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
{
ULONG MsRemainder = 0, MsIncrement;
ULONG IncrementRemainder;
ULONG i;
/* Count the number of milliseconds for each clock interrupt */
MsIncrement = ClockIncrement / (10 * 1000);
/* Count the remainder from the division above, with 24-bit precision */
IncrementRemainder = ClockIncrement - (MsIncrement * (10 * 1000));
for (i= 0; i < 24; i++)
{
/* Shift the remainders */
MsRemainder <<= 1;
IncrementRemainder <<= 1;
/* Check if we've went past 1 ms */
if (IncrementRemainder >= (10 * 1000))
{
/* Increase the remainder by one, and substract from increment */
IncrementRemainder -= (10 * 1000);
MsRemainder |= 1;
}
}
/* Return the increment */
return (MsIncrement << 24) | MsRemainder;
}
BOOLEAN BOOLEAN
NTAPI NTAPI
ExpInitSystemPhase0(VOID) ExpInitSystemPhase0(VOID)
@ -574,12 +606,12 @@ ExpInitializeExecutive(IN ULONG Cpu,
/* Setup system time */ /* Setup system time */
KiInitializeSystemClock(); KiInitializeSystemClock();
/* Initialize the second stage of the kernel */
KeInit2();
/* Initialize the executive at phase 0 */ /* Initialize the executive at phase 0 */
if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED); if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED);
/* Break into the Debugger if requested */
if (KdPollBreakIn()) DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
/* Set system ranges */ /* Set system ranges */
SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress; SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart; SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
@ -611,10 +643,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
*/ */
ExpNlsTableSize += 2 * PAGE_SIZE; // BIAS FOR FREELDR. HACK! ExpNlsTableSize += 2 * PAGE_SIZE; // BIAS FOR FREELDR. HACK!
/* /* Allocate the NLS buffer in the pool since loader memory will be freed */
* Allocate the table in pool memory, so we can stop depending on the
* memory given to use by the loader, which is freed later.
*/
ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool, ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool,
ExpNlsTableSize, ExpNlsTableSize,
TAG('R', 't', 'l', 'i')); TAG('R', 't', 'l', 'i'));
@ -661,8 +690,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED); if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
/* Load basic Security for other Managers */ /* Load basic Security for other Managers */
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED); if (!SeInit()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
/* Set up Region Maps, Sections and the Paging File */ /* Set up Region Maps, Sections and the Paging File */
MmInit2(); MmInit2();
@ -671,16 +699,26 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED); if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
/* Initialize the Process Manager */ /* Initialize the Process Manager */
PspInitPhase0(); if (!PsInitSystem()) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED);
/* Break into the Debugger if requested */ /* Calculate the tick count multiplier */
if (KdPollBreakIn()) DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C); ExpTickCountMultiplier = ExComputeTickCountMultiplier(KeMaximumIncrement);
SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
/* Initialize all processors */ /* Set the OS Version */
HalAllProcessorsStarted(); SharedUserData->NtMajorVersion = NtMajorVersion;
SharedUserData->NtMinorVersion = NtMinorVersion;
/* Do Phase 1 HAL Initialization */ /* Set the machine type */
HalInitSystem(1, KeLoaderBlock); #if defined(_X86_)
SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_I386;
SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_I386;
#elif defined(_PPC_) // <3 Arty
SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_POWERPC;
SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_POWERPC;
#elif
#error "Unsupported ReactOS Target"
#endif
} }
VOID VOID
@ -698,6 +736,15 @@ ExPhase2Init(PVOID Context)
/* Set us at maximum priority */ /* Set us at maximum priority */
KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY); KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY);
/* Initialize the second stage of the kernel */
KeInit2();
/* Initialize all processors */
HalAllProcessorsStarted();
/* Do Phase 1 HAL Initialization */
HalInitSystem(1, KeLoaderBlock);
/* Initialize Basic System Objects and Worker Threads */ /* Initialize Basic System Objects and Worker Threads */
ExInit3(); ExInit3();

View file

@ -25,6 +25,7 @@
TIME_ZONE_INFORMATION ExpTimeZoneInfo; TIME_ZONE_INFORMATION ExpTimeZoneInfo;
LARGE_INTEGER ExpTimeZoneBias; LARGE_INTEGER ExpTimeZoneBias;
ULONG ExpTimeZoneId; ULONG ExpTimeZoneId;
ULONG ExpTickCountMultiplier;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/

View file

@ -6,6 +6,7 @@
extern TIME_ZONE_INFORMATION ExpTimeZoneInfo; extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
extern LARGE_INTEGER ExpTimeZoneBias; extern LARGE_INTEGER ExpTimeZoneBias;
extern ULONG ExpTimeZoneId; extern ULONG ExpTimeZoneId;
extern ULONG ExpTickCountMultiplier;
extern POBJECT_TYPE ExEventPairObjectType; extern POBJECT_TYPE ExEventPairObjectType;
extern ULONG NtBuildNumber; extern ULONG NtBuildNumber;
extern ULONG NtMajorVersion; extern ULONG NtMajorVersion;

View file

@ -64,7 +64,6 @@ VOID IoInit(VOID);
VOID IoInit2(BOOLEAN BootLog); VOID IoInit2(BOOLEAN BootLog);
VOID NTAPI IoInit3(VOID); VOID NTAPI IoInit3(VOID);
BOOLEAN NTAPI ObInit(VOID); BOOLEAN NTAPI ObInit(VOID);
VOID PsInit(VOID);
VOID CmInitializeRegistry(VOID); VOID CmInitializeRegistry(VOID);
VOID NTAPI CmInitHives(BOOLEAN SetupBoot); VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
VOID CmInit2(PCHAR CommandLine); VOID CmInit2(PCHAR CommandLine);

View file

@ -81,7 +81,7 @@ PspShutdownProcessManager(
BOOLEAN BOOLEAN
NTAPI NTAPI
PspInitPhase0( PsInitSystem(
VOID VOID
); );

View file

@ -86,11 +86,7 @@ extern PSECURITY_DESCRIPTOR SeUnrestrictedSd;
/* Functions */ /* Functions */
BOOLEAN BOOLEAN
NTAPI NTAPI
SeInit1(VOID); SeInit(VOID);
BOOLEAN
NTAPI
SeInit2(VOID);
BOOLEAN BOOLEAN
NTAPI NTAPI

View file

@ -397,6 +397,14 @@ PspInitPhase0(VOID)
return TRUE; return TRUE;
} }
BOOLEAN
NTAPI
PsInitSystem(VOID)
{
/* For now, do only Phase 0 */
return PspInitPhase0();
}
/* PUBLIC FUNCTIONS **********************************************************/ /* PUBLIC FUNCTIONS **********************************************************/
/* /*

View file

@ -27,8 +27,7 @@ static ERESOURCE SepSubjectContextLock;
static BOOLEAN SepInitExports(VOID); static BOOLEAN SepInitExports(VOID);
#if defined (ALLOC_PRAGMA) #if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, SeInit1) #pragma alloc_text(INIT, SeInit)
#pragma alloc_text(INIT, SeInit2)
#pragma alloc_text(INIT, SepInitExports) #pragma alloc_text(INIT, SepInitExports)
#endif #endif
@ -37,7 +36,7 @@ static BOOLEAN SepInitExports(VOID);
BOOLEAN BOOLEAN
INIT_FUNCTION INIT_FUNCTION
NTAPI NTAPI
SeInit1(VOID) SeInit(VOID)
{ {
SepInitLuid(); SepInitLuid();
@ -58,30 +57,20 @@ SeInit1(VOID)
/* Initialize the subject context lock */ /* Initialize the subject context lock */
ExInitializeResource(&SepSubjectContextLock); ExInitializeResource(&SepSubjectContextLock);
/* Initialize token objects */
SepInitializeTokenImplementation();
/* Clear impersonation info for the idle thread */
PsGetCurrentThread()->ImpersonationInfo = NULL;
PspClearCrossThreadFlag(PsGetCurrentThread(), CT_ACTIVE_IMPERSONATION_INFO_BIT);
/* Initailize the boot token */
ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL);
ObInitializeFastReference(&PsGetCurrentProcess()->Token,
SepCreateSystemProcessToken());
return TRUE; return TRUE;
} }
BOOLEAN
INIT_FUNCTION
NTAPI
SeInit2(VOID)
{
/* Initialize token objects */
SepInitializeTokenImplementation();
/* Clear impersonation info for the idle thread */
PsGetCurrentThread()->ImpersonationInfo = NULL;
PspClearCrossThreadFlag(PsGetCurrentThread(), CT_ACTIVE_IMPERSONATION_INFO_BIT);
/* Initailize the boot token */
ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL);
ObInitializeFastReference(&PsGetCurrentProcess()->Token,
SepCreateSystemProcessToken());
return TRUE;
}
BOOLEAN BOOLEAN
NTAPI NTAPI
SeInitSRM(VOID) SeInitSRM(VOID)