Author: ion
Date: Sun Oct 1 23:27:10 2006
New Revision: 24348
URL:
http://svn.reactos.org/svn/reactos?rev=24348&view=rev
Log:
- Do MmInit1 much earlier in the boot phase (right at the beginning of
ExpInitalizeExecutive). This gives us access to things like SharedUserData, which NT has
since NTLDR. Will try moving it up even higher.
- Also move some ROS-specific/Freeldr hacks on top of the file so they'll be easier to
remove later when needed.
- Fix a bug in ExInitPoolLookasidePointers which was making us overwrite low-memory.
- Initialize NLS tables during Phase 0, so that the associated APIs can work earlier.
- Bugcheck if HAL Phase 0 initialization failed, and force interrupts enabled after the
HAL is ready.
Modified:
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/ex/lookas.c
trunk/reactos/ntoskrnl/ke/freeldr.c
trunk/reactos/ntoskrnl/rtl/nls.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 Sun Oct 1 23:27:10 2006
@@ -49,9 +49,16 @@
VOID
);
+/* Init flags and settings */
ULONG ExpInitializationPhase;
BOOLEAN ExpInTextModeSetup;
BOOLEAN IoRemoteBootClient;
+
+/* Boot NLS information */
+PVOID ExpNlsTableBase;
+ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
+ULONG ExpUnicodeCaseTableDataOffset;
+NLSTABLEINFO ExpNlsTableInfo;
/* FUNCTIONS ****************************************************************/
@@ -244,53 +251,6 @@
__inline
VOID
STDCALL
-ParseAndCacheLoadedModules(VOID)
-{
- ULONG i;
- PCHAR Name;
-
- /* Loop the Module List and get the modules we want */
- for (i = 1; i < KeLoaderModuleCount; i++) {
-
- /* Get the Name of this Module */
- if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\'))) {
-
- /* Save the name */
- Name = (PCHAR)KeLoaderModules[i].String;
-
- } else {
-
- /* No name, skip */
- Name++;
- }
-
- /* Now check for any of the modules we will need later */
- if (!_stricmp(Name, "ansi.nls")) {
-
- CachedModules[AnsiCodepage] = &KeLoaderModules[i];
-
- } else if (!_stricmp(Name, "oem.nls")) {
-
- CachedModules[OemCodepage] = &KeLoaderModules[i];
-
- } else if (!_stricmp(Name, "casemap.nls")) {
-
- CachedModules[UnicodeCasemap] = &KeLoaderModules[i];
-
- } else if (!_stricmp(Name, "system") || !_stricmp(Name,
"system.hiv")) {
-
- CachedModules[SystemRegistry] = &KeLoaderModules[i];
-
- } else if (!_stricmp(Name, "hardware") || !_stricmp(Name,
"hardware.hiv")) {
-
- CachedModules[HardwareRegistry] = &KeLoaderModules[i];
- }
- }
-}
-
-__inline
-VOID
-STDCALL
ParseCommandLine(PULONG MaxMem,
PBOOLEAN NoGuiBoot,
PBOOLEAN BootLog,
@@ -354,7 +314,53 @@
p1 = p2;
}
}
-
+
+VOID
+FORCEINLINE
+ParseAndCacheLoadedModules(VOID)
+{
+ ULONG i;
+ PCHAR Name;
+
+ /* Loop the Module List and get the modules we want */
+ for (i = 1; i < KeLoaderModuleCount; i++)
+ {
+ /* Get the Name of this Module */
+ if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\')))
+ {
+ /* Save the name */
+ Name = (PCHAR)KeLoaderModules[i].String;
+ }
+ else
+ {
+ /* No name, skip */
+ Name++;
+ }
+
+ /* Now check for any of the modules we will need later */
+ if (!_stricmp(Name, "ansi.nls"))
+ {
+ CachedModules[AnsiCodepage] = &KeLoaderModules[i];
+ }
+ else if (!_stricmp(Name, "oem.nls"))
+ {
+ CachedModules[OemCodepage] = &KeLoaderModules[i];
+ }
+ else if (!_stricmp(Name, "casemap.nls"))
+ {
+ CachedModules[UnicodeCasemap] = &KeLoaderModules[i];
+ }
+ else if (!_stricmp(Name, "system") || !_stricmp(Name,
"system.hiv"))
+ {
+ CachedModules[SystemRegistry] = &KeLoaderModules[i];
+ }
+ else if (!_stricmp(Name, "hardware") || !_stricmp(Name,
"hardware.hiv"))
+ {
+ CachedModules[HardwareRegistry] = &KeLoaderModules[i];
+ }
+ }
+}
+
VOID
INIT_FUNCTION
ExpDisplayNotice(VOID)
@@ -506,6 +512,25 @@
ExpInitializeExecutive(IN ULONG Cpu,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
+ PNLS_DATA_BLOCK NlsData;
+
+ /* Initialize Kernel Memory Address Space */
+ MmInit1(FirstKrnlPhysAddr,
+ LastKrnlPhysAddr,
+ LastKernelAddress,
+ (PADDRESS_RANGE)&KeMemoryMap,
+ KeMemoryMapRangeCount,
+ MaxMem > 8 ? MaxMem : 4096);
+
+ /* Sets up the Text Sections of the Kernel and HAL for debugging */
+ LdrInit1();
+
+ /* Parse Command Line Settings */
+ ParseCommandLine(&MaxMem, &NoGuiBoot, &BootLog, &ForceAcpiDisable);
+
+ /* FIXME: Deprecate soon */
+ ParseAndCacheLoadedModules();
+
/* Validate Loader */
if (!ExpIsLoaderValid(LoaderBlock))
{
@@ -558,31 +583,37 @@
/* Set phase to 0 */
ExpInitializationPhase = 0;
- /* Initialize HAL */
- HalInitSystem (0, KeLoaderBlock);
-
- /* Sets up the Text Sections of the Kernel and HAL for debugging */
- LdrInit1();
+ /* Setup NLS Base and offsets */
+ NlsData = LoaderBlock->NlsData;
+ ExpNlsTableBase = NlsData->AnsiCodePageData;
+ ExpAnsiCodePageDataOffset = 0;
+ ExpOemCodePageDataOffset = ((ULONG_PTR)NlsData->OemCodePageData -
+ (ULONG_PTR)NlsData->AnsiCodePageData);
+ ExpUnicodeCaseTableDataOffset = ((ULONG_PTR)NlsData->UnicodeCodePageData -
+ (ULONG_PTR)NlsData->AnsiCodePageData);
+
+ /* Initialize the NLS Tables */
+ RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
+ ExpAnsiCodePageDataOffset),
+ (PVOID)((ULONG_PTR)ExpNlsTableBase +
+ ExpOemCodePageDataOffset),
+ (PVOID)((ULONG_PTR)ExpNlsTableBase +
+ ExpUnicodeCaseTableDataOffset),
+ &ExpNlsTableInfo);
+ RtlResetRtlTranslations(&ExpNlsTableInfo);
+
+ /* Now initialize the HAL */
+ if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
+ {
+ /* HAL failed to initialize, bugcheck */
+ KeBugCheck(HAL_INITIALIZATION_FAILED);
+ }
+
+ /* Make sure interrupts are active now */
+ _enable();
/* Setup bugcheck messages */
KiInitializeBugCheck();
-
- /* Sets up the VDM Data */
- NtEarlyInitVdm();
-
- /* Parse Command Line Settings */
- ParseCommandLine(&MaxMem, &NoGuiBoot, &BootLog, &ForceAcpiDisable);
-
- /* Initialize Kernel Memory Address Space */
- MmInit1(FirstKrnlPhysAddr,
- LastKrnlPhysAddr,
- LastKernelAddress,
- (PADDRESS_RANGE)&KeMemoryMap,
- KeMemoryMapRangeCount,
- MaxMem > 8 ? MaxMem : 4096);
-
- /* Parse the Loaded Modules (by FreeLoader) and cache the ones we'll need */
- ParseAndCacheLoadedModules();
/* Setup system time */
KiInitializeSystemClock();
Modified: trunk/reactos/ntoskrnl/ex/lookas.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/lookas.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/lookas.c (original)
+++ trunk/reactos/ntoskrnl/ex/lookas.c Sun Oct 1 23:27:10 2006
@@ -24,8 +24,8 @@
KSPIN_LOCK ExpNonPagedLookasideListLock;
LIST_ENTRY ExpPagedLookasideListHead;
KSPIN_LOCK ExpPagedLookasideListLock;
-PNPAGED_LOOKASIDE_LIST ExpSmallNPagedPoolLookasideLists;
-PPAGED_LOOKASIDE_LIST ExpSmallPagedPoolLookasideLists;
+NPAGED_LOOKASIDE_LIST ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS];
+PAGED_LOOKASIDE_LIST ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS];
/* FUNCTIONS *****************************************************************/
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c Sun Oct 1 23:27:10 2006
@@ -431,6 +431,9 @@
(PVOID)DriverBase,
&DriverSize);
+ /* Sets up the VDM Data */
+ NtEarlyInitVdm();
+
/* Convert the loader block */
KiRosFrldrLpbToNtLpb(&KeRosLoaderBlock, &NtLoaderBlock);
Modified: trunk/reactos/ntoskrnl/rtl/nls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/nls.c?rev=243…
==============================================================================
--- trunk/reactos/ntoskrnl/rtl/nls.c (original)
+++ trunk/reactos/ntoskrnl/rtl/nls.c Sun Oct 1 23:27:10 2006
@@ -64,9 +64,6 @@
RtlpImportUnicodeCasemap((PUSHORT)BaseAddress,
CachedModules[UnicodeCasemap]->ModEnd - BaseAddress);
- /* Create initial NLS tables */
- RtlpCreateInitialNlsTables();
-
/* Create the NLS section */
RtlpCreateNlsSection();
}
@@ -101,29 +98,6 @@
{
NlsUnicodeCasemapTable = TableBase;
NlsUnicodeCasemapTableSize = Size;
-}
-
-
-VOID
-NTAPI
-INIT_FUNCTION
-RtlpCreateInitialNlsTables(VOID)
-{
- NLSTABLEINFO NlsTable;
-
- if (NlsAnsiCodePageTable == NULL || NlsAnsiCodePageTableSize == 0 ||
- NlsOemCodePageTable == NULL || NlsOemCodePageTableSize == 0 ||
- NlsUnicodeCasemapTable == NULL || NlsUnicodeCasemapTableSize == 0)
- {
- KEBUGCHECKEX (0x32, STATUS_UNSUCCESSFUL, 1, 0, 0);
- }
-
- RtlInitNlsTables (NlsAnsiCodePageTable,
- NlsOemCodePageTable,
- NlsUnicodeCasemapTable,
- &NlsTable);
-
- RtlResetRtlTranslations (&NlsTable);
}
VOID