Compute PTE count per page from entry size
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 28s
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (i686, release) (push) Failing after 20s
Builds / ExectOS (i686, debug) (push) Failing after 21s

This commit is contained in:
2025-12-15 13:56:39 +01:00
parent 36c273ea13
commit 7f0ca6a948
4 changed files with 21 additions and 9 deletions

View File

@@ -43,12 +43,6 @@
#define MM_PXI_SHIFT 39 #define MM_PXI_SHIFT 39
#define MM_P5I_SHIFT 48 #define MM_P5I_SHIFT 48
/* Number of PTEs per page */
#define MM_PTE_PER_PAGE 512
#define MM_PDE_PER_PAGE 512
#define MM_PPE_PER_PAGE 512
#define MM_PXE_PER_PAGE 512
/* PTE state flags */ /* PTE state flags */
#define MM_PTE_VALID 0x0000000000000001ULL #define MM_PTE_VALID 0x0000000000000001ULL
#define MM_PTE_ACCESSED 0x0000000000000020ULL #define MM_PTE_ACCESSED 0x0000000000000020ULL

View File

@@ -18,6 +18,7 @@ namespace MM
class Pte class Pte
{ {
public: public:
STATIC XTAPI ULONG GetPtesPerPage(VOID);
STATIC XTAPI VOID MapP5E(PVOID StartAddress, STATIC XTAPI VOID MapP5E(PVOID StartAddress,
PVOID EndAddress, PVOID EndAddress,
PMMP5E TemplateP5e); PMMP5E TemplateP5e);

View File

@@ -38,10 +38,12 @@ MM::Manager::InitializeMemoryLayout(VOID)
{ {
ULONG_PTR PagedPoolSize, PteCount; ULONG_PTR PagedPoolSize, PteCount;
PFN_NUMBER PfnDatabaseSize; PFN_NUMBER PfnDatabaseSize;
ULONG PtesPerPage;
/* Calculate size of paged pool (at least 32MiB) */ /* Get the number of PTEs per page and calculate size of paged pool (at least 32MiB) */
PteCount = ((SIZE_TO_PAGES(33554432) + (MM_PTE_PER_PAGE - 1)) / MM_PTE_PER_PAGE); PtesPerPage = MM::Pte::GetPtesPerPage();
PagedPoolSize = PteCount * MM_PTE_PER_PAGE * MM_PAGE_SIZE; PteCount = ((SIZE_TO_PAGES(33554432) + (PtesPerPage - 1)) / PtesPerPage);
PagedPoolSize = PteCount * PtesPerPage * MM_PAGE_SIZE;
/* Retrieve the PFN database size */ /* Retrieve the PFN database size */
PfnDatabaseSize = MM::Pfn::GetPfnDatabaseSize(); PfnDatabaseSize = MM::Pfn::GetPfnDatabaseSize();

View File

@@ -9,6 +9,21 @@
#include <xtos.hh> #include <xtos.hh>
/**
* Calculates the number of Page Table Entries (PTEs) that fit within a single page.
*
* @return This routine returns the number of PTEs per page.
*
* @since XT 1.0
*/
XTAPI
ULONG
MM::Pte::GetPtesPerPage(VOID)
{
/* Calculate and return the number of PTEs per page */
return MM_PAGE_SIZE / MM::Paging::GetPteSize();
}
/** /**
* Maps a range of virtual addresses at the P5E (PML5) level. * Maps a range of virtual addresses at the P5E (PML5) level.
* *