Compute PFN database size during MM initialization
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (amd64, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 25s
Builds / ExectOS (i686, debug) (push) Successful in 27s

This commit is contained in:
2025-12-13 22:50:27 +01:00
parent b7bbf9ffa8
commit 5224dc315f
3 changed files with 38 additions and 0 deletions

View File

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

View File

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

View File

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