Add bootstrap physical page allocator
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 38s
Builds / ExectOS (amd64, release) (push) Successful in 35s
Builds / ExectOS (i686, debug) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 21s

This commit is contained in:
2025-12-15 12:38:08 +01:00
parent 070c508e42
commit 5cf3dfa844
2 changed files with 34 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ namespace MM
STATIC PFN_NUMBER PfnDatabaseSize;
public:
STATIC XTAPI PFN_NUMBER AllocateBootstrapPages(IN PFN_NUMBER NumberOfPages);
STATIC XTAPI VOID ComputePfnDatabaseSize(VOID);
STATIC XTAPI ULONG GetNumberOfPhysicalPages(VOID);
STATIC XTAPI PFN_NUMBER GetPfnDatabaseSize(VOID);

View File

@@ -10,6 +10,39 @@
#include <xtos.hh>
/**
* Allocates a block of physical pages for early kernel initialization.
*
* @param NumberOfPages
* The number of physical pages to allocate.
*
* @return This routine returns the base page frame number (PFN) of the allocated block.
*
* @since XT 1.0
*/
XTAPI
PFN_NUMBER
MM::Pfn::AllocateBootstrapPages(IN PFN_NUMBER NumberOfPages)
{
PFN_NUMBER Pfn;
/* Check if the largest free memory block has enough pages */
if(NumberOfPages > FreeDescriptor->PageCount)
{
/* Not enough physical memory available, kernel panic */
DebugPrint(L"Insufficient physical pages! Install additional memory\n");
KE::Crash::Panic(0);
}
/* Allocate pages from the beginning of the free descriptor */
Pfn = FreeDescriptor->BasePage;
FreeDescriptor->BasePage += NumberOfPages;
FreeDescriptor->PageCount -= NumberOfPages;
/* Return the base page frame number of the allocated block */
return Pfn;
}
/**
* Calculates the total number of pages required for the PFN database and its associated color tables.
*