Add configurable extra memory (#3513)

* Add configurable extra memory

* lowercase getter and setter

* Refactor memory setup to configure maximum memory limits at runtime

* sir clang offnir, the all-formatting

* Correctly update BackingSize on W*ndows too

* small format change

* remove total_memory_to_use from the header

* i have no idea how to name this commit
"addressing review comments" is a good name i guess

* Do not include extraDmem in the general config
This commit is contained in:
kalaposfos13
2025-09-28 19:16:03 +02:00
committed by GitHub
parent 6c5a84dc99
commit cad027845f
4 changed files with 30 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
#include "common/alignment.h"
#include "common/arch.h"
#include "common/assert.h"
#include "common/config.h"
#include "common/error.h"
#include "core/address_space.h"
#include "core/libraries/kernel/memory.h"
@@ -27,7 +28,7 @@ asm(".zerofill SYSTEM_RESERVED,SYSTEM_RESERVED,__SYSTEM_RESERVED,0x7C0004000");
namespace Core {
static constexpr size_t BackingSize = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO;
static size_t BackingSize = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO;
#ifdef _WIN32
@@ -71,6 +72,7 @@ struct MemoryRegion {
struct AddressSpace::Impl {
Impl() : process{GetCurrentProcess()} {
BackingSize += Config::getExtraDmemInMbytes() * 1_MB;
// Allocate virtual address placeholder for our address space.
MEM_ADDRESS_REQUIREMENTS req{};
MEM_EXTENDED_PARAMETER param{};
@@ -432,6 +434,7 @@ enum PosixPageProtection {
struct AddressSpace::Impl {
Impl() {
BackingSize += Config::getExtraDmemInMbytes() * 1_MB;
// Allocate virtual address placeholder for our address space.
system_managed_size = SystemManagedSize;
system_reserved_size = SystemReservedSize;

View File

@@ -42,6 +42,13 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1
if (Config::isDevKitConsole()) {
total_size = is_neo ? ORBIS_KERNEL_TOTAL_MEM_DEV_PRO : ORBIS_KERNEL_TOTAL_MEM_DEV;
}
s32 extra_dmem = Config::getExtraDmemInMbytes();
if (Config::getExtraDmemInMbytes() != 0) {
LOG_WARNING(Kernel_Vmm,
"extraDmemInMbytes is {} MB! Old Direct Size: {:#x} -> New Direct Size: {:#x}",
extra_dmem, total_size, total_size + extra_dmem * 1_MB);
total_size += extra_dmem * 1_MB;
}
if (!use_extended_mem1 && is_neo) {
total_size -= 256_MB;
}
@@ -58,7 +65,7 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1
// Insert an area that covers the flexible memory physical address block.
// Note that this should never be called after flexible memory allocations have been made.
const auto remaining_physical_space = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO - total_direct_size;
const auto remaining_physical_space = total_size - total_direct_size;
fmem_map.clear();
fmem_map.emplace(total_direct_size,
FlexibleMemoryArea{total_direct_size, remaining_physical_space});