From 43a0706e96f6e6ba41ed33e949d9e52494baef35 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 1 Dec 2020 13:08:47 -0800 Subject: [PATCH] kern: remove more of clc --- .../arch/arm64/kern_k_hardware_timer.hpp | 2 +- .../mesosphere/kern_k_core_local_region.hpp | 12 ------------ .../source/arch/arm64/kern_k_hardware_timer.cpp | 4 ++-- libmesosphere/source/kern_kernel.cpp | 16 ++-------------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/libmesosphere/include/mesosphere/arch/arm64/kern_k_hardware_timer.hpp b/libmesosphere/include/mesosphere/arch/arm64/kern_k_hardware_timer.hpp index a7ebf846..2f805ca5 100644 --- a/libmesosphere/include/mesosphere/arch/arm64/kern_k_hardware_timer.hpp +++ b/libmesosphere/include/mesosphere/arch/arm64/kern_k_hardware_timer.hpp @@ -26,7 +26,7 @@ namespace ams::kern::arch::arm64 { constexpr KHardwareTimer() : KInterruptTask(), KHardwareTimerBase(), maximum_time(std::numeric_limits::max()) { /* ... */ } public: /* Public API. */ - NOINLINE void Initialize(s32 core_id); + NOINLINE void Initialize(); NOINLINE void Finalize(); static s64 GetTick() { diff --git a/libmesosphere/include/mesosphere/kern_k_core_local_region.hpp b/libmesosphere/include/mesosphere/kern_k_core_local_region.hpp index a70d886a..9a686135 100644 --- a/libmesosphere/include/mesosphere/kern_k_core_local_region.hpp +++ b/libmesosphere/include/mesosphere/kern_k_core_local_region.hpp @@ -27,18 +27,6 @@ namespace ams::kern { struct KCoreLocalContext { KCurrentContext current; - /* Everything after this point is for debugging. */ - /* Retail kernel doesn't even consistently update these fields. */ - u64 num_sw_interrupts; - u64 num_hw_interrupts; - std::atomic num_svc; - u64 num_process_switches; - u64 num_thread_switches; - u64 num_fpu_switches; - u64 num_scheduler_updates; - u64 num_invoked_scheduler_updates; - std::atomic num_specific_svc[0x80]; - u32 perf_counters[6]; }; static_assert(sizeof(KCoreLocalContext) < PageSize); diff --git a/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp b/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp index 280a66f8..fa42d676 100644 --- a/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp +++ b/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp @@ -17,7 +17,7 @@ namespace ams::kern::arch::arm64 { - void KHardwareTimer::Initialize(s32 core_id) { + void KHardwareTimer::Initialize() { /* Setup the global timer for the core. */ InitializeGlobalTimer(); @@ -25,7 +25,7 @@ namespace ams::kern::arch::arm64 { this->maximum_time = static_cast(std::min(std::numeric_limits::max(), cpu::CounterTimerPhysicalTimerCompareValueRegisterAccessor().GetCompareValue())); /* Bind the interrupt task for this core. */ - Kernel::GetInterruptManager().BindHandler(std::addressof(Kernel::GetHardwareTimer(core_id)), KInterruptName_NonSecurePhysicalTimer, core_id, KInterruptController::PriorityLevel_Timer, true, true); + Kernel::GetInterruptManager().BindHandler(this, KInterruptName_NonSecurePhysicalTimer, GetCurrentCoreId(), KInterruptController::PriorityLevel_Timer, true, true); } void KHardwareTimer::Finalize() { diff --git a/libmesosphere/source/kern_kernel.cpp b/libmesosphere/source/kern_kernel.cpp index e56321c7..35ba1c3e 100644 --- a/libmesosphere/source/kern_kernel.cpp +++ b/libmesosphere/source/kern_kernel.cpp @@ -49,22 +49,10 @@ namespace ams::kern { /* Initialize current context. */ clc->current.current_thread = nullptr; clc->current.current_process = nullptr; + clc->current.core_id = core_id; clc->current.scheduler = std::addressof(Kernel::GetScheduler()); clc->current.interrupt_task_manager = std::addressof(Kernel::GetInterruptTaskManager()); - clc->current.core_id = core_id; clc->current.exception_stack_top = GetVoidPointer(KMemoryLayout::GetExceptionStackTopAddress(core_id) - sizeof(KThread::StackParameters)); - - /* Clear debugging counters. */ - clc->num_sw_interrupts = 0; - clc->num_hw_interrupts = 0; - clc->num_svc = 0; - clc->num_process_switches = 0; - clc->num_thread_switches = 0; - clc->num_fpu_switches = 0; - - for (size_t i = 0; i < util::size(clc->perf_counters); i++) { - clc->perf_counters[i] = 0; - } } void Kernel::InitializeMainAndIdleThreads(s32 core_id) { @@ -84,7 +72,7 @@ namespace ams::kern { /* Initialize the interrupt manager, hardware timer, and scheduler */ GetInterruptManager().Initialize(core_id); - GetHardwareTimer().Initialize(core_id); + GetHardwareTimer().Initialize(); GetScheduler().Initialize(idle_thread); }