Implement tracking of available physical pages
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 27s
Builds / ExectOS (amd64, release) (push) Successful in 23s
Builds / ExectOS (i686, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 30s

This commit is contained in:
2025-12-23 22:13:09 +01:00
parent 5012c8dc37
commit b7c004528a
3 changed files with 38 additions and 0 deletions

View File

@@ -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);
};
}

View File

@@ -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;

View File

@@ -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.
*