Compute PFN database size during MM initialization
This commit is contained in:
@@ -23,9 +23,12 @@ namespace MM
|
||||
STATIC ULONG_PTR LowestPhysicalPage;
|
||||
STATIC ULONG NumberOfPhysicalPages;
|
||||
STATIC LOADER_MEMORY_DESCRIPTOR OriginalFreeDescriptor;
|
||||
STATIC PFN_NUMBER PfnDatabaseSize;
|
||||
|
||||
public:
|
||||
STATIC XTAPI VOID ComputePfnDatabaseSize(VOID);
|
||||
STATIC XTAPI ULONG GetNumberOfPhysicalPages(VOID);
|
||||
STATIC XTAPI PFN_NUMBER GetPfnDatabaseSize(VOID);
|
||||
STATIC XTAPI VOID ScanMemoryDescriptors(VOID);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ MM::Manager::InitializeMemoryManager(VOID)
|
||||
DebugPrint(L"Insufficient physical pages! Install additional memory\n");
|
||||
KE::Crash::Panic(0);
|
||||
}
|
||||
|
||||
/* Compute allocation size for the PFN database */
|
||||
MM::Pfn::ComputePfnDatabaseSize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,23 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the total number of pages required for the PFN database and its associated color tables.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
MM::Pfn::ComputePfnDatabaseSize(VOID)
|
||||
{
|
||||
/* Calculate the total number of pages required for the PFN database */
|
||||
PfnDatabaseSize = (HighestPhysicalPage + 1) * sizeof(MMPFN);
|
||||
PfnDatabaseSize = ROUND_UP(PfnDatabaseSize, MM_PAGE_SIZE);
|
||||
PfnDatabaseSize >>= MM_PAGE_SHIFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the total number of physical pages managed by the system.
|
||||
*
|
||||
@@ -25,6 +42,21 @@ MM::Pfn::GetNumberOfPhysicalPages(VOID)
|
||||
return NumberOfPhysicalPages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of the PFN database and its associated structures, in pages.
|
||||
*
|
||||
* @return This routine returns the total number of pages required for the PFN database and its associated structures.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PFN_NUMBER
|
||||
MM::Pfn::GetPfnDatabaseSize(VOID)
|
||||
{
|
||||
/* Return the pre-calculated size of the PFN database in pages */
|
||||
return PfnDatabaseSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans memory descriptors provided by the boot loader.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user