- 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();
}
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
NTAPI
ExpInitSystemPhase0(VOID)
@ -574,12 +606,12 @@ ExpInitializeExecutive(IN ULONG Cpu,
/* Setup system time */
KiInitializeSystemClock();
/* Initialize the second stage of the kernel */
KeInit2();
/* Initialize the executive at phase 0 */
if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED);
/* Break into the Debugger if requested */
if (KdPollBreakIn()) DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
/* Set system ranges */
SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
@ -611,10 +643,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
*/
ExpNlsTableSize += 2 * PAGE_SIZE; // BIAS FOR FREELDR. HACK!
/*
* Allocate the table in pool memory, so we can stop depending on the
* memory given to use by the loader, which is freed later.
*/
/* Allocate the NLS buffer in the pool since loader memory will be freed */
ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool,
ExpNlsTableSize,
TAG('R', 't', 'l', 'i'));
@ -661,8 +690,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
/* Load basic Security for other Managers */
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
if (!SeInit()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
/* Set up Region Maps, Sections and the Paging File */
MmInit2();
@ -671,16 +699,26 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
/* Initialize the Process Manager */
PspInitPhase0();
if (!PsInitSystem()) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED);
/* Break into the Debugger if requested */
if (KdPollBreakIn()) DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
/* Calculate the tick count multiplier */
ExpTickCountMultiplier = ExComputeTickCountMultiplier(KeMaximumIncrement);
SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
/* Initialize all processors */
HalAllProcessorsStarted();
/* Set the OS Version */
SharedUserData->NtMajorVersion = NtMajorVersion;
SharedUserData->NtMinorVersion = NtMinorVersion;
/* Do Phase 1 HAL Initialization */
HalInitSystem(1, KeLoaderBlock);
/* Set the machine type */
#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
@ -698,6 +736,15 @@ ExPhase2Init(PVOID Context)
/* Set us at maximum 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 */
ExInit3();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,8 +27,7 @@ static ERESOURCE SepSubjectContextLock;
static BOOLEAN SepInitExports(VOID);
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, SeInit1)
#pragma alloc_text(INIT, SeInit2)
#pragma alloc_text(INIT, SeInit)
#pragma alloc_text(INIT, SepInitExports)
#endif
@ -37,7 +36,7 @@ static BOOLEAN SepInitExports(VOID);
BOOLEAN
INIT_FUNCTION
NTAPI
SeInit1(VOID)
SeInit(VOID)
{
SepInitLuid();
@ -58,30 +57,20 @@ SeInit1(VOID)
/* Initialize the subject context lock */
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;
}
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
NTAPI
SeInitSRM(VOID)