mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
- Implement Phase 0 Ex initialization (Resource, Lookaside initialization) and generic Ex initialization routine.
- Clear the crypto exponent on boot-up. - Set default global flags for checked builds. - Set NtSystemRoot (SharedUserData) to C:<NT BOOT PATH> on startup. - Cleanup lookas.c file and implement routines to initialize the system lookaside list in phase 0. svn path=/trunk/; revision=24360
This commit is contained in:
parent
526efd2ee7
commit
afa1de7c81
4 changed files with 208 additions and 62 deletions
|
@ -22,7 +22,8 @@ ULONG NtMajorVersion = 5;
|
|||
ULONG NtMinorVersion = 0;
|
||||
ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(4, 0);
|
||||
ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
|
||||
ULONG NtGlobalFlag = 0;
|
||||
ULONG NtGlobalFlag;
|
||||
ULONG ExSuiteMask;
|
||||
|
||||
extern ULONG MmCoreDumpType;
|
||||
extern LOADER_MODULE KeLoaderModules[64];
|
||||
|
@ -36,6 +37,9 @@ BOOLEAN ExpInTextModeSetup;
|
|||
BOOLEAN IoRemoteBootClient;
|
||||
ULONG InitSafeBootMode;
|
||||
|
||||
/* NT Boot Path */
|
||||
UNICODE_STRING NtSystemRoot;
|
||||
|
||||
/* Boot NLS information */
|
||||
PVOID ExpNlsTableBase;
|
||||
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
||||
|
@ -348,14 +352,6 @@ ExpLoadInitialProcess(PHANDLE ProcessHandle,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExInit2(VOID)
|
||||
{
|
||||
ExpInitLookasideLists();
|
||||
ExpInitializeHandleTables();
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExInit3(VOID)
|
||||
|
@ -371,6 +367,61 @@ ExInit3(VOID)
|
|||
ExpInitUuids();
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ExpInitSystemPhase0(VOID)
|
||||
{
|
||||
/* Initialize EXRESOURCE Support */
|
||||
ExpResourceInitialization();
|
||||
|
||||
/* Initialize the environment lock */
|
||||
ExInitializeFastMutex(&ExpEnvironmentLock);
|
||||
|
||||
/* Initialize the lookaside lists and locks */
|
||||
ExpInitLookasideLists();
|
||||
|
||||
/* Initialize the Firmware Table resource and listhead */
|
||||
InitializeListHead(&ExpFirmwareTableProviderListHead);
|
||||
ExInitializeResourceLite(&ExpFirmwareTableResource);
|
||||
|
||||
/* Set the suite mask to maximum and return */
|
||||
ExSuiteMask = 0xFFFFFFFF;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ExpInitSystemPhase1(VOID)
|
||||
{
|
||||
/* Not yet done */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ExInitSystem(VOID)
|
||||
{
|
||||
/* Check the initialization phase */
|
||||
switch (ExpInitializationPhase)
|
||||
{
|
||||
case 0:
|
||||
|
||||
/* Do Phase 0 */
|
||||
return ExpInitSystemPhase0();
|
||||
|
||||
case 1:
|
||||
|
||||
/* Do Phase 1 */
|
||||
return ExpInitSystemPhase1();
|
||||
|
||||
default:
|
||||
|
||||
/* Don't know any other phase! Bugcheck! */
|
||||
KeBugCheck(UNEXPECTED_INITIALIZATION_CALL);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
|
@ -402,6 +453,9 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
PNLS_DATA_BLOCK NlsData;
|
||||
CHAR Buffer[256];
|
||||
ANSI_STRING AnsiPath;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* FIXME: Deprecate soon */
|
||||
ParseAndCacheLoadedModules();
|
||||
|
@ -487,6 +541,31 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
/* Make sure interrupts are active now */
|
||||
_enable();
|
||||
|
||||
/* Clear the crypto exponent */
|
||||
SharedUserData->CryptoExponent = 0;
|
||||
|
||||
/* Set global flags for the checked build */
|
||||
#if DBG
|
||||
NtGlobalFlag |= FLG_ENABLE_CLOSE_EXCEPTIONS |
|
||||
FLG_ENABLE_KDEBUG_SYMBOL_LOAD;
|
||||
#endif
|
||||
|
||||
/* Setup NT System Root Path */
|
||||
sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
|
||||
|
||||
/* Convert to ANSI_STRING and null-terminate it */
|
||||
RtlInitString(&AnsiPath, Buffer );
|
||||
Buffer[--AnsiPath.Length] = UNICODE_NULL;
|
||||
|
||||
/* Get the string from KUSER_SHARED_DATA's buffer */
|
||||
NtSystemRoot.Buffer = SharedUserData->NtSystemRoot;
|
||||
NtSystemRoot.MaximumLength = sizeof(SharedUserData->NtSystemRoot) / sizeof(WCHAR);
|
||||
NtSystemRoot.Length = 0;
|
||||
|
||||
/* Now fill it in */
|
||||
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
|
||||
if (!NT_SUCCESS(Status)) KEBUGCHECK(SESSION3_INITIALIZATION_FAILED);
|
||||
|
||||
/* Setup bugcheck messages */
|
||||
KiInitializeBugCheck();
|
||||
|
||||
|
@ -496,14 +575,14 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
/* Initialize the second stage of the kernel */
|
||||
KeInit2();
|
||||
|
||||
/* Initialize resources */
|
||||
ExpResourceInitialization();
|
||||
/* Initialize the executive at phase 0 */
|
||||
if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED);
|
||||
|
||||
/* Load basic Security for other Managers */
|
||||
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
|
||||
|
||||
/* Initialize Lookaside Lists and Handle Table */
|
||||
ExInit2();
|
||||
/* Initialize the Handle Table */
|
||||
ExpInitializeHandleTables();
|
||||
|
||||
/* Create the Basic Object Manager Types to allow new Object Types */
|
||||
ObInit();
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ex/lookas.c
|
||||
* PURPOSE: Lookaside lists
|
||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||
* David Welch (welch@mcmail.com)
|
||||
* Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
*/
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/ex/lookas.c
|
||||
* PURPOSE: Lookaside Lists
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
#include <debug.h>
|
||||
|
||||
#if defined (ALLOC_PRAGMA)
|
||||
#pragma alloc_text(INIT, ExpInitLookasideLists)
|
||||
|
@ -24,10 +22,41 @@ LIST_ENTRY ExpNonPagedLookasideListHead;
|
|||
KSPIN_LOCK ExpNonPagedLookasideListLock;
|
||||
LIST_ENTRY ExpPagedLookasideListHead;
|
||||
KSPIN_LOCK ExpPagedLookasideListLock;
|
||||
LIST_ENTRY ExSystemLookasideListHead;
|
||||
LIST_ENTRY ExPoolLookasideListHead;
|
||||
NPAGED_LOOKASIDE_LIST ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS];
|
||||
PAGED_LOOKASIDE_LIST ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS];
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExInitializeSystemLookasideList(IN PGENERAL_LOOKASIDE List,
|
||||
IN POOL_TYPE Type,
|
||||
IN ULONG Size,
|
||||
IN ULONG Tag,
|
||||
IN USHORT MaximumDepth,
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
/* Initialize the list */
|
||||
List->Tag = Tag;
|
||||
List->Type = Type;
|
||||
List->Size = Size;
|
||||
InsertHeadList(ListHead, &List->ListEntry);
|
||||
List->MaximumDepth = MaximumDepth;
|
||||
List->Depth = 2;
|
||||
List->Allocate = ExAllocatePoolWithTag;
|
||||
List->Free = ExFreePool;
|
||||
List->ListHead.Next.Next = NULL;
|
||||
List->ListHead.Depth = 0;
|
||||
List->ListHead.Sequence = 0;
|
||||
List->TotalAllocates = 0;
|
||||
List->AllocateHits = 0;
|
||||
List->TotalFrees = 0;
|
||||
List->FreeHits = 0;
|
||||
List->LastTotalAllocates = 0;
|
||||
List->LastAllocateHits = 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -60,23 +89,49 @@ ExInitPoolLookasidePointers(VOID)
|
|||
Entry->P = &PagedListEntry->L;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
STDCALL
|
||||
NTAPI
|
||||
ExpInitLookasideLists()
|
||||
{
|
||||
/* Initialize Lock and Listhead */
|
||||
ULONG i, j;
|
||||
|
||||
/* Initialize locks and lists */
|
||||
InitializeListHead(&ExpNonPagedLookasideListHead);
|
||||
KeInitializeSpinLock(&ExpNonPagedLookasideListLock);
|
||||
InitializeListHead(&ExpPagedLookasideListHead);
|
||||
InitializeListHead(&ExSystemLookasideListHead);
|
||||
InitializeListHead(&ExPoolLookasideListHead);
|
||||
KeInitializeSpinLock(&ExpNonPagedLookasideListLock);
|
||||
KeInitializeSpinLock(&ExpPagedLookasideListLock);
|
||||
|
||||
/* Initialize the system lookaside lists */
|
||||
for (i = 0, j = 1; i < (MAXIMUM_PROCESSORS - 1); j++, i++)
|
||||
{
|
||||
/* Initialize the non-paged list */
|
||||
ExInitializeSystemLookasideList(&ExpSmallNPagedPoolLookasideLists[i].L,
|
||||
NonPagedPool,
|
||||
j * 8,
|
||||
TAG('P', 'o', 'o', 'l'),
|
||||
256,
|
||||
&ExPoolLookasideListHead);
|
||||
|
||||
/* Initialize the paged list */
|
||||
ExInitializeSystemLookasideList(&ExpSmallPagedPoolLookasideLists[i].L,
|
||||
PagedPool,
|
||||
j * 8,
|
||||
TAG('P', 'o', 'o', 'l'),
|
||||
256,
|
||||
&ExPoolLookasideListHead);
|
||||
}
|
||||
}
|
||||
|
||||
/* PUBLIC FUNCTIONS **********************************************************/
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
PVOID
|
||||
STDCALL
|
||||
NTAPI
|
||||
ExiAllocateFromPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside)
|
||||
{
|
||||
PVOID Entry;
|
||||
|
@ -87,7 +142,7 @@ ExiAllocateFromPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside)
|
|||
{
|
||||
Lookaside->L.AllocateMisses++;
|
||||
Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
|
||||
Lookaside->L.Size,
|
||||
Lookaside->L.Size,
|
||||
Lookaside->L.Tag);
|
||||
}
|
||||
return Entry;
|
||||
|
@ -97,7 +152,7 @@ ExiAllocateFromPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside)
|
|||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
NTAPI
|
||||
ExiFreeToPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside,
|
||||
IN PVOID Entry)
|
||||
{
|
||||
|
@ -117,21 +172,20 @@ ExiFreeToPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside,
|
|||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside)
|
||||
NTAPI
|
||||
ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
PVOID Entry;
|
||||
|
||||
/* Pop all entries off the stack and release the resources allocated
|
||||
for them */
|
||||
/* Pop all entries off the stack and release their resources */
|
||||
for (;;)
|
||||
{
|
||||
Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
|
||||
if (!Entry) break;
|
||||
(*Lookaside->L.Free)(Entry);
|
||||
}
|
||||
|
||||
|
||||
/* Remove from list */
|
||||
KeAcquireSpinLock(&ExpNonPagedLookasideListLock, &OldIrql);
|
||||
RemoveEntryList(&Lookaside->L.ListEntry);
|
||||
|
@ -142,21 +196,20 @@ ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside)
|
|||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside)
|
||||
NTAPI
|
||||
ExDeletePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
PVOID Entry;
|
||||
|
||||
/* Pop all entries off the stack and release the resources allocated
|
||||
for them */
|
||||
/* Pop all entries off the stack and release their resources */
|
||||
for (;;)
|
||||
{
|
||||
Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
|
||||
if (!Entry) break;
|
||||
(*Lookaside->L.Free)(Entry);
|
||||
}
|
||||
|
||||
|
||||
/* Remove from list */
|
||||
KeAcquireSpinLock(&ExpPagedLookasideListLock, &OldIrql);
|
||||
RemoveEntryList(&Lookaside->L.ListEntry);
|
||||
|
@ -167,17 +220,15 @@ ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside)
|
|||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
|
||||
PALLOCATE_FUNCTION Allocate,
|
||||
PFREE_FUNCTION Free,
|
||||
ULONG Flags,
|
||||
ULONG Size,
|
||||
ULONG Tag,
|
||||
USHORT Depth)
|
||||
NTAPI
|
||||
ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside,
|
||||
IN PALLOCATE_FUNCTION Allocate OPTIONAL,
|
||||
IN PFREE_FUNCTION Free OPTIONAL,
|
||||
IN ULONG Flags,
|
||||
IN ULONG Size,
|
||||
IN ULONG Tag,
|
||||
IN USHORT Depth)
|
||||
{
|
||||
DPRINT("Initializing nonpaged lookaside list at 0x%p\n", Lookaside);
|
||||
|
||||
/* Initialize the Header */
|
||||
ExInitializeSListHead(&Lookaside->L.ListHead);
|
||||
Lookaside->L.TotalAllocates = 0;
|
||||
|
@ -221,17 +272,15 @@ ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
|
|||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
ExInitializePagedLookasideList (PPAGED_LOOKASIDE_LIST Lookaside,
|
||||
PALLOCATE_FUNCTION Allocate,
|
||||
PFREE_FUNCTION Free,
|
||||
ULONG Flags,
|
||||
ULONG Size,
|
||||
ULONG Tag,
|
||||
USHORT Depth)
|
||||
NTAPI
|
||||
ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside,
|
||||
IN PALLOCATE_FUNCTION Allocate OPTIONAL,
|
||||
IN PFREE_FUNCTION Free OPTIONAL,
|
||||
IN ULONG Flags,
|
||||
IN ULONG Size,
|
||||
IN ULONG Tag,
|
||||
IN USHORT Depth)
|
||||
{
|
||||
DPRINT("Initializing paged lookaside list at 0x%p\n", Lookaside);
|
||||
|
||||
/* Initialize the Header */
|
||||
ExInitializeSListHead(&Lookaside->L.ListHead);
|
||||
Lookaside->L.TotalAllocates = 0;
|
||||
|
@ -264,7 +313,7 @@ ExInitializePagedLookasideList (PPAGED_LOOKASIDE_LIST Lookaside,
|
|||
{
|
||||
Lookaside->L.Free = ExFreePool;
|
||||
}
|
||||
|
||||
|
||||
/* Insert it into the list */
|
||||
ExInterlockedInsertTailList(&ExpNonPagedLookasideListHead,
|
||||
&Lookaside->L.ListEntry,
|
||||
|
|
|
@ -21,6 +21,10 @@ ULONGLONG STDCALL KeQueryInterruptTime(VOID);
|
|||
|
||||
VOID MmPrintMemoryStatistic(VOID);
|
||||
|
||||
FAST_MUTEX ExpEnvironmentLock;
|
||||
ERESOURCE ExpFirmwareTableResource;
|
||||
LIST_ENTRY ExpFirmwareTableProviderListHead;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/*
|
||||
|
|
|
@ -10,6 +10,9 @@ extern POBJECT_TYPE ExEventPairObjectType;
|
|||
extern ULONG NtBuildNumber;
|
||||
extern ULONG NtMajorVersion;
|
||||
extern ULONG NtMinorVersion;
|
||||
extern FAST_MUTEX ExpEnvironmentLock;
|
||||
extern ERESOURCE ExpFirmwareTableResource;
|
||||
extern LIST_ENTRY ExpFirmwareTableProviderListHead;
|
||||
|
||||
#define MAX_FAST_REFS 7
|
||||
|
||||
|
@ -66,6 +69,17 @@ VOID
|
|||
NTAPI
|
||||
ExpInitLookasideLists(VOID);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExInitializeSystemLookasideList(
|
||||
IN PGENERAL_LOOKASIDE List,
|
||||
IN POOL_TYPE Type,
|
||||
IN ULONG Size,
|
||||
IN ULONG Tag,
|
||||
IN USHORT MaximumDepth,
|
||||
IN PLIST_ENTRY ListHead
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExpInitializeCallbacks(VOID);
|
||||
|
|
Loading…
Reference in a new issue