From 1b82ccec2220a69711ba75cf51ee98cbcfe6a510 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 29 Feb 2020 13:58:50 -0400 Subject: Core: Refactor ARM Interface. --- src/core/hle/kernel/kernel.cpp | 28 +++++++++++++++++++++++++++- src/core/hle/kernel/physical_core.cpp | 25 ++++++++----------------- src/core/hle/kernel/physical_core.h | 14 ++++++++------ 3 files changed, 43 insertions(+), 24 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index a19cd7a1f..e33ef5323 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include #include @@ -16,7 +17,9 @@ #include "common/microprofile.h" #include "common/thread.h" #include "core/arm/arm_interface.h" +#include "core/arm/cpu_interrupt_handler.h" #include "core/arm/exclusive_monitor.h" +#include "core/arm/unicorn/arm_unicorn.h" #include "core/core.h" #include "core/core_timing.h" #include "core/core_timing_util.h" @@ -42,6 +45,11 @@ #include "core/hle/result.h" #include "core/memory.h" +#ifdef ARCHITECTURE_x86_64 +#include "core/arm/dynarmic/arm_dynarmic_32.h" +#include "core/arm/dynarmic/arm_dynarmic_64.h" +#endif + MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); namespace Kernel { @@ -178,7 +186,20 @@ struct KernelCore::Impl { exclusive_monitor = Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { - cores.emplace_back(system, i, *exclusive_monitor); +#ifdef ARCHITECTURE_x86_64 + arm_interfaces_32[i] = + std::make_unique(system, interrupts, *exclusive_monitor, i); + arm_interfaces_64[i] = + std::make_unique(system, interrupts, *exclusive_monitor, i); +#else + arm_interfaces_32[i] = std::make_shared( + system, interrupts, ARM_Unicorn::Arch::AArch32, i); + arm_interfaces_64[i] = std::make_shared( + system, interrupts, ARM_Unicorn::Arch::AArch64, i); + LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available"); +#endif + cores.emplace_back(system, i, *exclusive_monitor, interrupts[i], *arm_interfaces_32[i], + *arm_interfaces_64[i]); } } @@ -407,6 +428,11 @@ struct KernelCore::Impl { std::shared_ptr time_shared_mem; std::array, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; + std::array interrupts{}; + std::array, Core::Hardware::NUM_CPU_CORES> + arm_interfaces_32{}; + std::array, Core::Hardware::NUM_CPU_CORES> + arm_interfaces_64{}; bool is_multicore{}; std::thread::id single_core_thread_id{}; diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index ff14fcb42..9146b331d 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -21,21 +21,12 @@ namespace Kernel { PhysicalCore::PhysicalCore(Core::System& system, std::size_t id, - Core::ExclusiveMonitor& exclusive_monitor) - : interrupt_handler{}, core_index{id} { -#ifdef ARCHITECTURE_x86_64 - arm_interface_32 = std::make_unique(system, interrupt_handler, - exclusive_monitor, core_index); - arm_interface_64 = std::make_unique(system, interrupt_handler, - exclusive_monitor, core_index); -#else - using Core::ARM_Unicorn; - arm_interface_32 = - std::make_unique(system, interrupt_handler, ARM_Unicorn::Arch::AArch32); - arm_interface_64 = - std::make_unique(system, interrupt_handler, ARM_Unicorn::Arch::AArch64); - LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available"); -#endif + Core::ExclusiveMonitor& exclusive_monitor, + Core::CPUInterruptHandler& interrupt_handler, + Core::ARM_Interface& arm_interface32, + Core::ARM_Interface& arm_interface64) + : interrupt_handler{interrupt_handler}, core_index{id}, arm_interface_32{arm_interface32}, + arm_interface_64{arm_interface64} { scheduler = std::make_unique(system, core_index); guard = std::make_unique(); @@ -69,9 +60,9 @@ void PhysicalCore::Shutdown() { void PhysicalCore::SetIs64Bit(bool is_64_bit) { if (is_64_bit) { - arm_interface = arm_interface_64.get(); + arm_interface = &arm_interface_64; } else { - arm_interface = arm_interface_32.get(); + arm_interface = &arm_interface_32; } } diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index cd2e42fc3..2673d90f2 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h @@ -10,7 +10,7 @@ #include "core/arm/cpu_interrupt_handler.h" namespace Common { - class SpinLock; +class SpinLock; } namespace Kernel { @@ -27,7 +27,9 @@ namespace Kernel { class PhysicalCore { public: - PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor); + PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor, + Core::CPUInterruptHandler& interrupt_handler, Core::ARM_Interface& arm_interface32, + Core::ARM_Interface& arm_interface64); ~PhysicalCore(); PhysicalCore(const PhysicalCore&) = delete; @@ -92,13 +94,13 @@ public: void SetIs64Bit(bool is_64_bit); private: - Core::CPUInterruptHandler interrupt_handler; + Core::CPUInterruptHandler& interrupt_handler; std::size_t core_index; - std::unique_ptr arm_interface_32; - std::unique_ptr arm_interface_64; + Core::ARM_Interface& arm_interface_32; + Core::ARM_Interface& arm_interface_64; std::unique_ptr scheduler; Core::ARM_Interface* arm_interface{}; - std::unique_ptr guard; + std::unique_ptr guard; }; } // namespace Kernel -- cgit v1.2.3