From 44d728cc1cdb72375bcf6925d5f5b84cd9c4cc39 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 28 Mar 2024 00:24:45 -0700 Subject: [PATCH] kern: pass kernel base from KernelLdr to Kernel --- libmesosphere/include/mesosphere/kern_initial_process.hpp | 1 + .../include/mesosphere/kern_k_system_control_base.hpp | 2 +- libmesosphere/source/kern_k_system_control_base.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libmesosphere/include/mesosphere/kern_initial_process.hpp b/libmesosphere/include/mesosphere/kern_initial_process.hpp index 91129819..a7dfeab7 100644 --- a/libmesosphere/include/mesosphere/kern_initial_process.hpp +++ b/libmesosphere/include/mesosphere/kern_initial_process.hpp @@ -32,6 +32,7 @@ namespace ams::kern { struct InitialProcessBinaryLayout { uintptr_t address; uintptr_t _08; + uintptr_t kern_address; }; struct InitialProcessBinaryLayoutWithSize { diff --git a/libmesosphere/include/mesosphere/kern_k_system_control_base.hpp b/libmesosphere/include/mesosphere/kern_k_system_control_base.hpp index 095bff49..bb1c1ff0 100644 --- a/libmesosphere/include/mesosphere/kern_k_system_control_base.hpp +++ b/libmesosphere/include/mesosphere/kern_k_system_control_base.hpp @@ -53,7 +53,7 @@ namespace ams::kern { static size_t GetRealMemorySize(); static size_t GetIntendedMemorySize(); static KPhysicalAddress GetKernelPhysicalBaseAddress(KPhysicalAddress base_address); - static void GetInitialProcessBinaryLayout(InitialProcessBinaryLayout *out); + static void GetInitialProcessBinaryLayout(InitialProcessBinaryLayout *out, KPhysicalAddress kern_base_address); static bool ShouldIncreaseThreadResourceLimit(); static void TurnOnCpu(u64 core_id, const ams::kern::init::KInitArguments *args); static size_t GetApplicationPoolSize(); diff --git a/libmesosphere/source/kern_k_system_control_base.cpp b/libmesosphere/source/kern_k_system_control_base.cpp index 77582203..6764662d 100644 --- a/libmesosphere/source/kern_k_system_control_base.cpp +++ b/libmesosphere/source/kern_k_system_control_base.cpp @@ -46,10 +46,11 @@ namespace ams::kern { } } - void KSystemControlBase::Init::GetInitialProcessBinaryLayout(InitialProcessBinaryLayout *out) { + void KSystemControlBase::Init::GetInitialProcessBinaryLayout(InitialProcessBinaryLayout *out, KPhysicalAddress kern_base_address) { *out = { - .address = GetInteger(KSystemControl::Init::GetKernelPhysicalBaseAddress(ams::kern::MainMemoryAddress)) + KSystemControl::Init::GetIntendedMemorySize() - InitialProcessBinarySizeMax, - ._08 = 0, + .address = GetInteger(KSystemControl::Init::GetKernelPhysicalBaseAddress(ams::kern::MainMemoryAddress)) + KSystemControl::Init::GetIntendedMemorySize() - InitialProcessBinarySizeMax, + ._08 = 0, + .kern_address = GetInteger(kern_base_address), }; }