Author: ion
Date: Mon Oct 2 19:52:58 2006
New Revision: 24363
URL:
http://svn.reactos.org/svn/reactos?rev=24363&view=rev
Log:
- 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.
Modified:
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/ex/time.c
trunk/reactos/ntoskrnl/include/internal/ex.h
trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
trunk/reactos/ntoskrnl/include/internal/ps.h
trunk/reactos/ntoskrnl/include/internal/se.h
trunk/reactos/ntoskrnl/ps/psmgr.c
trunk/reactos/ntoskrnl/se/semgr.c
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=243…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c (original)
+++ trunk/reactos/ntoskrnl/ex/init.c Mon Oct 2 19:52:58 2006
@@ -367,6 +367,38 @@
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,11 +606,11 @@
/* 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;
@@ -611,10 +643,7 @@
*/
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 @@
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 @@
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
/* Initialize the Process Manager */
- PspInitPhase0();
-
- /* Break into the Debugger if requested */
- if (KdPollBreakIn()) DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
-
- /* Initialize all processors */
- HalAllProcessorsStarted();
-
- /* Do Phase 1 HAL Initialization */
- HalInitSystem(1, KeLoaderBlock);
+ if (!PsInitSystem()) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED);
+
+ /* Calculate the tick count multiplier */
+ ExpTickCountMultiplier = ExComputeTickCountMultiplier(KeMaximumIncrement);
+ SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
+
+ /* Set the OS Version */
+ SharedUserData->NtMajorVersion = NtMajorVersion;
+ SharedUserData->NtMinorVersion = NtMinorVersion;
+
+ /* 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
@@ -697,6 +735,15 @@
/* 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();
Modified: trunk/reactos/ntoskrnl/ex/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/time.c?rev=243…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/time.c (original)
+++ trunk/reactos/ntoskrnl/ex/time.c Mon Oct 2 19:52:58 2006
@@ -25,6 +25,7 @@
TIME_ZONE_INFORMATION ExpTimeZoneInfo;
LARGE_INTEGER ExpTimeZoneBias;
ULONG ExpTimeZoneId;
+ULONG ExpTickCountMultiplier;
/* FUNCTIONS ****************************************************************/
Modified: trunk/reactos/ntoskrnl/include/internal/ex.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ex.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ex.h Mon Oct 2 19:52:58 2006
@@ -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;
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h Mon Oct 2 19:52:58 2006
@@ -64,7 +64,6 @@
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);
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ps.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h Mon Oct 2 19:52:58 2006
@@ -81,7 +81,7 @@
BOOLEAN
NTAPI
-PspInitPhase0(
+PsInitSystem(
VOID
);
Modified: trunk/reactos/ntoskrnl/include/internal/se.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/se.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/se.h Mon Oct 2 19:52:58 2006
@@ -86,11 +86,7 @@
/* Functions */
BOOLEAN
NTAPI
-SeInit1(VOID);
-
-BOOLEAN
-NTAPI
-SeInit2(VOID);
+SeInit(VOID);
BOOLEAN
NTAPI
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/psmgr.c?rev=24…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/psmgr.c (original)
+++ trunk/reactos/ntoskrnl/ps/psmgr.c Mon Oct 2 19:52:58 2006
@@ -397,6 +397,14 @@
return TRUE;
}
+BOOLEAN
+NTAPI
+PsInitSystem(VOID)
+{
+ /* For now, do only Phase 0 */
+ return PspInitPhase0();
+}
+
/* PUBLIC FUNCTIONS **********************************************************/
/*
Modified: trunk/reactos/ntoskrnl/se/semgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/semgr.c?rev=24…
==============================================================================
--- trunk/reactos/ntoskrnl/se/semgr.c (original)
+++ trunk/reactos/ntoskrnl/se/semgr.c Mon Oct 2 19:52:58 2006
@@ -27,8 +27,7 @@
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 @@
BOOLEAN
INIT_FUNCTION
NTAPI
-SeInit1(VOID)
+SeInit(VOID)
{
SepInitLuid();
@@ -58,29 +57,19 @@
/* 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