mirror of
https://github.com/reactos/reactos.git
synced 2025-06-13 11:58:31 +00:00
[NTOS:MM] Stop using PD_COUNT, PDE_COUNT and PTE_COUNT (#2294)
Directly use PPE_PER_PAGE, PDE_PER_PAGE, PTE_PER_PAGE constants from hardware-specific MM headers instead
This commit is contained in:
parent
37349d7a0f
commit
2c6747aff0
8 changed files with 29 additions and 33 deletions
|
@ -37,7 +37,7 @@ ULONG MmSessionPoolSize;
|
||||||
ULONG MmSessionImageSize;
|
ULONG MmSessionImageSize;
|
||||||
PVOID MiSystemViewStart;
|
PVOID MiSystemViewStart;
|
||||||
ULONG MmSystemViewSize;
|
ULONG MmSystemViewSize;
|
||||||
PFN_NUMBER MmSystemPageDirectory[PD_COUNT];
|
PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE];
|
||||||
PMMPDE MmSystemPagePtes;
|
PMMPDE MmSystemPagePtes;
|
||||||
ULONG MmNumberOfSystemPtes;
|
ULONG MmNumberOfSystemPtes;
|
||||||
ULONG MxPfnAllocation;
|
ULONG MxPfnAllocation;
|
||||||
|
|
|
@ -19,21 +19,16 @@
|
||||||
#define _64K (64 * _1KB)
|
#define _64K (64 * _1KB)
|
||||||
|
|
||||||
/* Area mapped by a PDE */
|
/* Area mapped by a PDE */
|
||||||
#define PDE_MAPPED_VA (PTE_COUNT * PAGE_SIZE)
|
#define PDE_MAPPED_VA (PTE_PER_PAGE * PAGE_SIZE)
|
||||||
|
|
||||||
/* Size of a page table */
|
/* Size of a page table */
|
||||||
#define PT_SIZE (PTE_COUNT * sizeof(MMPTE))
|
#define PT_SIZE (PTE_PER_PAGE * sizeof(MMPTE))
|
||||||
|
|
||||||
/* Size of a page directory */
|
/* Size of a page directory */
|
||||||
#define PD_SIZE (PDE_COUNT * sizeof(MMPDE))
|
#define PD_SIZE (PDE_PER_PAGE * sizeof(MMPDE))
|
||||||
|
|
||||||
/* Stop using these! */
|
|
||||||
#define PD_COUNT PPE_PER_PAGE
|
|
||||||
#define PDE_COUNT PDE_PER_PAGE
|
|
||||||
#define PTE_COUNT PTE_PER_PAGE
|
|
||||||
|
|
||||||
/* Size of all page directories for a process */
|
/* Size of all page directories for a process */
|
||||||
#define SYSTEM_PD_SIZE (PD_COUNT * PD_SIZE)
|
#define SYSTEM_PD_SIZE (PPE_PER_PAGE * PD_SIZE)
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
|
C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
@ -644,7 +639,7 @@ extern PVOID MiSessionImageStart;
|
||||||
extern PVOID MiSessionImageEnd;
|
extern PVOID MiSessionImageEnd;
|
||||||
extern PMMPTE MiHighestUserPte;
|
extern PMMPTE MiHighestUserPte;
|
||||||
extern PMMPDE MiHighestUserPde;
|
extern PMMPDE MiHighestUserPde;
|
||||||
extern PFN_NUMBER MmSystemPageDirectory[PD_COUNT];
|
extern PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE];
|
||||||
extern PMMPTE MmSharedUserDataPte;
|
extern PMMPTE MmSharedUserDataPte;
|
||||||
extern LIST_ENTRY MmProcessList;
|
extern LIST_ENTRY MmProcessList;
|
||||||
extern BOOLEAN MmZeroingPageThreadActive;
|
extern BOOLEAN MmZeroingPageThreadActive;
|
||||||
|
|
|
@ -161,7 +161,7 @@ SIZE_T MmSystemViewSize;
|
||||||
// map paged pool PDEs into external processes when they fault on a paged pool
|
// map paged pool PDEs into external processes when they fault on a paged pool
|
||||||
// address.
|
// address.
|
||||||
//
|
//
|
||||||
PFN_NUMBER MmSystemPageDirectory[PD_COUNT];
|
PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE];
|
||||||
PMMPDE MmSystemPagePtes;
|
PMMPDE MmSystemPagePtes;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
|
|
||||||
/* Start with the first PDE and scan them all */
|
/* Start with the first PDE and scan them all */
|
||||||
PointerPde = MiAddressToPde(NULL);
|
PointerPde = MiAddressToPde(NULL);
|
||||||
Count = PD_COUNT * PDE_COUNT;
|
Count = PPE_PER_PAGE * PDE_PER_PAGE;
|
||||||
for (i = 0; i < Count; i++)
|
for (i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
/* Check for valid PDE */
|
/* Check for valid PDE */
|
||||||
|
@ -812,7 +812,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
|
|
||||||
/* Now get the PTE and scan the pages */
|
/* Now get the PTE and scan the pages */
|
||||||
PointerPte = MiAddressToPte(BaseAddress);
|
PointerPte = MiAddressToPte(BaseAddress);
|
||||||
for (j = 0; j < PTE_COUNT; j++)
|
for (j = 0; j < PTE_PER_PAGE; j++)
|
||||||
{
|
{
|
||||||
/* Check for a valid PTE */
|
/* Check for a valid PTE */
|
||||||
if (PointerPte->u.Hard.Valid == 1)
|
if (PointerPte->u.Hard.Valid == 1)
|
||||||
|
@ -1439,7 +1439,7 @@ MiAddHalIoMappings(VOID)
|
||||||
{
|
{
|
||||||
/* Get the PTE for it and scan each page */
|
/* Get the PTE for it and scan each page */
|
||||||
PointerPte = MiAddressToPte(BaseAddress);
|
PointerPte = MiAddressToPte(BaseAddress);
|
||||||
for (j = 0 ; j < PTE_COUNT; j++)
|
for (j = 0; j < PTE_PER_PAGE; j++)
|
||||||
{
|
{
|
||||||
/* Does the HAL own this page? */
|
/* Does the HAL own this page? */
|
||||||
if (PointerPte->u.Hard.Valid == 1)
|
if (PointerPte->u.Hard.Valid == 1)
|
||||||
|
@ -1767,7 +1767,7 @@ MiBuildPagedPool(VOID)
|
||||||
// Get the page frame number for the system page directory
|
// Get the page frame number for the system page directory
|
||||||
//
|
//
|
||||||
PointerPte = MiAddressToPte(PDE_BASE);
|
PointerPte = MiAddressToPte(PDE_BASE);
|
||||||
ASSERT(PD_COUNT == 1);
|
ASSERT(PPE_PER_PAGE == 1);
|
||||||
MmSystemPageDirectory[0] = PFN_FROM_PTE(PointerPte);
|
MmSystemPageDirectory[0] = PFN_FROM_PTE(PointerPte);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1785,7 +1785,7 @@ MiBuildPagedPool(VOID)
|
||||||
// way).
|
// way).
|
||||||
//
|
//
|
||||||
TempPte = ValidKernelPte;
|
TempPte = ValidKernelPte;
|
||||||
ASSERT(PD_COUNT == 1);
|
ASSERT(PPE_PER_PAGE == 1);
|
||||||
TempPte.u.Hard.PageFrameNumber = MmSystemPageDirectory[0];
|
TempPte.u.Hard.PageFrameNumber = MmSystemPageDirectory[0];
|
||||||
MI_WRITE_VALID_PTE(PointerPte, TempPte);
|
MI_WRITE_VALID_PTE(PointerPte, TempPte);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1894,12 +1894,12 @@ MiBuildPagedPool(VOID)
|
||||||
PFN_FROM_PTE(MiAddressToPpe(MmPagedPoolStart)));
|
PFN_FROM_PTE(MiAddressToPpe(MmPagedPoolStart)));
|
||||||
#else
|
#else
|
||||||
/* Do it this way */
|
/* Do it this way */
|
||||||
// Bla = MmSystemPageDirectory[(PointerPde - (PMMPTE)PDE_BASE) / PDE_COUNT]
|
// Bla = MmSystemPageDirectory[(PointerPde - (PMMPTE)PDE_BASE) / PDE_PER_PAGE]
|
||||||
|
|
||||||
/* Initialize the PFN entry for it */
|
/* Initialize the PFN entry for it */
|
||||||
MiInitializePfnForOtherProcess(PageFrameIndex,
|
MiInitializePfnForOtherProcess(PageFrameIndex,
|
||||||
(PMMPTE)PointerPde,
|
(PMMPTE)PointerPde,
|
||||||
MmSystemPageDirectory[(PointerPde - (PMMPDE)PDE_BASE) / PDE_COUNT]);
|
MmSystemPageDirectory[(PointerPde - (PMMPDE)PDE_BASE) / PDE_PER_PAGE]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -480,7 +480,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
||||||
//
|
//
|
||||||
// Get the page bit count
|
// Get the page bit count
|
||||||
//
|
//
|
||||||
i = ((SizeInPages - 1) / PTE_COUNT) + 1;
|
i = ((SizeInPages - 1) / PTE_PER_PAGE) + 1;
|
||||||
DPRINT("Paged pool expansion: %lu %x\n", i, SizeInPages);
|
DPRINT("Paged pool expansion: %lu %x\n", i, SizeInPages);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -566,7 +566,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
||||||
/* Initialize the PFN */
|
/* Initialize the PFN */
|
||||||
MiInitializePfnForOtherProcess(PageFrameNumber,
|
MiInitializePfnForOtherProcess(PageFrameNumber,
|
||||||
(PMMPTE)PointerPde,
|
(PMMPTE)PointerPde,
|
||||||
MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT]);
|
MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_PER_PAGE]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -587,10 +587,10 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
||||||
//
|
//
|
||||||
EndAllocation = (ULONG)(MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
|
EndAllocation = (ULONG)(MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
|
||||||
(PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
|
(PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
|
||||||
PTE_COUNT;
|
PTE_PER_PAGE;
|
||||||
RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap,
|
RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap,
|
||||||
EndAllocation,
|
EndAllocation,
|
||||||
PageTableCount * PTE_COUNT);
|
PageTableCount * PTE_PER_PAGE);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update the next expansion location
|
// Update the next expansion location
|
||||||
|
|
|
@ -512,7 +512,7 @@ MiFillSystemPageDirectory(IN PVOID Base,
|
||||||
TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
|
TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
|
||||||
|
|
||||||
#if (_MI_PAGING_LEVELS == 2)
|
#if (_MI_PAGING_LEVELS == 2)
|
||||||
ParentPage = MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT];
|
ParentPage = MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_PER_PAGE];
|
||||||
#else
|
#else
|
||||||
ParentPage = MiPdeToPpe(PointerPde)->u.Hard.PageFrameNumber;
|
ParentPage = MiPdeToPpe(PointerPde)->u.Hard.PageFrameNumber;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -361,7 +361,7 @@ MiBalancerThread(PVOID Unused)
|
||||||
PMMPDE pointerPde;
|
PMMPDE pointerPde;
|
||||||
for (Address = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS;
|
for (Address = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS;
|
||||||
Address < (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS;
|
Address < (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS;
|
||||||
Address += (PAGE_SIZE * PTE_COUNT))
|
Address += PTE_PER_PAGE * PAGE_SIZE)
|
||||||
{
|
{
|
||||||
if (MiQueryPageTableReferences((PVOID)Address) == 0)
|
if (MiQueryPageTableReferences((PVOID)Address) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <ntoskrnl.h>
|
#include <ntoskrnl.h>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <mm/ARM3/miarm.h>
|
#include <mm/ARM3/miarm.h>
|
||||||
|
|
||||||
#if defined (ALLOC_PRAGMA)
|
#if defined (ALLOC_PRAGMA)
|
||||||
|
@ -389,7 +390,7 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address,
|
||||||
{
|
{
|
||||||
/* Remove PDE reference */
|
/* Remove PDE reference */
|
||||||
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
||||||
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT);
|
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_PER_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pfn = PTE_TO_PFN(Pte);
|
Pfn = PTE_TO_PFN(Pte);
|
||||||
|
@ -453,7 +454,7 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
|
||||||
{
|
{
|
||||||
/* Remove PDE reference */
|
/* Remove PDE reference */
|
||||||
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
||||||
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT);
|
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_PER_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't need to flush here because page file entries
|
/* We don't need to flush here because page file entries
|
||||||
|
@ -638,7 +639,7 @@ MmCreatePageFileMapping(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
/* Add PDE reference */
|
/* Add PDE reference */
|
||||||
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++;
|
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++;
|
||||||
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT);
|
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_PER_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't need to flush the TLB here because it
|
/* We don't need to flush the TLB here because it
|
||||||
|
@ -755,7 +756,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
/* Add PDE reference */
|
/* Add PDE reference */
|
||||||
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Addr)]++;
|
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Addr)]++;
|
||||||
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Addr)] <= PTE_COUNT);
|
ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Addr)] <= PTE_PER_PAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -600,7 +600,7 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
|
||||||
|
|
||||||
for (Address = MI_LOWEST_VAD_ADDRESS;
|
for (Address = MI_LOWEST_VAD_ADDRESS;
|
||||||
Address < MM_HIGHEST_VAD_ADDRESS;
|
Address < MM_HIGHEST_VAD_ADDRESS;
|
||||||
Address =(PVOID)((ULONG_PTR)Address + (PAGE_SIZE * PTE_COUNT)))
|
Address = (PVOID)((ULONG_PTR)Address + (PTE_PER_PAGE * PAGE_SIZE)))
|
||||||
{
|
{
|
||||||
/* At this point all references should be dead */
|
/* At this point all references should be dead */
|
||||||
if (MiQueryPageTableReferences(Address) != 0)
|
if (MiQueryPageTableReferences(Address) != 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue