Author: ros-arm-bringup Date: Sun Jul 27 20:49:23 2008 New Revision: 34881
URL: http://svn.reactos.org/svn/reactos?rev=34881&view=rev Log: Now that MADDRESS_SPACE became nearly an empty structure pointing only at the root, it can completely go away. Now VadRoot really is a MM_AVL_TABLE structure. The BalancedRoot.u1.Parent now points to what used to be MemoryAreaRoot. This isn't really the most proper fix out there -- the problem is that React starts with an no root, while Windows starts with an empty balanced root. So for now we keep doing it the React way, which means we have about 10 ugly typecast hacks. On the other hand, we got rid of more than 100 of them.
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/anonmem.c trunk/reactos/ntoskrnl/mm/aspace.c trunk/reactos/ntoskrnl/mm/i386/page.c trunk/reactos/ntoskrnl/mm/marea.c trunk/reactos/ntoskrnl/mm/mdlsup.c trunk/reactos/ntoskrnl/mm/mm.c trunk/reactos/ntoskrnl/mm/procsup.c trunk/reactos/ntoskrnl/mm/region.c trunk/reactos/ntoskrnl/mm/rmap.c trunk/reactos/ntoskrnl/mm/section.c trunk/reactos/ntoskrnl/mm/virtual.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/m... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -249,11 +249,6 @@ } VirtualMemoryData; } Data; } MEMORY_AREA, *PMEMORY_AREA; - -typedef struct _MADDRESS_SPACE -{ - PMEMORY_AREA MemoryAreaRoot; -} MADDRESS_SPACE, *PMADDRESS_SPACE;
typedef struct { @@ -367,7 +362,7 @@
typedef VOID (*PMM_ALTER_REGION_FUNC)( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, ULONG Length, ULONG OldType, @@ -386,22 +381,6 @@ BOOLEAN Dirty );
-/* aspace.c ******************************************************************/ - -VOID -NTAPI -MmInitializeKernelAddressSpace(VOID); - -NTSTATUS -NTAPI -MmInitializeAddressSpace( - struct _EPROCESS* Process, - PMADDRESS_SPACE AddressSpace); - -NTSTATUS -NTAPI -MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace); - /* marea.c *******************************************************************/
NTSTATUS @@ -411,7 +390,7 @@ NTSTATUS NTAPI MmCreateMemoryArea( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, ULONG Type, PVOID *BaseAddress, ULONG_PTR Length, @@ -425,21 +404,21 @@ PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID Address );
ULONG_PTR NTAPI MmFindGapAtAddress( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID Address );
NTSTATUS NTAPI MmFreeMemoryArea( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext @@ -448,7 +427,7 @@ NTSTATUS NTAPI MmFreeMemoryAreaByPtr( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext @@ -456,12 +435,12 @@
VOID NTAPI -MmDumpMemoryAreas(PMADDRESS_SPACE AddressSpace); +MmDumpMemoryAreas(PMM_AVL_TABLE AddressSpace);
PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID Address, ULONG_PTR Length ); @@ -469,7 +448,7 @@ PVOID NTAPI MmFindGap( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity, BOOLEAN TopDown @@ -479,7 +458,7 @@ NTAPI MmReleaseMemoryAreaIfDecommitted( struct _EPROCESS *Process, - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID BaseAddress );
@@ -745,7 +724,7 @@ NTSTATUS NTAPI MmNotPresentFaultVirtualMemory( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked @@ -754,7 +733,7 @@ NTSTATUS NTAPI MmPageOutVirtualMemory( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, struct _MM_PAGEOP* PageOp @@ -779,7 +758,7 @@ NTSTATUS NTAPI MmProtectAnonMem( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID BaseAddress, ULONG Length, @@ -790,7 +769,7 @@ NTSTATUS NTAPI MmWritePageVirtualMemory( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MArea, PVOID Address, PMM_PAGEOP PageOp @@ -1360,7 +1339,7 @@ NTSTATUS NTAPI MmAlterRegion( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID StartAddress, @@ -1428,7 +1407,7 @@ NTSTATUS NTAPI MmProtectSectionView( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID BaseAddress, ULONG Length, @@ -1439,7 +1418,7 @@ NTSTATUS NTAPI MmWritePageSectionView( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MArea, PVOID Address, PMM_PAGEOP PageOp @@ -1452,7 +1431,7 @@ NTSTATUS NTAPI MmNotPresentFaultSectionView( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked @@ -1461,7 +1440,7 @@ NTSTATUS NTAPI MmPageOutSectionView( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, struct _MM_PAGEOP *PageOp @@ -1474,7 +1453,7 @@ NTSTATUS NTAPI MmAccessFaultSectionView( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked @@ -1568,39 +1547,39 @@ }
-extern PMADDRESS_SPACE MmKernelAddressSpace; +extern PMM_AVL_TABLE MmKernelAddressSpace;
FORCEINLINE VOID -MmLockAddressSpace(PMADDRESS_SPACE AddressSpace) +MmLockAddressSpace(PMM_AVL_TABLE AddressSpace) { KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot)->AddressCreationLock); }
FORCEINLINE VOID -MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace) +MmUnlockAddressSpace(PMM_AVL_TABLE AddressSpace) { KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot)->AddressCreationLock); }
FORCEINLINE PEPROCESS -MmGetAddressSpaceOwner(IN PMADDRESS_SPACE AddressSpace) +MmGetAddressSpaceOwner(IN PMM_AVL_TABLE AddressSpace) { if (AddressSpace == MmKernelAddressSpace) return NULL; return CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot); }
FORCEINLINE -PMADDRESS_SPACE +PMM_AVL_TABLE MmGetCurrentAddressSpace(VOID) { - return (PMADDRESS_SPACE)&((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->VadRoot; + return &((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->VadRoot; }
FORCEINLINE -PMADDRESS_SPACE +PMM_AVL_TABLE MmGetKernelAddressSpace(VOID) { return MmKernelAddressSpace;
Modified: trunk/reactos/ntoskrnl/mm/anonmem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/anonmem.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -47,7 +47,7 @@
NTSTATUS NTAPI -MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, +MmWritePageVirtualMemory(PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, PMM_PAGEOP PageOp) @@ -130,7 +130,7 @@
NTSTATUS NTAPI -MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, +MmPageOutVirtualMemory(PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, PMM_PAGEOP PageOp) @@ -239,7 +239,7 @@
NTSTATUS NTAPI -MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, +MmNotPresentFaultVirtualMemory(PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked) @@ -437,7 +437,7 @@ }
VOID static -MmModifyAttributes(PMADDRESS_SPACE AddressSpace, +MmModifyAttributes(PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, ULONG RegionSize, ULONG OldType, @@ -553,7 +553,7 @@ ULONG_PTR MemoryAreaLength; ULONG Type; NTSTATUS Status; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; PVOID BaseAddress; ULONG RegionSize; PVOID PBaseAddress; @@ -704,7 +704,7 @@ Type = (AllocationType & MEM_COMMIT) ? MEM_COMMIT : MEM_RESERVE; DPRINT("Type %x\n", Type);
- AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + AddressSpace = &Process->VadRoot; MmLockAddressSpace(AddressSpace);
if (PBaseAddress != 0) @@ -861,7 +861,7 @@ if (PageOp != NULL) { NTSTATUS Status; - MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmUnlockAddressSpace(&Process->VadRoot); Status = KeWaitForSingleObject(&PageOp->CompletionEvent, 0, KernelMode, @@ -872,7 +872,7 @@ DPRINT1("Failed to wait for page op\n"); KEBUGCHECK(0); } - MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmLockAddressSpace(&Process->VadRoot); MmReleasePageOp(PageOp); } } @@ -888,7 +888,7 @@ }
/* Actually free the memory area. */ - MmFreeMemoryArea((PMADDRESS_SPACE)&Process->VadRoot, + MmFreeMemoryArea(&Process->VadRoot, MemoryArea, MmFreeVirtualMemoryPage, (PVOID)Process); @@ -918,7 +918,7 @@ MEMORY_AREA* MemoryArea; NTSTATUS Status; PEPROCESS Process; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; PVOID BaseAddress; ULONG RegionSize;
@@ -941,7 +941,7 @@ return(Status); }
- AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + AddressSpace = &Process->VadRoot;
MmLockAddressSpace(AddressSpace); MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, BaseAddress); @@ -991,7 +991,7 @@
NTSTATUS NTAPI -MmProtectAnonMem(PMADDRESS_SPACE AddressSpace, +MmProtectAnonMem(PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID BaseAddress, ULONG Length,
Modified: trunk/reactos/ntoskrnl/mm/aspace.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/aspace.c?rev=34... ============================================================================== --- trunk/reactos/ntoskrnl/mm/aspace.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/aspace.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -19,27 +19,9 @@
/* GLOBALS ******************************************************************/
-PMADDRESS_SPACE MmKernelAddressSpace; - -ULONGLONG Cycles; -ULONG TimeDelta; +PMM_AVL_TABLE MmKernelAddressSpace;
/* FUNCTIONS *****************************************************************/
-NTSTATUS -NTAPI -MmInitializeAddressSpace(PEPROCESS Process, - PMADDRESS_SPACE AddressSpace) -{ - AddressSpace->MemoryAreaRoot = NULL; - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace) -{ - return STATUS_SUCCESS; -}
/* EOF */
Modified: trunk/reactos/ntoskrnl/mm/i386/page.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/i386/page.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/mm/i386/page.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/i386/page.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -197,7 +197,7 @@
/* Initialize the Addresss Space */ KeInitializeGuardedMutex(&Process->AddressCreationLock); - MmInitializeAddressSpace(Process, (PMADDRESS_SPACE)&Process->VadRoot); + Process->VadRoot.BalancedRoot.u1.Parent = NULL;
/* The process now has an address space */ Process->HasAddressSpace = TRUE;
Modified: trunk/reactos/ntoskrnl/mm/marea.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=348... ============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -160,18 +160,18 @@ }
#ifdef VALIDATE_MEMORY_AREAS -static VOID MmVerifyMemoryAreas(PMADDRESS_SPACE AddressSpace) +static VOID MmVerifyMemoryAreas(PMM_AVL_TABLE AddressSpace) { PMEMORY_AREA Node;
ASSERT(AddressSpace != NULL);
/* Special case for empty tree. */ - if (AddressSpace->MemoryAreaRoot == NULL) + if (AddressSpace->BalancedRoot.u1.Parent == NULL) return;
/* Traverse the tree from left to right. */ - for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot); + for (Node = MmIterateFirstNode(AddressSpace->BalancedRoot.u1.Parent); Node != NULL; Node = MmIterateNextNode(Node)) { @@ -186,18 +186,18 @@ #endif
VOID STDCALL -MmDumpMemoryAreas(PMADDRESS_SPACE AddressSpace) +MmDumpMemoryAreas(PMM_AVL_TABLE AddressSpace) { PMEMORY_AREA Node;
DbgPrint("MmDumpMemoryAreas()\n");
/* Special case for empty tree. */ - if (AddressSpace->MemoryAreaRoot == NULL) + if (AddressSpace->BalancedRoot.u1.Parent == NULL) return;
/* Traverse the tree from left to right. */ - for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot); + for (Node = MmIterateFirstNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent); Node != NULL; Node = MmIterateNextNode(Node)) { @@ -211,10 +211,10 @@
PMEMORY_AREA STDCALL MmLocateMemoryAreaByAddress( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID Address) { - PMEMORY_AREA Node = AddressSpace->MemoryAreaRoot; + PMEMORY_AREA Node = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent;
DPRINT("MmLocateMemoryAreaByAddress(AddressSpace %p, Address %p)\n", AddressSpace, Address); @@ -241,7 +241,7 @@
PMEMORY_AREA STDCALL MmLocateMemoryAreaByRegion( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID Address, ULONG_PTR Length) { @@ -251,11 +251,11 @@ MmVerifyMemoryAreas(AddressSpace);
/* Special case for empty tree. */ - if (AddressSpace->MemoryAreaRoot == NULL) + if (AddressSpace->BalancedRoot.u1.Parent == NULL) return NULL;
/* Traverse the tree from left to right. */ - for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot); + for (Node = MmIterateFirstNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent); Node != NULL; Node = MmIterateNextNode(Node)) { @@ -302,11 +302,11 @@
static VOID MmCompressHelper( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, ULONG Count) { PMEMORY_AREA Root = NULL; - PMEMORY_AREA Red = AddressSpace->MemoryAreaRoot; + PMEMORY_AREA Red = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent; PMEMORY_AREA Black = Red->LeftChild;
while (Count--) @@ -314,7 +314,7 @@ if (Root) Root->LeftChild = Black; else - AddressSpace->MemoryAreaRoot = Black; + AddressSpace->BalancedRoot.u1.Parent = (PVOID)Black; Black->Parent = Root; Red->LeftChild = Black->RightChild; if (Black->RightChild) @@ -341,7 +341,7 @@
static VOID MmRebalanceTree( - PMADDRESS_SPACE AddressSpace) + PMM_AVL_TABLE AddressSpace) { PMEMORY_AREA PreviousNode; PMEMORY_AREA CurrentNode; @@ -354,7 +354,7 @@ /* Transform the tree into Vine. */
PreviousNode = NULL; - CurrentNode = AddressSpace->MemoryAreaRoot; + CurrentNode = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent; while (CurrentNode != NULL) { if (CurrentNode->RightChild == NULL) @@ -379,7 +379,7 @@ if (PreviousNode != NULL) PreviousNode->LeftChild = TempNode; else - AddressSpace->MemoryAreaRoot = TempNode; + AddressSpace->BalancedRoot.u1.Parent = (PVOID)TempNode; TempNode->Parent = PreviousNode; } } @@ -410,7 +410,7 @@
static VOID MmInsertMemoryArea( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA marea) { PMEMORY_AREA Node; @@ -419,14 +419,14 @@
MmVerifyMemoryAreas(AddressSpace);
- if (AddressSpace->MemoryAreaRoot == NULL) - { - AddressSpace->MemoryAreaRoot = marea; + if (AddressSpace->BalancedRoot.u1.Parent == NULL) + { + AddressSpace->BalancedRoot.u1.Parent = (PVOID)marea; marea->LeftChild = marea->RightChild = marea->Parent = NULL; return; }
- Node = AddressSpace->MemoryAreaRoot; + Node = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent; do { DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n", @@ -466,7 +466,7 @@
static PVOID MmFindGapBottomUp( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity) { @@ -486,7 +486,7 @@ AlignedAddress = MM_ROUND_UP(LowestAddress, Granularity);
/* Special case for empty tree. */ - if (AddressSpace->MemoryAreaRoot == NULL) + if (AddressSpace->BalancedRoot.u1.Parent == NULL) { if ((ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length) { @@ -498,7 +498,7 @@ }
/* Go to the node with lowest address in the tree. */ - FirstNode = Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot); + FirstNode = Node = MmIterateFirstNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent);
/* Traverse the tree from left to right. */ PreviousNode = Node; @@ -544,7 +544,7 @@
static PVOID MmFindGapTopDown( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity) { @@ -567,7 +567,7 @@ return NULL;
/* Special case for empty tree. */ - if (AddressSpace->MemoryAreaRoot == NULL) + if (AddressSpace->BalancedRoot.u1.Parent == NULL) { if (AlignedAddress >= LowestAddress) { @@ -579,7 +579,7 @@ }
/* Go to the node with highest address in the tree. */ - Node = MmIterateLastNode(AddressSpace->MemoryAreaRoot); + Node = MmIterateLastNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent);
/* Check if there is enough space after the last memory area. */ if (Node->EndingAddress <= AlignedAddress) @@ -630,7 +630,7 @@
PVOID STDCALL MmFindGap( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity, BOOLEAN TopDown) @@ -643,10 +643,10 @@
ULONG_PTR STDCALL MmFindGapAtAddress( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID Address) { - PMEMORY_AREA Node = AddressSpace->MemoryAreaRoot; + PMEMORY_AREA Node = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent; PMEMORY_AREA RightNeighbour = NULL; PVOID LowestAddress = MmGetAddressSpaceOwner(AddressSpace) ? MM_LOWEST_USER_ADDRESS : MmSystemRangeStart; PVOID HighestAddress = MmGetAddressSpaceOwner(AddressSpace) ? @@ -740,7 +740,7 @@
NTSTATUS STDCALL MmFreeMemoryArea( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext) @@ -804,7 +804,7 @@ ParentReplace = &MemoryArea->Parent->RightChild; } else - ParentReplace = &AddressSpace->MemoryAreaRoot; + ParentReplace = (PMEMORY_AREA*)&AddressSpace->BalancedRoot.u1.Parent;
if (MemoryArea->RightChild == NULL) { @@ -882,7 +882,7 @@
NTSTATUS STDCALL MmFreeMemoryAreaByPtr( - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext) @@ -933,7 +933,7 @@ */
NTSTATUS STDCALL -MmCreateMemoryArea(PMADDRESS_SPACE AddressSpace, +MmCreateMemoryArea(PMM_AVL_TABLE AddressSpace, ULONG Type, PVOID *BaseAddress, ULONG_PTR Length, @@ -1059,7 +1059,7 @@
VOID STDCALL MmReleaseMemoryAreaIfDecommitted(PEPROCESS Process, - PMADDRESS_SPACE AddressSpace, + PMM_AVL_TABLE AddressSpace, PVOID BaseAddress) { PMEMORY_AREA MemoryArea;
Modified: trunk/reactos/ntoskrnl/mm/mdlsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mdlsup.c?rev=34... ============================================================================== --- trunk/reactos/ntoskrnl/mm/mdlsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/mdlsup.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -366,12 +366,12 @@ ASSERT(Mdl->Process == PsGetCurrentProcess());
/* Find the memory area */ - MemoryArea = MmLocateMemoryAreaByAddress((PMADDRESS_SPACE)&(Mdl->Process)->VadRoot, + MemoryArea = MmLocateMemoryAreaByAddress(&Mdl->Process->VadRoot, BaseAddress); ASSERT(MemoryArea);
/* Free it */ - MmFreeMemoryArea((PMADDRESS_SPACE)&(Mdl->Process)->VadRoot, + MmFreeMemoryArea(&Mdl->Process->VadRoot, MemoryArea, NULL, NULL); @@ -395,7 +395,7 @@ PFN_TYPE Page; PEPROCESS CurrentProcess; PETHREAD Thread; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; DPRINT("Probing MDL: %p\n", Mdl);
/* Sanity checks */ @@ -479,7 +479,7 @@ Mdl->Process = CurrentProcess;
/* Use the process lock */ - AddressSpace = (PMADDRESS_SPACE)&(CurrentProcess)->VadRoot; + AddressSpace = &CurrentProcess->VadRoot; }
@@ -732,8 +732,8 @@
CurrentProcess = PsGetCurrentProcess();
- MmLockAddressSpace((PMADDRESS_SPACE)&CurrentProcess->VadRoot); - Status = MmCreateMemoryArea((PMADDRESS_SPACE)&CurrentProcess->VadRoot, + MmLockAddressSpace(&CurrentProcess->VadRoot); + Status = MmCreateMemoryArea(&CurrentProcess->VadRoot, MEMORY_AREA_MDL_MAPPING, &Base, PageCount * PAGE_SIZE, @@ -742,7 +742,7 @@ (Base != NULL), 0, BoundaryAddressMultiple); - MmUnlockAddressSpace((PMADDRESS_SPACE)&CurrentProcess->VadRoot); + MmUnlockAddressSpace(&CurrentProcess->VadRoot); if (!NT_SUCCESS(Status)) { if (Mdl->MdlFlags & MDL_MAPPING_CAN_FAIL)
Modified: trunk/reactos/ntoskrnl/mm/mm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mm.c?rev=34881&... ============================================================================== --- trunk/reactos/ntoskrnl/mm/mm.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/mm.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -48,7 +48,7 @@ */ { MEMORY_AREA* MemoryArea; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace;
if (VirtualAddress >= MmSystemRangeStart) { @@ -56,7 +56,7 @@ } else { - AddressSpace = (PMADDRESS_SPACE)&(PsGetCurrentProcess())->VadRoot; + AddressSpace = &PsGetCurrentProcess()->VadRoot; }
MmLockAddressSpace(AddressSpace); @@ -78,7 +78,7 @@ ULONG_PTR Address, BOOLEAN FromMdl) { - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; MEMORY_AREA* MemoryArea; NTSTATUS Status; BOOLEAN Locked = FromMdl; @@ -114,7 +114,7 @@ } else { - AddressSpace = (PMADDRESS_SPACE)&(PsGetCurrentProcess())->VadRoot; + AddressSpace = &PsGetCurrentProcess()->VadRoot; }
if (!FromMdl) @@ -179,7 +179,7 @@ ULONG_PTR Address, BOOLEAN FromMdl) { - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; MEMORY_AREA* MemoryArea; NTSTATUS Status; BOOLEAN Locked = FromMdl; @@ -210,7 +210,7 @@ } else { - AddressSpace = (PMADDRESS_SPACE)&(PsGetCurrentProcess())->VadRoot; + AddressSpace = &PsGetCurrentProcess()->VadRoot; }
if (!FromMdl)
Modified: trunk/reactos/ntoskrnl/mm/procsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/procsup.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/mm/procsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/procsup.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -80,7 +80,7 @@ PVOID BaseAddress) { NTSTATUS Status; - PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot; PMEMORY_AREA MemoryArea; PHYSICAL_ADDRESS BoundaryAddressMultiple; PVOID AllocatedBase = BaseAddress; @@ -161,7 +161,7 @@ MmDeleteTeb(PEPROCESS Process, PTEB Teb) { - PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot; PMEMORY_AREA MemoryArea;
/* Lock the Address Space */ @@ -484,7 +484,7 @@ PMEMORY_AREA MemoryArea; PHYSICAL_ADDRESS BoundaryAddressMultiple; NTSTATUS Status; - PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot; BoundaryAddressMultiple.QuadPart = 0;
/* Create the shared data page */ @@ -510,7 +510,7 @@ IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL) { NTSTATUS Status; - PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot; PVOID BaseAddress; PMEMORY_AREA MemoryArea; PHYSICAL_ADDRESS BoundaryAddressMultiple; @@ -519,9 +519,9 @@ PROS_SECTION_OBJECT SectionObject = Section; BoundaryAddressMultiple.QuadPart = 0;
- /* Initialize the Addresss Space */ + /* Initialize the Addresss Space lock */ KeInitializeGuardedMutex(&Process->AddressCreationLock); - MmInitializeAddressSpace(Process, ProcessAddressSpace); + Process->VadRoot.BalancedRoot.u1.Parent = NULL;
/* Acquire the Lock */ MmLockAddressSpace(ProcessAddressSpace); @@ -682,17 +682,17 @@ DPRINT("MmDeleteProcessAddressSpace(Process %x (%s))\n", Process, Process->ImageFileName);
- MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); - - while ((MemoryArea = ((PMADDRESS_SPACE)&Process->VadRoot)->MemoryAreaRoot) != NULL) + MmLockAddressSpace(&Process->VadRoot); + + while ((MemoryArea = (PMEMORY_AREA)Process->VadRoot.BalancedRoot.u1.Parent) != NULL) { switch (MemoryArea->Type) { case MEMORY_AREA_SECTION_VIEW: Address = (PVOID)MemoryArea->StartingAddress; - MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmUnlockAddressSpace(&Process->VadRoot); MmUnmapViewOfSection(Process, Address); - MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmLockAddressSpace(&Process->VadRoot); break;
case MEMORY_AREA_VIRTUAL_MEMORY: @@ -702,7 +702,7 @@
case MEMORY_AREA_SHARED_DATA: case MEMORY_AREA_NO_ACCESS: - MmFreeMemoryArea((PMADDRESS_SPACE)&Process->VadRoot, + MmFreeMemoryArea(&Process->VadRoot, MemoryArea, NULL, NULL); @@ -719,8 +719,7 @@
Mmi386ReleaseMmInfo(Process);
- MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); - MmDestroyAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmUnlockAddressSpace(&Process->VadRoot);
DPRINT("Finished MmReleaseMmInfo()\n"); return(STATUS_SUCCESS);
Modified: trunk/reactos/ntoskrnl/mm/region.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/region.c?rev=34... ============================================================================== --- trunk/reactos/ntoskrnl/mm/region.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/region.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -33,7 +33,7 @@ PMM_REGION static MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress, PVOID StartAddress, ULONG Length, ULONG NewType, - ULONG NewProtect, PMADDRESS_SPACE AddressSpace, + ULONG NewProtect, PMM_AVL_TABLE AddressSpace, PMM_ALTER_REGION_FUNC AlterFunc) { PMM_REGION NewRegion1; @@ -105,7 +105,7 @@
NTSTATUS NTAPI -MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress, +MmAlterRegion(PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length, ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc) {
Modified: trunk/reactos/ntoskrnl/mm/rmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/rmap.c?rev=3488... ============================================================================== --- trunk/reactos/ntoskrnl/mm/rmap.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/rmap.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -58,7 +58,7 @@ { PMM_RMAP_ENTRY entry; PMEMORY_AREA MemoryArea; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; ULONG Type; PVOID Address; PEPROCESS Process; @@ -91,7 +91,7 @@ { return Status; } - AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + AddressSpace = &Process->VadRoot; } else { @@ -192,7 +192,7 @@ { PMM_RMAP_ENTRY entry; PMEMORY_AREA MemoryArea; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; ULONG Type; PVOID Address; PEPROCESS Process; @@ -222,7 +222,7 @@ { return Status; } - AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + AddressSpace = &Process->VadRoot; } else {
Modified: trunk/reactos/ntoskrnl/mm/section.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -152,7 +152,7 @@ { /* * FIXME: TODO. - * Filip says to get the MADDRESS_SPACE from EPROCESS, + * Filip says to get the MM_AVL_TABLE from EPROCESS, * then use the MmMarea routines to locate the Marea that * corresponds to the address. Then make sure it's a section * view type (MEMORY_AREA_SECTION_VIEW) and use the marea's @@ -707,7 +707,7 @@
NTSTATUS NTAPI -MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, +MmNotPresentFaultSectionView(PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked) @@ -1227,7 +1227,7 @@
NTSTATUS NTAPI -MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, +MmAccessFaultSectionView(PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked) @@ -1412,7 +1412,7 @@ PageOutContext = (MM_SECTION_PAGEOUT_CONTEXT*)Context; if (Process) { - MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmLockAddressSpace(&Process->VadRoot); }
MmDeleteVirtualMapping(Process, @@ -1436,7 +1436,7 @@ } if (Process) { - MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot); + MmUnlockAddressSpace(&Process->VadRoot); }
if (PageOutContext->Private) @@ -1449,7 +1449,7 @@
NTSTATUS NTAPI -MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, +MmPageOutSectionView(PMM_AVL_TABLE AddressSpace, MEMORY_AREA* MemoryArea, PVOID Address, PMM_PAGEOP PageOp) @@ -1803,7 +1803,7 @@
NTSTATUS NTAPI -MmWritePageSectionView(PMADDRESS_SPACE AddressSpace, +MmWritePageSectionView(PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, PMM_PAGEOP PageOp) @@ -1950,7 +1950,7 @@ }
VOID static -MmAlterViewAttributes(PMADDRESS_SPACE AddressSpace, +MmAlterViewAttributes(PMM_AVL_TABLE AddressSpace, PVOID BaseAddress, ULONG RegionSize, ULONG OldType, @@ -2015,7 +2015,7 @@
NTSTATUS NTAPI -MmProtectSectionView(PMADDRESS_SPACE AddressSpace, +MmProtectSectionView(PMM_AVL_TABLE AddressSpace, PMEMORY_AREA MemoryArea, PVOID BaseAddress, ULONG Length, @@ -3566,7 +3566,7 @@ }
NTSTATUS static -MmMapViewOfSegment(PMADDRESS_SPACE AddressSpace, +MmMapViewOfSegment(PMM_AVL_TABLE AddressSpace, PROS_SECTION_OBJECT Section, PMM_SECTION_SEGMENT Segment, PVOID* BaseAddress, @@ -3677,7 +3677,7 @@ PROS_SECTION_OBJECT Section; PEPROCESS Process; KPROCESSOR_MODE PreviousMode; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; NTSTATUS Status = STATUS_SUCCESS; ULONG tmpProtect;
@@ -3758,7 +3758,7 @@ return(Status); }
- AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + AddressSpace = &Process->VadRoot;
Status = ObReferenceObjectByHandle(SectionHandle, SECTION_MAP_READ, @@ -3840,10 +3840,10 @@ NTSTATUS Status; PROS_SECTION_OBJECT Section; PMM_SECTION_SEGMENT Segment; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; PEPROCESS Process;
- AddressSpace = (PMADDRESS_SPACE)Context; + AddressSpace = (PMM_AVL_TABLE)Context; Process = MmGetAddressSpaceOwner(AddressSpace);
Address = (PVOID)PAGE_ROUND_DOWN(Address); @@ -3937,7 +3937,7 @@ }
static NTSTATUS -MmUnmapViewOfSegment(PMADDRESS_SPACE AddressSpace, +MmUnmapViewOfSegment(PMM_AVL_TABLE AddressSpace, PVOID BaseAddress) { NTSTATUS Status; @@ -3997,7 +3997,7 @@ { NTSTATUS Status; PMEMORY_AREA MemoryArea; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; PROS_SECTION_OBJECT Section; PMM_PAGEOP PageOp; ULONG_PTR Offset; @@ -4008,7 +4008,7 @@
ASSERT(Process);
- AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot; + AddressSpace = &Process->VadRoot;
MmLockAddressSpace(AddressSpace); MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, @@ -4398,7 +4398,7 @@ PVOID Result; MEMORY_AREA* marea; NTSTATUS Status; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; PHYSICAL_ADDRESS BoundaryAddressMultiple;
DPRINT("MmAllocateSection(Length %x)\n",Length); @@ -4494,7 +4494,7 @@ IN ULONG Protect) { PROS_SECTION_OBJECT Section; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; ULONG ViewOffset; NTSTATUS Status = STATUS_SUCCESS;
@@ -4514,7 +4514,7 @@
Section = (PROS_SECTION_OBJECT)SectionObject; - AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot; + AddressSpace = &Process->VadRoot;
AllocationType |= (Section->AllocationAttributes & SEC_NO_CHANGE);
@@ -4743,7 +4743,7 @@ IN OUT PULONG ViewSize) { PROS_SECTION_OBJECT Section; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; NTSTATUS Status;
DPRINT("MmMapViewInSystemSpace() called\n"); @@ -4803,7 +4803,7 @@ NTSTATUS STDCALL MmUnmapViewInSystemSpace (IN PVOID MappedBase) { - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; NTSTATUS Status;
DPRINT("MmUnmapViewInSystemSpace() called\n");
Modified: trunk/reactos/ntoskrnl/mm/virtual.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/virtual.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/mm/virtual.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/virtual.c [iso-8859-1] Sun Jul 27 20:49:23 2008 @@ -425,7 +425,7 @@ NTSTATUS Status; PEPROCESS Process; MEMORY_AREA* MemoryArea; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace;
if (Address < MmSystemRangeStart) { @@ -441,7 +441,7 @@ DPRINT("NtQueryVirtualMemory() = %x\n",Status); return(Status); } - AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot; + AddressSpace = &Process->VadRoot; } else { @@ -589,7 +589,7 @@ OUT PULONG OldAccessProtection OPTIONAL) { PMEMORY_AREA MemoryArea; - PMADDRESS_SPACE AddressSpace; + PMM_AVL_TABLE AddressSpace; ULONG OldAccessProtection_; NTSTATUS Status;
@@ -598,7 +598,7 @@ PAGE_ROUND_DOWN(*BaseAddress); *BaseAddress = (PVOID)PAGE_ROUND_DOWN(*BaseAddress);
- AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot; + AddressSpace = &Process->VadRoot;
MmLockAddressSpace(AddressSpace); MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, *BaseAddress);