diff --git a/xtoskrnl/includes/mm/pfn.hh b/xtoskrnl/includes/mm/pfn.hh index 6473f1a..6546b2f 100644 --- a/xtoskrnl/includes/mm/pfn.hh +++ b/xtoskrnl/includes/mm/pfn.hh @@ -18,6 +18,7 @@ namespace MM class Pfn { private: + STATIC PFN_NUMBER AvailablePages; STATIC PLOADER_MEMORY_DESCRIPTOR FreeDescriptor; STATIC ULONG_PTR HighestPhysicalPage; STATIC ULONG_PTR LowestPhysicalPage; @@ -31,6 +32,10 @@ namespace MM STATIC XTAPI ULONGLONG GetNumberOfPhysicalPages(VOID); STATIC XTAPI PFN_NUMBER GetPfnDatabaseSize(VOID); STATIC XTAPI VOID ScanMemoryDescriptors(VOID); + + private: + STATIC XTAPI VOID DecrementAvailablePages(VOID); + STATIC XTAPI VOID IncrementAvailablePages(VOID); }; } diff --git a/xtoskrnl/mm/data.cc b/xtoskrnl/mm/data.cc index be173b1..3c26171 100644 --- a/xtoskrnl/mm/data.cc +++ b/xtoskrnl/mm/data.cc @@ -39,6 +39,9 @@ PFN_NUMBER MM::Manager::NumberOfSystemPtes; /* Instance of the page map routines for the current PML level */ MM::PPAGEMAP MM::Paging::PmlRoutines; +/* Total number of physical pages available for allocation */ +PFN_NUMBER MM::Pfn::AvailablePages; + /* Biggest free memory descriptor */ PLOADER_MEMORY_DESCRIPTOR MM::Pfn::FreeDescriptor; diff --git a/xtoskrnl/mm/pfn.cc b/xtoskrnl/mm/pfn.cc index 68e3337..5a8d20e 100644 --- a/xtoskrnl/mm/pfn.cc +++ b/xtoskrnl/mm/pfn.cc @@ -60,6 +60,21 @@ MM::Pfn::ComputePfnDatabaseSize(VOID) PfnDatabaseSize >>= MM_PAGE_SHIFT; } +/** + * Decrements the global count of available pages. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +MM::Pfn::DecrementAvailablePages(VOID) +{ + /* Decrement the global count of available pages */ + AvailablePages--; +} + /** * Retrieves the total number of physical pages managed by the system. * @@ -90,6 +105,21 @@ MM::Pfn::GetPfnDatabaseSize(VOID) return PfnDatabaseSize; } +/** + * Increments the global count of available pages. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +MM::Pfn::IncrementAvailablePages(VOID) +{ + /* Increment the global count of available pages */ + AvailablePages++; +} + /** * Scans memory descriptors provided by the boot loader. *