From 79201428b0588a577a4e178ec42e25da33afd699 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 17 Aug 2020 16:00:55 -0700 Subject: [PATCH] kern: resolve NonSecure definition TODO --- .../board/nintendo/nx/kern_k_system_control.cpp | 7 +++++-- .../svc/board/nintendo/nx/svc_device_name.hpp | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp index 4b6aed0e8..11f6cfc9b 100644 --- a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp +++ b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp @@ -387,8 +387,11 @@ namespace ams::kern::board::nintendo::nx { } size_t KSystemControl::Init::GetMinimumNonSecureSystemPoolSize() { - /* TODO: Where does this constant actually come from? */ - return 0x29C8000; + /* Verify that our minimum is at least as large as Nintendo's. */ + constexpr size_t MinimumSize = ::ams::svc::RequiredNonSecureSystemMemorySize; + static_assert(MinimumSize >= 0x29C8000); + + return MinimumSize; } void KSystemControl::Init::CpuOn(u64 core_id, uintptr_t entrypoint, uintptr_t arg) { diff --git a/libraries/libvapours/include/vapours/svc/board/nintendo/nx/svc_device_name.hpp b/libraries/libvapours/include/vapours/svc/board/nintendo/nx/svc_device_name.hpp index fb289dd83..9700a1929 100644 --- a/libraries/libvapours/include/vapours/svc/board/nintendo/nx/svc_device_name.hpp +++ b/libraries/libvapours/include/vapours/svc/board/nintendo/nx/svc_device_name.hpp @@ -62,4 +62,16 @@ namespace ams::svc::board::nintendo::nx { DeviceName_Count, }; + namespace impl { + + constexpr inline const size_t RequiredNonSecureSystemMemorySizeVi = 0x2238 * 4_KB; + constexpr inline const size_t RequiredNonSecureSystemMemorySizeNvservices = 0x710 * 4_KB; + constexpr inline const size_t RequiredNonSecureSystemMemorySizeMisc = 0x80 * 4_KB; + + } + + constexpr inline const size_t RequiredNonSecureSystemMemorySize = impl::RequiredNonSecureSystemMemorySizeVi + + impl::RequiredNonSecureSystemMemorySizeNvservices + + impl::RequiredNonSecureSystemMemorySizeMisc; + }