From 46c24e653e53a210bc609488366bf79ab5dd2ad9 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Thu, 15 Jan 2026 19:09:10 +0100 Subject: [PATCH] Add routine to retrieve installed memory size --- xtoskrnl/includes/mm/mmgr.hh | 1 + xtoskrnl/mm/mmgr.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/xtoskrnl/includes/mm/mmgr.hh b/xtoskrnl/includes/mm/mmgr.hh index 8d4254a..e33253b 100644 --- a/xtoskrnl/includes/mm/mmgr.hh +++ b/xtoskrnl/includes/mm/mmgr.hh @@ -22,6 +22,7 @@ namespace MM STATIC PFN_NUMBER NumberOfSystemPtes; public: + STATIC XTAPI ULONG_PTR GetInstalledMemorySize(VOID); STATIC XTAPI PMMMEMORY_LAYOUT GetMemoryLayout(VOID); STATIC XTAPI PFN_NUMBER GetNumberOfSystemPtes(); STATIC XTAPI VOID InitializeMemoryLayout(VOID); diff --git a/xtoskrnl/mm/mmgr.cc b/xtoskrnl/mm/mmgr.cc index 29fa31e..3c22c26 100644 --- a/xtoskrnl/mm/mmgr.cc +++ b/xtoskrnl/mm/mmgr.cc @@ -10,6 +10,21 @@ #include +/** + * Retrieves the amount of total available memory in the system. + * + * @return This routine returns the amount of available memory in the system in megabytes. + * + * @since XT 1.0 + */ +XTAPI +ULONG_PTR +MM::Manager::GetInstalledMemorySize(VOID) +{ + /* Return the amount of installed memory */ + return (MM::Pfn::GetNumberOfPhysicalPages() * MM_PAGE_SIZE) / 1048576; +} + /** * Retrieves a pointer to the system's virtual memory layout structure. *