From c2fd59ff6ff3743cae7a35a82495e6a316fdda7c Mon Sep 17 00:00:00 2001 From: PSI-Rockin Date: Fri, 10 May 2024 23:16:24 -0400 Subject: [PATCH] Kernel: Return used app memory for Commit ResourceLimit Not quite correct, but nothing to be done until process management is improved Also remove the stack limit for CXIs (thanks amogus) --- src/core/kernel/resource_limits.cpp | 2 +- src/core/loader/ncsd.cpp | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core/kernel/resource_limits.cpp b/src/core/kernel/resource_limits.cpp index 0e05d65b..27be8839 100644 --- a/src/core/kernel/resource_limits.cpp +++ b/src/core/kernel/resource_limits.cpp @@ -81,7 +81,7 @@ void Kernel::getResourceLimitCurrentValues() { s32 Kernel::getCurrentResourceValue(const KernelObject* limit, u32 resourceName) { const auto data = static_cast(limit->data); switch (resourceName) { - case ResourceType::Commit: return 0; // TODO: needs to use the current amount of memory allocated by the process + case ResourceType::Commit: return fcramManager.getUsedCount(FcramRegion::App) << 12; // TODO: needs to use the current amount of memory allocated by the process case ResourceType::Thread: return threadIndices.size(); default: Helpers::panic("Attempted to get current value of unknown kernel resource: %d\n", resourceName); } diff --git a/src/core/loader/ncsd.cpp b/src/core/loader/ncsd.cpp index da5bb170..25a0fa83 100644 --- a/src/core/loader/ncsd.cpp +++ b/src/core/loader/ncsd.cpp @@ -27,12 +27,6 @@ bool Memory::mapCXI(NCSD& ncsd, NCCH& cxi) { // Round up the size of the CXI stack size to a page (4KB) boundary, as the OS can only allocate memory this way u32 stackSize = (cxi.stackSize + pageSize - 1) & -pageSize; - if (stackSize > 512_KB) { - // TODO: Figure out the actual max stack size - Helpers::warn("CXI stack size is %08X which seems way too big. Clamping to 512KB", stackSize); - stackSize = 512_KB; - } - // Allocate stack if (!allocateMainThreadStack(stackSize)) { // Should be unreachable