mirror of
https://github.com/reactos/reactos.git
synced 2025-07-02 20:01:25 +00:00
- Get rid of MmPageArray and MmPageArraySize since these were defined as just being ReactOS-specific clones of MmPfnDatabase and MmHighestPhysicalPage. Ergo, use the latter in relevant places.
svn path=/trunk/; revision=41506
This commit is contained in:
parent
f7ed5bd01d
commit
6464056a16
4 changed files with 34 additions and 41 deletions
|
@ -21,7 +21,6 @@ extern ULONG MmPagedPoolSize;
|
||||||
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
||||||
extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
||||||
extern ULONG MmHighestPhysicalPage;
|
extern ULONG MmHighestPhysicalPage;
|
||||||
extern PVOID MmPfnDatabase;
|
|
||||||
|
|
||||||
struct _KTRAP_FRAME;
|
struct _KTRAP_FRAME;
|
||||||
struct _EPROCESS;
|
struct _EPROCESS;
|
||||||
|
@ -352,9 +351,7 @@ typedef struct _MMPFN
|
||||||
} u4;
|
} u4;
|
||||||
} MMPFN, *PMMPFN;
|
} MMPFN, *PMMPFN;
|
||||||
|
|
||||||
extern PMMPFN MmPageArray;
|
extern PMMPFN MmPfnDatabase;
|
||||||
extern ULONG MmPageArraySize;
|
|
||||||
|
|
||||||
extern MM_STATS MmStats;
|
extern MM_STATS MmStats;
|
||||||
|
|
||||||
typedef struct _MM_PAGEOP
|
typedef struct _MM_PAGEOP
|
||||||
|
@ -1041,10 +1038,10 @@ MiGetPfnEntry(IN PFN_TYPE Pfn)
|
||||||
PMMPFN Page;
|
PMMPFN Page;
|
||||||
|
|
||||||
/* Make sure the PFN number is valid */
|
/* Make sure the PFN number is valid */
|
||||||
if (Pfn > MmPageArraySize) return NULL;
|
if (Pfn > MmHighestPhysicalPage) return NULL;
|
||||||
|
|
||||||
/* Get the entry */
|
/* Get the entry */
|
||||||
Page = &MmPageArray[Pfn];
|
Page = &MmPfnDatabase[Pfn];
|
||||||
|
|
||||||
/* Make sure it's valid */
|
/* Make sure it's valid */
|
||||||
ASSERT_PFN(Page);
|
ASSERT_PFN(Page);
|
||||||
|
|
|
@ -48,8 +48,8 @@
|
||||||
#define PHYSICAL_PAGE MMPFN
|
#define PHYSICAL_PAGE MMPFN
|
||||||
#define PPHYSICAL_PAGE PMMPFN
|
#define PPHYSICAL_PAGE PMMPFN
|
||||||
|
|
||||||
PPHYSICAL_PAGE MmPageArray;
|
PPHYSICAL_PAGE MmPfnDatabase;
|
||||||
ULONG MmPageArraySize;
|
ULONG MmHighestPhysicalPage;
|
||||||
|
|
||||||
/* List of pages allocated to the MC_USER Consumer */
|
/* List of pages allocated to the MC_USER Consumer */
|
||||||
static LIST_ENTRY UserPageListHead;
|
static LIST_ENTRY UserPageListHead;
|
||||||
|
@ -84,7 +84,7 @@ MmGetLRUFirstUserPage(VOID)
|
||||||
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
|
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
|
||||||
ASSERT_PFN(PageDescriptor);
|
ASSERT_PFN(PageDescriptor);
|
||||||
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
||||||
return PageDescriptor - MmPageArray;
|
return PageDescriptor - MmPfnDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -123,7 +123,7 @@ MmGetLRUNextUserPage(PFN_TYPE PreviousPfn)
|
||||||
}
|
}
|
||||||
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
|
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
|
||||||
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
||||||
return PageDescriptor - MmPageArray;
|
return PageDescriptor - MmPfnDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -152,7 +152,7 @@ MmGetContinuousPages(ULONG NumberOfBytes,
|
||||||
|
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
|
|
||||||
last = min(HighestAcceptableAddress.LowPart / PAGE_SIZE, MmPageArraySize - 1);
|
last = min(HighestAcceptableAddress.LowPart / PAGE_SIZE, MmHighestPhysicalPage - 1);
|
||||||
boundary = BoundaryAddressMultiple.LowPart / PAGE_SIZE;
|
boundary = BoundaryAddressMultiple.LowPart / PAGE_SIZE;
|
||||||
|
|
||||||
for (j = 0; j < 2; j++)
|
for (j = 0; j < 2; j++)
|
||||||
|
@ -204,7 +204,7 @@ MmGetContinuousPages(ULONG NumberOfBytes,
|
||||||
PPHYSICAL_PAGE Page;
|
PPHYSICAL_PAGE Page;
|
||||||
Page = MiGetPfnEntry(i);
|
Page = MiGetPfnEntry(i);
|
||||||
RemoveEntryList(&Page->ListEntry);
|
RemoveEntryList(&Page->ListEntry);
|
||||||
if (MmPageArray[i].Flags.Zero == 0)
|
if (MmPfnDatabase[i].Flags.Zero == 0)
|
||||||
{
|
{
|
||||||
UnzeroedPageCount--;
|
UnzeroedPageCount--;
|
||||||
}
|
}
|
||||||
|
@ -268,14 +268,12 @@ MmInitializePageList(VOID)
|
||||||
InitializeListHead(&FreeZeroedPageListHead);
|
InitializeListHead(&FreeZeroedPageListHead);
|
||||||
|
|
||||||
/* Set the size and start of the PFN Database */
|
/* Set the size and start of the PFN Database */
|
||||||
MmPageArray = (PHYSICAL_PAGE *)MmPfnDatabase;
|
Reserved = PAGE_ROUND_UP((MmHighestPhysicalPage * sizeof(PHYSICAL_PAGE))) / PAGE_SIZE;
|
||||||
MmPageArraySize = MmHighestPhysicalPage;
|
|
||||||
Reserved = PAGE_ROUND_UP((MmPageArraySize * sizeof(PHYSICAL_PAGE))) / PAGE_SIZE;
|
|
||||||
|
|
||||||
/* Loop every page required to hold the PFN database */
|
/* Loop every page required to hold the PFN database */
|
||||||
for (i = 0; i < Reserved; i++)
|
for (i = 0; i < Reserved; i++)
|
||||||
{
|
{
|
||||||
PVOID Address = (char*)MmPageArray + (i * PAGE_SIZE);
|
PVOID Address = (char*)MmPfnDatabase + (i * PAGE_SIZE);
|
||||||
|
|
||||||
/* Check if FreeLDR has already allocated it for us */
|
/* Check if FreeLDR has already allocated it for us */
|
||||||
if (!MmIsPagePresent(NULL, Address))
|
if (!MmIsPagePresent(NULL, Address))
|
||||||
|
@ -302,7 +300,7 @@ MmInitializePageList(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the PFN database */
|
/* Clear the PFN database */
|
||||||
RtlZeroMemory(MmPageArray, (MmPageArraySize + 1) * sizeof(PHYSICAL_PAGE));
|
RtlZeroMemory(MmPfnDatabase, (MmHighestPhysicalPage + 1) * sizeof(PHYSICAL_PAGE));
|
||||||
|
|
||||||
/* This is what a used page looks like */
|
/* This is what a used page looks like */
|
||||||
RtlZeroMemory(&UsedPage, sizeof(UsedPage));
|
RtlZeroMemory(&UsedPage, sizeof(UsedPage));
|
||||||
|
@ -333,11 +331,11 @@ MmInitializePageList(VOID)
|
||||||
for (i = 0; i < Md->PageCount; i++)
|
for (i = 0; i < Md->PageCount; i++)
|
||||||
{
|
{
|
||||||
/* Skip memory we ignore completely */
|
/* Skip memory we ignore completely */
|
||||||
if ((Md->BasePage + i) > MmPageArraySize) break;
|
if ((Md->BasePage + i) > MmHighestPhysicalPage) break;
|
||||||
|
|
||||||
/* These are pages reserved by the BIOS/ROMs */
|
/* These are pages reserved by the BIOS/ROMs */
|
||||||
MmPageArray[Md->BasePage + i].Flags.Type = MM_PHYSICAL_PAGE_BIOS;
|
MmPfnDatabase[Md->BasePage + i].Flags.Type = MM_PHYSICAL_PAGE_BIOS;
|
||||||
MmPageArray[Md->BasePage + i].Flags.Consumer = MC_NPPOOL;
|
MmPfnDatabase[Md->BasePage + i].Flags.Consumer = MC_NPPOOL;
|
||||||
MmStats.NrSystemPages++;
|
MmStats.NrSystemPages++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,9 +348,9 @@ MmInitializePageList(VOID)
|
||||||
for (i = 0; i < Md->PageCount; i++)
|
for (i = 0; i < Md->PageCount; i++)
|
||||||
{
|
{
|
||||||
/* Mark it as a free page */
|
/* Mark it as a free page */
|
||||||
MmPageArray[Md->BasePage + i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
|
MmPfnDatabase[Md->BasePage + i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
|
||||||
InsertTailList(&FreeUnzeroedPageListHead,
|
InsertTailList(&FreeUnzeroedPageListHead,
|
||||||
&MmPageArray[Md->BasePage + i].ListEntry);
|
&MmPfnDatabase[Md->BasePage + i].ListEntry);
|
||||||
UnzeroedPageCount++;
|
UnzeroedPageCount++;
|
||||||
MmStats.NrFreePages++;
|
MmStats.NrFreePages++;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +361,7 @@ MmInitializePageList(VOID)
|
||||||
for (i = 0; i < Md->PageCount; i++)
|
for (i = 0; i < Md->PageCount; i++)
|
||||||
{
|
{
|
||||||
/* Everything else is used memory */
|
/* Everything else is used memory */
|
||||||
MmPageArray[Md->BasePage + i] = UsedPage;
|
MmPfnDatabase[Md->BasePage + i] = UsedPage;
|
||||||
MmStats.NrSystemPages++;
|
MmStats.NrSystemPages++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,10 +373,10 @@ MmInitializePageList(VOID)
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
/* Ensure this page was not added previously */
|
/* Ensure this page was not added previously */
|
||||||
ASSERT(MmPageArray[i].Flags.Type == 0);
|
ASSERT(MmPfnDatabase[i].Flags.Type == 0);
|
||||||
|
|
||||||
/* Mark it as used kernel memory */
|
/* Mark it as used kernel memory */
|
||||||
MmPageArray[i] = UsedPage;
|
MmPfnDatabase[i] = UsedPage;
|
||||||
MmStats.NrSystemPages++;
|
MmStats.NrSystemPages++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +419,7 @@ MmMarkPageMapped(PFN_TYPE Pfn)
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PPHYSICAL_PAGE Page;
|
PPHYSICAL_PAGE Page;
|
||||||
|
|
||||||
if (Pfn <= MmPageArraySize)
|
if (Pfn <= MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
Page = MiGetPfnEntry(Pfn);
|
Page = MiGetPfnEntry(Pfn);
|
||||||
|
@ -443,7 +441,7 @@ MmMarkPageUnmapped(PFN_TYPE Pfn)
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PPHYSICAL_PAGE Page;
|
PPHYSICAL_PAGE Page;
|
||||||
|
|
||||||
if (Pfn <= MmPageArraySize)
|
if (Pfn <= MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
Page = MiGetPfnEntry(Pfn);
|
Page = MiGetPfnEntry(Pfn);
|
||||||
|
@ -497,7 +495,7 @@ MmReferencePageUnsafe(PFN_TYPE Pfn)
|
||||||
|
|
||||||
DPRINT("MmReferencePageUnsafe(PysicalAddress %x)\n", Pfn << PAGE_SHIFT);
|
DPRINT("MmReferencePageUnsafe(PysicalAddress %x)\n", Pfn << PAGE_SHIFT);
|
||||||
|
|
||||||
if (Pfn == 0 || Pfn > MmPageArraySize)
|
if (Pfn == 0 || Pfn > MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -778,7 +776,7 @@ MmAllocPage(ULONG Consumer, SWAPENTRY SwapEntry)
|
||||||
|
|
||||||
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
||||||
|
|
||||||
PfnOffset = PageDescriptor - MmPageArray;
|
PfnOffset = PageDescriptor - MmPfnDatabase;
|
||||||
if (NeedClear)
|
if (NeedClear)
|
||||||
{
|
{
|
||||||
MiZeroPage(PfnOffset);
|
MiZeroPage(PfnOffset);
|
||||||
|
@ -822,16 +820,16 @@ MmAllocPagesSpecifyRange(ULONG Consumer,
|
||||||
if ((HighestAddress.u.LowPart % PAGE_SIZE) != 0)
|
if ((HighestAddress.u.LowPart % PAGE_SIZE) != 0)
|
||||||
HighestPage++;
|
HighestPage++;
|
||||||
|
|
||||||
if (LowestPage >= MmPageArraySize)
|
if (LowestPage >= MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
DPRINT1("MmAllocPagesSpecifyRange(): Out of memory\n");
|
DPRINT1("MmAllocPagesSpecifyRange(): Out of memory\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (HighestPage > MmPageArraySize)
|
if (HighestPage > MmHighestPhysicalPage)
|
||||||
HighestPage = MmPageArraySize;
|
HighestPage = MmHighestPhysicalPage;
|
||||||
|
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
if (LowestPage == 0 && HighestPage == MmPageArraySize)
|
if (LowestPage == 0 && HighestPage == MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY ListEntry;
|
||||||
while (NumberOfPagesFound < NumberOfPages)
|
while (NumberOfPagesFound < NumberOfPages)
|
||||||
|
@ -876,7 +874,7 @@ MmAllocPagesSpecifyRange(ULONG Consumer,
|
||||||
MmStats.NrFreePages--;
|
MmStats.NrFreePages--;
|
||||||
|
|
||||||
/* Remember the page */
|
/* Remember the page */
|
||||||
pfn = PageDescriptor - MmPageArray;
|
pfn = PageDescriptor - MmPfnDatabase;
|
||||||
Pages[NumberOfPagesFound++] = pfn;
|
Pages[NumberOfPagesFound++] = pfn;
|
||||||
if(Consumer == MC_USER) MmInsertLRULastUserPage(pfn);
|
if(Consumer == MC_USER) MmInsertLRULastUserPage(pfn);
|
||||||
}
|
}
|
||||||
|
@ -888,7 +886,7 @@ MmAllocPagesSpecifyRange(ULONG Consumer,
|
||||||
{
|
{
|
||||||
for (pfn = LowestPage; pfn < HighestPage; pfn++)
|
for (pfn = LowestPage; pfn < HighestPage; pfn++)
|
||||||
{
|
{
|
||||||
PageDescriptor = MmPageArray + pfn;
|
PageDescriptor = MmPfnDatabase + pfn;
|
||||||
|
|
||||||
if (PageDescriptor->Flags.Type != MM_PHYSICAL_PAGE_FREE)
|
if (PageDescriptor->Flags.Type != MM_PHYSICAL_PAGE_FREE)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1000,7 +998,7 @@ MmZeroPageThreadMain(PVOID Ignored)
|
||||||
/* We set the page to used, because MmCreateVirtualMapping failed with unused pages */
|
/* We set the page to used, because MmCreateVirtualMapping failed with unused pages */
|
||||||
PageDescriptor->Flags.Type = MM_PHYSICAL_PAGE_USED;
|
PageDescriptor->Flags.Type = MM_PHYSICAL_PAGE_USED;
|
||||||
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
||||||
Pfn = PageDescriptor - MmPageArray;
|
Pfn = PageDescriptor - MmPfnDatabase;
|
||||||
Status = MiZeroPageInternal(Pfn);
|
Status = MiZeroPageInternal(Pfn);
|
||||||
|
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
|
|
|
@ -26,7 +26,6 @@ PVOID MiMdlMappingRegionBase = NULL;
|
||||||
RTL_BITMAP MiMdlMappingRegionAllocMap;
|
RTL_BITMAP MiMdlMappingRegionAllocMap;
|
||||||
ULONG MiMdlMappingRegionHint;
|
ULONG MiMdlMappingRegionHint;
|
||||||
KSPIN_LOCK MiMdlMappingRegionLock;
|
KSPIN_LOCK MiMdlMappingRegionLock;
|
||||||
extern ULONG MmPageArraySize;
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
@ -418,7 +417,7 @@ MmProbeAndLockPages(IN PMDL Mdl,
|
||||||
|
|
||||||
/* Check if this is an MDL in I/O Space */
|
/* Check if this is an MDL in I/O Space */
|
||||||
if (Mdl->StartVa >= MmSystemRangeStart &&
|
if (Mdl->StartVa >= MmSystemRangeStart &&
|
||||||
MmGetPfnForProcess(NULL, Mdl->StartVa) >= MmPageArraySize)
|
MmGetPfnForProcess(NULL, Mdl->StartVa) >= MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
/* Just loop each page */
|
/* Just loop each page */
|
||||||
for (i = 0; i < NrPages; i++)
|
for (i = 0; i < NrPages; i++)
|
||||||
|
@ -521,7 +520,7 @@ MmProbeAndLockPages(IN PMDL Mdl,
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
Page = MdlPages[j];
|
Page = MdlPages[j];
|
||||||
if (Page < MmPageArraySize)
|
if (Page < MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
MmUnlockPage(Page);
|
MmUnlockPage(Page);
|
||||||
MmDereferencePage(Page);
|
MmDereferencePage(Page);
|
||||||
|
@ -532,7 +531,7 @@ MmProbeAndLockPages(IN PMDL Mdl,
|
||||||
}
|
}
|
||||||
Page = MmGetPfnForProcess(NULL, Address);
|
Page = MmGetPfnForProcess(NULL, Address);
|
||||||
MdlPages[i] = Page;
|
MdlPages[i] = Page;
|
||||||
if (Page >= MmPageArraySize)
|
if (Page >= MmHighestPhysicalPage)
|
||||||
{
|
{
|
||||||
Mdl->MdlFlags |= MDL_IO_SPACE;
|
Mdl->MdlFlags |= MDL_IO_SPACE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ ULONG MiNonPagedPoolLength;
|
||||||
ULONG MmBootImageSize;
|
ULONG MmBootImageSize;
|
||||||
ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage;
|
ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage;
|
||||||
ULONG_PTR MiKSeg0Start, MiKSeg0End;
|
ULONG_PTR MiKSeg0Start, MiKSeg0End;
|
||||||
PVOID MmPfnDatabase;
|
|
||||||
ULONG_PTR MmPfnDatabaseEnd;
|
ULONG_PTR MmPfnDatabaseEnd;
|
||||||
PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
||||||
MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue