From 0658e98436ccc7f927bf1d51a642b231b1c502fb Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Wed, 25 Feb 2026 20:25:50 +0100 Subject: [PATCH] Expose the number of available physical pages --- xtoskrnl/includes/mm/pfn.hh | 1 + xtoskrnl/mm/pfn.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/xtoskrnl/includes/mm/pfn.hh b/xtoskrnl/includes/mm/pfn.hh index 1d6eae8..5b7a810 100644 --- a/xtoskrnl/includes/mm/pfn.hh +++ b/xtoskrnl/includes/mm/pfn.hh @@ -45,6 +45,7 @@ namespace MM IN PFN_NUMBER PageFrameIndex, IN BOOLEAN BeginStandbyList = FALSE); STATIC XTAPI VOID FreePhysicalPage(IN PMMPTE PointerPte); + STATIC XTAPI PFN_NUMBER GetAvailablePages(VOID); STATIC XTAPI ULONG_PTR GetHighestPhysicalPage(VOID); STATIC XTAPI ULONGLONG GetNumberOfPhysicalPages(VOID); STATIC XTAPI PMMPFN GetPfnEntry(IN PFN_NUMBER Pfn); diff --git a/xtoskrnl/mm/pfn.cc b/xtoskrnl/mm/pfn.cc index 4dcf258..ad94f0c 100644 --- a/xtoskrnl/mm/pfn.cc +++ b/xtoskrnl/mm/pfn.cc @@ -351,6 +351,21 @@ MM::Pfn::FreePhysicalPage(IN PMMPTE PointerPte) MM::Pfn::DecrementShareCount(PageFrame, PageFrameNumber, FALSE); } +/** + * Retrieves the number of available physical pages. + * + * @return This routine returns the number of available physical pages. + * + * @since XT 1.0 + */ +XTAPI +PFN_NUMBER +MM::Pfn::GetAvailablePages(VOID) +{ + /* Return the number of available pages */ + return AvailablePages; +} + /** * Retrieves the highest physical page number (PFN) detected in the system. *