Expose PFN database lookup via GetPfnEntry
All checks were successful
Builds / ExectOS (i686, debug) (push) Successful in 49s
Builds / ExectOS (i686, release) (push) Successful in 46s
Builds / ExectOS (amd64, debug) (push) Successful in 1m24s
Builds / ExectOS (amd64, release) (push) Successful in 1m21s

This commit is contained in:
2025-12-28 21:18:17 +01:00
parent b7c004528a
commit 4593a89a9b
2 changed files with 31 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ namespace MM
STATIC XTAPI VOID ComputePfnDatabaseSize(VOID);
STATIC XTAPI ULONGLONG GetNumberOfPhysicalPages(VOID);
STATIC XTAPI PFN_NUMBER GetPfnDatabaseSize(VOID);
STATIC XTAPI PMMPFN GetPfnEntry(IN PFN_NUMBER Pfn);
STATIC XTAPI VOID ScanMemoryDescriptors(VOID);
private:

View File

@@ -105,6 +105,36 @@ MM::Pfn::GetPfnDatabaseSize(VOID)
return PfnDatabaseSize;
}
/**
* Retrieves a pointer to the PFN database entry for a given physical page.
*
* @param Pfn
* The Page Frame Number (PFN) to look up.
*
* @return This routine returns a pointer to the MMPFN structure for the given PFN, or NULLPTR if the PFN is invalid.
*
* @since XT 1.0
*/
XTAPI
PMMPFN
MM::Pfn::GetPfnEntry(IN PFN_NUMBER Pfn)
{
PMMMEMORY_LAYOUT MemoryLayout;
/* Validate that the PFN is within the range of managed physical memory */
if(Pfn > HighestPhysicalPage)
{
/* The requested page number is outside the bounds, return NULLPTR */
return NULLPTR;
}
/* Get the memory layout */
MemoryLayout = MM::Manager::GetMemoryLayout();
/* Calculate the address of the PFN entry by indexing into the PFN database array and return it */
return &((PMMPFN)MemoryLayout->PfnDatabaseAddress)[Pfn];
}
/**
* Increments the global count of available pages.
*