From f29743948c5010b25b72ae23b4616c1665b95820 Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Sun, 21 Jun 2009 05:46:50 +0000 Subject: [PATCH] - Introduce a new MEMORY_AREA flag, MEMORY_AREA_STATIC: - MEMORY_AREA structures are typically allocated from nonpaged pool, under the assumption it exists. - However, nonpaged pool itself is described by a MEMORY_AREA. Right now, this MEMORY_AREA is created after nonpaged pool has been initialized (it is a miracle this works). - This new flag allows MEMORY_AREA structures to be allocated statically, allowing the description of certain system address space components, themselves prerequisites to nonpaged pool creation, as well as the nonpaged pool component itself, before nonpaged pool has been initialized. - This is not yet used. svn path=/trunk/; revision=41509 --- reactos/ntoskrnl/include/internal/mm.h | 3 +++ reactos/ntoskrnl/mm/marea.c | 28 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 75fd0e5ce7d..cf9a02ee0ae 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -29,6 +29,8 @@ struct _MM_PAGEOP; typedef ULONG SWAPENTRY; typedef ULONG PFN_TYPE, *PPFN_TYPE; +#define MI_STATIC_MEMORY_AREAS (1) + #define MEMORY_AREA_INVALID (0) #define MEMORY_AREA_SECTION_VIEW (1) #define MEMORY_AREA_CONTINUOUS_MEMORY (2) @@ -43,6 +45,7 @@ typedef ULONG PFN_TYPE, *PPFN_TYPE; #define MEMORY_AREA_PAGED_POOL (12) #define MEMORY_AREA_NO_ACCESS (13) #define MEMORY_AREA_PEB_OR_TEB (14) +#define MEMORY_AREA_STATIC (0x80000000) #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8) diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 131225f0eb0..5fe30972862 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -49,6 +49,9 @@ #pragma alloc_text(INIT, MmInitMemoryAreas) #endif +MEMORY_AREA MiStaticMemoryAreas[MI_STATIC_MEMORY_AREAS]; +ULONG MiStaticMemoryAreaCount; + /* #define VALIDATE_MEMORY_AREAS */ /* FUNCTIONS *****************************************************************/ @@ -986,9 +989,28 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace, return STATUS_CONFLICTING_ADDRESSES; } } - - MemoryArea = ExAllocatePoolWithTag(NonPagedPool, sizeof(MEMORY_AREA), - TAG_MAREA); + + // + // Is this a static memory area? + // + if (Type & MEMORY_AREA_STATIC) + { + // + // Use the static array instead of the pool + // + ASSERT(MiStaticMemoryAreaCount < MI_STATIC_MEMORY_AREAS); + MemoryArea = &MiStaticMemoryAreas[MiStaticMemoryAreaCount++]; + } + else + { + // + // Allocate the memory area from nonpaged pool + // + MemoryArea = ExAllocatePoolWithTag(NonPagedPool, + sizeof(MEMORY_AREA), + TAG_MAREA); + } + RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA)); MemoryArea->Type = Type; MemoryArea->StartingAddress = *BaseAddress;