mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Allocate a separate memory area for the kmap area.
- Changed the free block list for the non paged pool from a double linked list to an avl tree which is sorted by sizes. svn path=/trunk/; revision=5002
This commit is contained in:
parent
4ac70b6bbb
commit
89b0516273
5 changed files with 906 additions and 337 deletions
|
@ -198,7 +198,7 @@ NTSTATUS MmCreateMemoryArea(struct _EPROCESS* Process,
|
|||
MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID Address);
|
||||
NTSTATUS MmInitMemoryAreas(VOID);
|
||||
VOID ExInitNonPagedPool(ULONG BaseAddress);
|
||||
VOID MiInitializeNonPagedPool(VOID);
|
||||
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID BaseAddress,
|
||||
ULONG Length,
|
||||
|
@ -333,7 +333,7 @@ VOID MmInit2(VOID);
|
|||
VOID MmInit3(VOID);
|
||||
NTSTATUS MmInitPagerThread(VOID);
|
||||
|
||||
VOID MmInitKernelMap(PVOID BaseAddress);
|
||||
VOID MiInitKernelMap(VOID);
|
||||
NTSTATUS MmCreatePageTable(PVOID PAddress);
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -19,10 +19,12 @@ extern PVOID MmPagedPoolBase;
|
|||
extern ULONG MmPagedPoolSize;
|
||||
|
||||
#define MM_PAGED_POOL_SIZE (100*1024*1024)
|
||||
#define MM_NONPAGED_POOL_SIZE (100*1024*1024)
|
||||
|
||||
/*
|
||||
* Maximum size of the kmalloc area (this is totally arbitary)
|
||||
*/
|
||||
#define NONPAGED_POOL_SIZE (100*1024*1024)
|
||||
#define MM_KERNEL_MAP_SIZE (16*1024*1024)
|
||||
|
||||
|
||||
#endif /* __INTERNAL_POOL_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: kmap.c,v 1.24 2003/06/19 19:01:01 gvg Exp $
|
||||
/* $Id: kmap.c,v 1.25 2003/07/05 18:10:50 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -20,18 +20,19 @@
|
|||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
#define ALLOC_MAP_SIZE (NONPAGED_POOL_SIZE / PAGE_SIZE)
|
||||
#define ALLOC_MAP_SIZE (MM_KERNEL_MAP_SIZE / PAGE_SIZE)
|
||||
|
||||
/*
|
||||
* One bit for each page in the kmalloc region
|
||||
* If set then the page is used by a kmalloc block
|
||||
*/
|
||||
static UCHAR AllocMapBuffer[ROUND_UP(ALLOC_MAP_SIZE, 8) / 8];
|
||||
static UCHAR AllocMapBuffer[ROUND_UP(ALLOC_MAP_SIZE, 32) / 8];
|
||||
static RTL_BITMAP AllocMap;
|
||||
static KSPIN_LOCK AllocMapLock;
|
||||
static ULONG AllocMapHint = 0;
|
||||
|
||||
static PVOID NonPagedPoolBase;
|
||||
extern PVOID MiKernelMapStart;
|
||||
extern ULONG MiKernelMapLength;
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
|
@ -39,7 +40,7 @@ VOID
|
|||
ExUnmapPage(PVOID Addr)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
ULONG Base = (Addr - NonPagedPoolBase) / PAGE_SIZE;
|
||||
ULONG Base = (Addr - MiKernelMapStart) / PAGE_SIZE;
|
||||
|
||||
DPRINT("ExUnmapPage(Addr %x)\n",Addr);
|
||||
|
||||
|
@ -109,12 +110,12 @@ ExAllocatePageWithPhysPage(PHYSICAL_ADDRESS PhysPage)
|
|||
{
|
||||
AllocMapHint = Base + 1;
|
||||
KeReleaseSpinLock(&AllocMapLock, oldlvl);
|
||||
Addr = NonPagedPoolBase + Base * PAGE_SIZE;
|
||||
Addr = MiKernelMapStart + Base * PAGE_SIZE;
|
||||
Status = MmCreateVirtualMapping(NULL,
|
||||
Addr,
|
||||
PAGE_READWRITE | PAGE_SYSTEM,
|
||||
PhysPage,
|
||||
FALSE);
|
||||
TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Unable to create virtual mapping\n");
|
||||
|
@ -127,19 +128,18 @@ ExAllocatePageWithPhysPage(PHYSICAL_ADDRESS PhysPage)
|
|||
}
|
||||
|
||||
VOID
|
||||
MmInitKernelMap(PVOID BaseAddress)
|
||||
MiInitKernelMap(VOID)
|
||||
{
|
||||
NonPagedPoolBase = BaseAddress;
|
||||
KeInitializeSpinLock(&AllocMapLock);
|
||||
RtlInitializeBitMap(&AllocMap, (PVOID)&AllocMapBuffer, ALLOC_MAP_SIZE);
|
||||
RtlClearAllBits(&AllocMap);
|
||||
}
|
||||
|
||||
#if 0
|
||||
VOID
|
||||
MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
|
||||
{
|
||||
ULONG i;
|
||||
ULONG Base = (Addr - NonPagedPoolBase) / PAGE_SIZE;
|
||||
ULONG Base = (Addr - MiKernelMapStart) / PAGE_SIZE;
|
||||
KIRQL oldlvl;
|
||||
|
||||
for (i = 0; i < Count; i++)
|
||||
|
@ -178,5 +178,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
|
|||
}
|
||||
KeReleaseSpinLock(&AllocMapLock, oldlvl);
|
||||
DPRINT("returning %x\n",NonPagedPoolBase + Base * PAGE_SIZE);
|
||||
return NonPagedPoolBase + Base * PAGE_SIZE;
|
||||
return MiKernelMapStart + Base * PAGE_SIZE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mminit.c,v 1.49 2003/06/19 19:01:01 gvg Exp $
|
||||
/* $Id: mminit.c,v 1.50 2003/07/05 18:10:50 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -42,14 +42,21 @@ static MM_SYSTEM_SIZE MmSystemSize = MmSmallSystem;
|
|||
extern unsigned int _bss_end__;
|
||||
|
||||
static MEMORY_AREA* kernel_text_desc = NULL;
|
||||
static MEMORY_AREA* kernel_map_desc = NULL;
|
||||
static MEMORY_AREA* kernel_data_desc = NULL;
|
||||
static MEMORY_AREA* kernel_param_desc = NULL;
|
||||
static MEMORY_AREA* kernel_pool_desc = NULL;
|
||||
static MEMORY_AREA* kernel_shared_data_desc = NULL;
|
||||
static MEMORY_AREA* MiKernelMapDescriptor = NULL;
|
||||
static MEMORY_AREA* MiPagedPoolDescriptor = NULL;
|
||||
|
||||
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
|
||||
|
||||
PVOID MiNonPagedPoolStart;
|
||||
ULONG MiNonPagedPoolLength;
|
||||
PVOID MiKernelMapStart;
|
||||
ULONG MiKernelMapLength;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
BOOLEAN STDCALL MmIsThisAnNtAsSystem(VOID)
|
||||
|
@ -86,11 +93,35 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
|
|||
LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
|
||||
|
||||
MmInitMemoryAreas();
|
||||
ExInitNonPagedPool(LastKernelAddress + PAGE_SIZE);
|
||||
|
||||
/* Don't change the start of kernel map. Pte's must always exist for this region. */
|
||||
MiKernelMapStart = (PVOID)LastKernelAddress + PAGE_SIZE;
|
||||
MiKernelMapLength = MM_KERNEL_MAP_SIZE;
|
||||
|
||||
MiNonPagedPoolStart = MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
|
||||
MiNonPagedPoolLength = MM_NONPAGED_POOL_SIZE;
|
||||
|
||||
MmPagedPoolBase = MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
|
||||
MmPagedPoolSize = MM_PAGED_POOL_SIZE;
|
||||
|
||||
|
||||
MiInitKernelMap();
|
||||
MiInitializeNonPagedPool();
|
||||
|
||||
/*
|
||||
* Setup the system area descriptor list
|
||||
*/
|
||||
BaseAddress = (PVOID)0xf0000000;
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
0x400000,
|
||||
0,
|
||||
&kernel_map_desc,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
BaseAddress = (PVOID)KERNEL_BASE;
|
||||
Length = PAGE_ROUND_UP(((ULONG)&_text_end__)) - KERNEL_BASE;
|
||||
ParamLength = ParamLength - Length;
|
||||
|
@ -108,7 +139,6 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
|
|||
&kernel_text_desc,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
Length = PAGE_ROUND_UP(((ULONG)&_bss_end__)) -
|
||||
PAGE_ROUND_UP(((ULONG)&_text_end__));
|
||||
ParamLength = ParamLength - Length;
|
||||
|
@ -131,7 +161,6 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
|
|||
FALSE);
|
||||
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&_bss_end__));
|
||||
// Length = ParamLength;
|
||||
Length = LastKernelAddress - (ULONG)BaseAddress;
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
|
@ -143,32 +172,39 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
|
|||
FALSE,
|
||||
FALSE);
|
||||
|
||||
BaseAddress = (PVOID)(LastKernelAddress + PAGE_SIZE);
|
||||
Length = NONPAGED_POOL_SIZE;
|
||||
BaseAddress = MiNonPagedPoolStart;
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
MiNonPagedPoolLength,
|
||||
0,
|
||||
&kernel_pool_desc,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
MmPagedPoolSize = MM_PAGED_POOL_SIZE;
|
||||
BaseAddress = (PVOID)(LastKernelAddress + PAGE_SIZE + NONPAGED_POOL_SIZE +
|
||||
PAGE_SIZE);
|
||||
MmPagedPoolBase = BaseAddress;
|
||||
Length = MM_PAGED_POOL_SIZE;
|
||||
MmCreateMemoryArea(NULL,
|
||||
BaseAddress = MiKernelMapStart;
|
||||
Status = MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
MiKernelMapLength,
|
||||
0,
|
||||
&MiKernelMapDescriptor,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
BaseAddress = MmPagedPoolBase;
|
||||
Status = MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_PAGED_POOL,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
MmPagedPoolSize,
|
||||
0,
|
||||
&MiPagedPoolDescriptor,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
MmInitializePagedPool();
|
||||
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue