Author: tkreuzer
Date: Sat May 16 20:09:40 2015
New Revision: 67784
URL:
http://svn.reactos.org/svn/reactos?rev=67784&view=rev
Log:
[NTOSKRNL]
Convert StartingAddress and EndingAddress members in MEMORY_AREA to ULONG_PTR. Remove
unused MmFindGapAtAddress.
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/ARM3/virtual.c
trunk/reactos/ntoskrnl/mm/marea.c
trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat May 16 20:09:40 2015
@@ -201,8 +201,8 @@
typedef struct _MEMORY_AREA
{
- PVOID StartingAddress;
- PVOID EndingAddress;
+ ULONG_PTR StartingAddress;
+ ULONG_PTR EndingAddress;
struct _MEMORY_AREA *Parent;
struct _MEMORY_AREA *LeftChild;
struct _MEMORY_AREA *RightChild;
@@ -495,14 +495,6 @@
PVOID Address
);
-// fixme: unused?
-ULONG_PTR
-NTAPI
-MmFindGapAtAddress_(
- PMMSUPPORT AddressSpace,
- PVOID Address
-);
-
NTSTATUS
NTAPI
MmFreeMemoryArea(
Modified: trunk/reactos/ntoskrnl/mm/ARM3/virtual.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/virtual.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] Sat May 16 20:09:40 2015
@@ -5317,10 +5317,10 @@
Vad->u.VadFlags.CommitCharge -= CommitReduction;
// For ReactOS: shrink the corresponding memory area
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
(PVOID)StartingAddress);
- ASSERT(Vad->StartingVpn << PAGE_SHIFT ==
(ULONG_PTR)MemoryArea->StartingAddress);
- ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT ==
(ULONG_PTR)MemoryArea->EndingAddress);
- Vad->EndingVpn = ((ULONG_PTR)StartingAddress - 1) >>
PAGE_SHIFT;
- MemoryArea->EndingAddress = (PVOID)(StartingAddress);
+ ASSERT(Vad->StartingVpn << PAGE_SHIFT ==
MemoryArea->StartingAddress);
+ ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT ==
MemoryArea->EndingAddress);
+ Vad->EndingVpn = (StartingAddress - 1) >> PAGE_SHIFT;
+ MemoryArea->EndingAddress = StartingAddress;
}
else
{
Modified: trunk/reactos/ntoskrnl/mm/marea.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 20:09:40 2015
@@ -162,9 +162,10 @@
PMEMORY_AREA NTAPI
MmLocateMemoryAreaByAddress(
PMMSUPPORT AddressSpace,
- PVOID Address)
+ PVOID Address_)
{
PMEMORY_AREA Node = (PMEMORY_AREA)AddressSpace->WorkingSetExpansionLinks.Flink;
+ ULONG_PTR Address = (ULONG_PTR)Address_;
DPRINT("MmLocateMemoryAreaByAddress(AddressSpace %p, Address %p)\n",
AddressSpace, Address);
@@ -190,11 +191,12 @@
PMEMORY_AREA NTAPI
MmLocateMemoryAreaByRegion(
PMMSUPPORT AddressSpace,
- PVOID Address,
+ PVOID Address_,
ULONG_PTR Length)
{
PMEMORY_AREA Node;
- PVOID Extent = (PVOID)((ULONG_PTR)Address + Length);
+ ULONG_PTR Address = (ULONG_PTR)Address_;
+ ULONG_PTR Extent = Address + Length;
/* Special case for empty tree. */
if (AddressSpace->WorkingSetExpansionLinks.Flink == NULL)
@@ -376,7 +378,8 @@
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
/* Build a lame VAD if this is a user-space allocation */
- if ((marea->EndingAddress < MmSystemRangeStart) && (marea->Type !=
MEMORY_AREA_OWNED_BY_ARM3))
+ if ((marea->EndingAddress < (ULONG_PTR)MmSystemRangeStart) &&
+ (marea->Type != MEMORY_AREA_OWNED_BY_ARM3))
{
PMMVAD Vad;
@@ -610,66 +613,6 @@
return MmFindGapBottomUp(AddressSpace, Length, Granularity);
}
-ULONG_PTR NTAPI
-MmFindGapAtAddress(
- PMMSUPPORT AddressSpace,
- PVOID Address)
-{
- PMEMORY_AREA Node = (PMEMORY_AREA)AddressSpace->WorkingSetExpansionLinks.Flink;
- PMEMORY_AREA RightNeighbour = NULL;
- PVOID LowestAddress = MmGetAddressSpaceOwner(AddressSpace) ? MM_LOWEST_USER_ADDRESS
: MmSystemRangeStart;
- PVOID HighestAddress = MmGetAddressSpaceOwner(AddressSpace) ?
- (PVOID)((ULONG_PTR)MmSystemRangeStart - 1) :
(PVOID)MAXULONG_PTR;
-
- Address = MM_ROUND_DOWN(Address, PAGE_SIZE);
-
- if (LowestAddress < MmSystemRangeStart)
- {
- if (Address >= MmSystemRangeStart)
- {
- return 0;
- }
- }
- else
- {
- if (Address < LowestAddress)
- {
- return 0;
- }
- }
-
- while (Node != NULL)
- {
- if (Address < Node->StartingAddress)
- {
- RightNeighbour = Node;
- Node = Node->LeftChild;
- }
- else if (Address >= Node->EndingAddress)
- {
- Node = Node->RightChild;
- }
- else
- {
- DPRINT("MmFindGapAtAddress: 0\n");
- return 0;
- }
- }
-
- if (RightNeighbour)
- {
- DPRINT("MmFindGapAtAddress: %p [%p]\n", Address,
- (ULONG_PTR)RightNeighbour->StartingAddress - (ULONG_PTR)Address);
- return (ULONG_PTR)RightNeighbour->StartingAddress - (ULONG_PTR)Address;
- }
- else
- {
- DPRINT("MmFindGapAtAddress: %p [%p]\n", Address,
- (ULONG_PTR)HighestAddress - (ULONG_PTR)Address);
- return (ULONG_PTR)HighestAddress - (ULONG_PTR)Address;
- }
-}
-
VOID
NTAPI
MiRemoveNode(IN PMMADDRESS_NODE Node,
@@ -687,10 +630,10 @@
/* Check some fields */
ASSERT(Node->Magic == 'erAM');
- ASSERT(PAGE_ALIGN(Node->StartingAddress) == Node->StartingAddress);
- ASSERT(Node->EndingAddress != NULL);
- ASSERT(PAGE_ALIGN(Node->EndingAddress) == Node->EndingAddress);
- ASSERT((ULONG_PTR)Node->StartingAddress < (ULONG_PTR)Node->EndingAddress);
+ ASSERT(PAGE_ALIGN(Node->StartingAddress) == (PVOID)Node->StartingAddress);
+ ASSERT(Node->EndingAddress != 0);
+ ASSERT(PAGE_ALIGN(Node->EndingAddress) == (PVOID)Node->EndingAddress);
+ ASSERT(Node->StartingAddress < Node->EndingAddress);
ASSERT((Node->Type == 0) ||
(Node->Type == MEMORY_AREA_CACHE) ||
// (Node->Type == MEMORY_AREA_CACHE_SEGMENT) ||
@@ -872,7 +815,7 @@
if (MemoryArea->Vad)
{
- ASSERT(MemoryArea->EndingAddress < MmSystemRangeStart);
+ ASSERT(MemoryArea->EndingAddress < (ULONG_PTR)MmSystemRangeStart);
ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type
== MEMORY_AREA_CACHE);
/* MmCleanProcessAddressSpace might have removed it (and this would be
MmDeleteProcessAdressSpace) */
@@ -1065,8 +1008,8 @@
RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
MemoryArea->Type = Type;
- MemoryArea->StartingAddress = *BaseAddress;
- MemoryArea->EndingAddress = (PVOID)((ULONG_PTR)*BaseAddress + tmpLength);
+ MemoryArea->StartingAddress = (ULONG_PTR)*BaseAddress;
+ MemoryArea->EndingAddress = ((ULONG_PTR)*BaseAddress + tmpLength);
MemoryArea->Protect = Protect;
MemoryArea->Flags = AllocationFlags;
//MemoryArea->LockCount = 0;
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sat May 16 20:09:40 2015
@@ -1328,7 +1328,7 @@
Segment = MemoryArea->Data.SectionData.Segment;
Section = MemoryArea->Data.SectionData.Section;
- Region = MmFindRegion(MemoryArea->StartingAddress,
+ Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
&MemoryArea->Data.SectionData.RegionListHead,
Address, NULL);
ASSERT(Region != NULL);
@@ -1705,7 +1705,7 @@
Segment = MemoryArea->Data.SectionData.Segment;
Section = MemoryArea->Data.SectionData.Section;
- Region = MmFindRegion(MemoryArea->StartingAddress,
+ Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
&MemoryArea->Data.SectionData.RegionListHead,
Address, NULL);
ASSERT(Region != NULL);
@@ -2520,11 +2520,11 @@
NTSTATUS Status;
ULONG_PTR MaxLength;
- MaxLength = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)BaseAddress;
+ MaxLength = MemoryArea->EndingAddress - (ULONG_PTR)BaseAddress;
if (Length > MaxLength)
Length = (ULONG)MaxLength;
- Region = MmFindRegion(MemoryArea->StartingAddress,
+ Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
&MemoryArea->Data.SectionData.RegionListHead,
BaseAddress, NULL);
ASSERT(Region != NULL);
@@ -2536,7 +2536,7 @@
}
*OldProtect = Region->Protect;
- Status = MmAlterRegion(AddressSpace, MemoryArea->StartingAddress,
+ Status = MmAlterRegion(AddressSpace, (PVOID)MemoryArea->StartingAddress,
&MemoryArea->Data.SectionData.RegionListHead,
BaseAddress, Length, Region->Type, Protect,
MmAlterViewAttributes);
@@ -2572,7 +2572,7 @@
}
else
{
- Info->AllocationBase = MemoryArea->StartingAddress;
+ Info->AllocationBase = (PVOID)MemoryArea->StartingAddress;
Info->Type = MEM_MAPPED;
}
Info->BaseAddress = RegionBaseAddress;