summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/kernel.cpp28
-rw-r--r--src/core/hle/kernel/physical_core.cpp25
-rw-r--r--src/core/hle/kernel/physical_core.h14
3 files changed, 43 insertions, 24 deletions
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 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <array>
5#include <atomic> 6#include <atomic>
6#include <bitset> 7#include <bitset>
7#include <functional> 8#include <functional>
@@ -16,7 +17,9 @@
16#include "common/microprofile.h" 17#include "common/microprofile.h"
17#include "common/thread.h" 18#include "common/thread.h"
18#include "core/arm/arm_interface.h" 19#include "core/arm/arm_interface.h"
20#include "core/arm/cpu_interrupt_handler.h"
19#include "core/arm/exclusive_monitor.h" 21#include "core/arm/exclusive_monitor.h"
22#include "core/arm/unicorn/arm_unicorn.h"
20#include "core/core.h" 23#include "core/core.h"
21#include "core/core_timing.h" 24#include "core/core_timing.h"
22#include "core/core_timing_util.h" 25#include "core/core_timing_util.h"
@@ -42,6 +45,11 @@
42#include "core/hle/result.h" 45#include "core/hle/result.h"
43#include "core/memory.h" 46#include "core/memory.h"
44 47
48#ifdef ARCHITECTURE_x86_64
49#include "core/arm/dynarmic/arm_dynarmic_32.h"
50#include "core/arm/dynarmic/arm_dynarmic_64.h"
51#endif
52
45MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); 53MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70));
46 54
47namespace Kernel { 55namespace Kernel {
@@ -178,7 +186,20 @@ struct KernelCore::Impl {
178 exclusive_monitor = 186 exclusive_monitor =
179 Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); 187 Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES);
180 for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { 188 for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
181 cores.emplace_back(system, i, *exclusive_monitor); 189#ifdef ARCHITECTURE_x86_64
190 arm_interfaces_32[i] =
191 std::make_unique<Core::ARM_Dynarmic_32>(system, interrupts, *exclusive_monitor, i);
192 arm_interfaces_64[i] =
193 std::make_unique<Core::ARM_Dynarmic_64>(system, interrupts, *exclusive_monitor, i);
194#else
195 arm_interfaces_32[i] = std::make_shared<Core::ARM_Unicorn>(
196 system, interrupts, ARM_Unicorn::Arch::AArch32, i);
197 arm_interfaces_64[i] = std::make_shared<Core::ARM_Unicorn>(
198 system, interrupts, ARM_Unicorn::Arch::AArch64, i);
199 LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");
200#endif
201 cores.emplace_back(system, i, *exclusive_monitor, interrupts[i], *arm_interfaces_32[i],
202 *arm_interfaces_64[i]);
182 } 203 }
183 } 204 }
184 205
@@ -407,6 +428,11 @@ struct KernelCore::Impl {
407 std::shared_ptr<Kernel::SharedMemory> time_shared_mem; 428 std::shared_ptr<Kernel::SharedMemory> time_shared_mem;
408 429
409 std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; 430 std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{};
431 std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{};
432 std::array<std::unique_ptr<Core::ARM_Interface>, Core::Hardware::NUM_CPU_CORES>
433 arm_interfaces_32{};
434 std::array<std::unique_ptr<Core::ARM_Interface>, Core::Hardware::NUM_CPU_CORES>
435 arm_interfaces_64{};
410 436
411 bool is_multicore{}; 437 bool is_multicore{};
412 std::thread::id single_core_thread_id{}; 438 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 @@
21namespace Kernel { 21namespace Kernel {
22 22
23PhysicalCore::PhysicalCore(Core::System& system, std::size_t id, 23PhysicalCore::PhysicalCore(Core::System& system, std::size_t id,
24 Core::ExclusiveMonitor& exclusive_monitor) 24 Core::ExclusiveMonitor& exclusive_monitor,
25 : interrupt_handler{}, core_index{id} { 25 Core::CPUInterruptHandler& interrupt_handler,
26#ifdef ARCHITECTURE_x86_64 26 Core::ARM_Interface& arm_interface32,
27 arm_interface_32 = std::make_unique<Core::ARM_Dynarmic_32>(system, interrupt_handler, 27 Core::ARM_Interface& arm_interface64)
28 exclusive_monitor, core_index); 28 : interrupt_handler{interrupt_handler}, core_index{id}, arm_interface_32{arm_interface32},
29 arm_interface_64 = std::make_unique<Core::ARM_Dynarmic_64>(system, interrupt_handler, 29 arm_interface_64{arm_interface64} {
30 exclusive_monitor, core_index);
31#else
32 using Core::ARM_Unicorn;
33 arm_interface_32 =
34 std::make_unique<ARM_Unicorn>(system, interrupt_handler, ARM_Unicorn::Arch::AArch32);
35 arm_interface_64 =
36 std::make_unique<ARM_Unicorn>(system, interrupt_handler, ARM_Unicorn::Arch::AArch64);
37 LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");
38#endif
39 30
40 scheduler = std::make_unique<Kernel::Scheduler>(system, core_index); 31 scheduler = std::make_unique<Kernel::Scheduler>(system, core_index);
41 guard = std::make_unique<Common::SpinLock>(); 32 guard = std::make_unique<Common::SpinLock>();
@@ -69,9 +60,9 @@ void PhysicalCore::Shutdown() {
69 60
70void PhysicalCore::SetIs64Bit(bool is_64_bit) { 61void PhysicalCore::SetIs64Bit(bool is_64_bit) {
71 if (is_64_bit) { 62 if (is_64_bit) {
72 arm_interface = arm_interface_64.get(); 63 arm_interface = &arm_interface_64;
73 } else { 64 } else {
74 arm_interface = arm_interface_32.get(); 65 arm_interface = &arm_interface_32;
75 } 66 }
76} 67}
77 68
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 @@
10#include "core/arm/cpu_interrupt_handler.h" 10#include "core/arm/cpu_interrupt_handler.h"
11 11
12namespace Common { 12namespace Common {
13 class SpinLock; 13class SpinLock;
14} 14}
15 15
16namespace Kernel { 16namespace Kernel {
@@ -27,7 +27,9 @@ namespace Kernel {
27 27
28class PhysicalCore { 28class PhysicalCore {
29public: 29public:
30 PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor); 30 PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor,
31 Core::CPUInterruptHandler& interrupt_handler, Core::ARM_Interface& arm_interface32,
32 Core::ARM_Interface& arm_interface64);
31 ~PhysicalCore(); 33 ~PhysicalCore();
32 34
33 PhysicalCore(const PhysicalCore&) = delete; 35 PhysicalCore(const PhysicalCore&) = delete;
@@ -92,13 +94,13 @@ public:
92 void SetIs64Bit(bool is_64_bit); 94 void SetIs64Bit(bool is_64_bit);
93 95
94private: 96private:
95 Core::CPUInterruptHandler interrupt_handler; 97 Core::CPUInterruptHandler& interrupt_handler;
96 std::size_t core_index; 98 std::size_t core_index;
97 std::unique_ptr<Core::ARM_Interface> arm_interface_32; 99 Core::ARM_Interface& arm_interface_32;
98 std::unique_ptr<Core::ARM_Interface> arm_interface_64; 100 Core::ARM_Interface& arm_interface_64;
99 std::unique_ptr<Kernel::Scheduler> scheduler; 101 std::unique_ptr<Kernel::Scheduler> scheduler;
100 Core::ARM_Interface* arm_interface{}; 102 Core::ARM_Interface* arm_interface{};
101 std::unique_ptr<Common::SpinLock> guard; 103 std::unique_ptr<Common::SpinLock> guard;
102}; 104};
103 105
104} // namespace Kernel 106} // namespace Kernel