summaryrefslogtreecommitdiff
path: root/src/core/arm
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-29 13:58:50 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:56 -0400
commit1b82ccec2220a69711ba75cf51ee98cbcfe6a510 (patch)
tree281ad19080ec4e6e14caa50b073acdfac005212b /src/core/arm
parentX64 Clock: Reduce accuracy to be less or equal to guest accuracy. (diff)
downloadyuzu-1b82ccec2220a69711ba75cf51ee98cbcfe6a510.tar.gz
yuzu-1b82ccec2220a69711ba75cf51ee98cbcfe6a510.tar.xz
yuzu-1b82ccec2220a69711ba75cf51ee98cbcfe6a510.zip
Core: Refactor ARM Interface.
Diffstat (limited to 'src/core/arm')
-rw-r--r--src/core/arm/arm_interface.h9
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_32.cpp6
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_32.h2
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_64.cpp13
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_64.h2
-rw-r--r--src/core/arm/unicorn/arm_unicorn.cpp7
-rw-r--r--src/core/arm/unicorn/arm_unicorn.h5
7 files changed, 26 insertions, 18 deletions
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index e701ddf21..dc9b2ff7b 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -7,6 +7,7 @@
7#include <array> 7#include <array>
8#include <vector> 8#include <vector>
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "core/hardware_properties.h"
10 11
11namespace Common { 12namespace Common {
12struct PageTable; 13struct PageTable;
@@ -20,11 +21,13 @@ namespace Core {
20class System; 21class System;
21class CPUInterruptHandler; 22class CPUInterruptHandler;
22 23
24using CPUInterrupts = std::array<CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>;
25
23/// Generic ARMv8 CPU interface 26/// Generic ARMv8 CPU interface
24class ARM_Interface : NonCopyable { 27class ARM_Interface : NonCopyable {
25public: 28public:
26 explicit ARM_Interface(System& system_, CPUInterruptHandler& interrupt_handler) 29 explicit ARM_Interface(System& system_, CPUInterrupts& interrupt_handlers)
27 : system{system_}, interrupt_handler{interrupt_handler} {} 30 : system{system_}, interrupt_handlers{interrupt_handlers} {}
28 virtual ~ARM_Interface() = default; 31 virtual ~ARM_Interface() = default;
29 32
30 struct ThreadContext32 { 33 struct ThreadContext32 {
@@ -180,7 +183,7 @@ public:
180protected: 183protected:
181 /// System context that this ARM interface is running under. 184 /// System context that this ARM interface is running under.
182 System& system; 185 System& system;
183 CPUInterruptHandler& interrupt_handler; 186 CPUInterrupts& interrupt_handlers;
184}; 187};
185 188
186} // namespace Core 189} // namespace Core
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp
index c8a1ce6e7..f36c5f401 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp
@@ -76,7 +76,7 @@ public:
76 } 76 }
77 77
78 u64 GetTicksRemaining() override { 78 u64 GetTicksRemaining() override {
79 if (!parent.interrupt_handler.IsInterrupted()) { 79 if (!parent.interrupt_handlers[parent.core_index].IsInterrupted()) {
80 return std::max<s64>(ticks, 0); 80 return std::max<s64>(ticks, 0);
81 } 81 }
82 return 0ULL; 82 return 0ULL;
@@ -111,9 +111,9 @@ void ARM_Dynarmic_32::Step() {
111 jit->Step(); 111 jit->Step();
112} 112}
113 113
114ARM_Dynarmic_32::ARM_Dynarmic_32(System& system, CPUInterruptHandler& interrupt_handler, 114ARM_Dynarmic_32::ARM_Dynarmic_32(System& system, CPUInterrupts& interrupt_handlers,
115 ExclusiveMonitor& exclusive_monitor, std::size_t core_index) 115 ExclusiveMonitor& exclusive_monitor, std::size_t core_index)
116 : ARM_Interface{system, interrupt_handler}, cb(std::make_unique<DynarmicCallbacks32>(*this)), 116 : ARM_Interface{system, interrupt_handlers}, cb(std::make_unique<DynarmicCallbacks32>(*this)),
117 cp15(std::make_shared<DynarmicCP15>(*this)), core_index{core_index}, 117 cp15(std::make_shared<DynarmicCP15>(*this)), core_index{core_index},
118 exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} 118 exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {}
119 119
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h
index 1e7e17e64..2dd9a4df0 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_32.h
+++ b/src/core/arm/dynarmic/arm_dynarmic_32.h
@@ -29,7 +29,7 @@ class System;
29 29
30class ARM_Dynarmic_32 final : public ARM_Interface { 30class ARM_Dynarmic_32 final : public ARM_Interface {
31public: 31public:
32 ARM_Dynarmic_32(System& system, CPUInterruptHandler& interrupt_handler, 32 ARM_Dynarmic_32(System& system, CPUInterrupts& interrupt_handlers,
33 ExclusiveMonitor& exclusive_monitor, std::size_t core_index); 33 ExclusiveMonitor& exclusive_monitor, std::size_t core_index);
34 ~ARM_Dynarmic_32() override; 34 ~ARM_Dynarmic_32() override;
35 35
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
index 3f18dede2..8401ba631 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
@@ -128,7 +128,7 @@ public:
128 } 128 }
129 129
130 u64 GetTicksRemaining() override { 130 u64 GetTicksRemaining() override {
131 if (!parent.interrupt_handler.IsInterrupted()) { 131 if (!parent.interrupt_handlers[parent.core_index].IsInterrupted()) {
132 return std::max<s64>(ticks, 0); 132 return std::max<s64>(ticks, 0);
133 } 133 }
134 return 0ULL; 134 return 0ULL;
@@ -199,11 +199,14 @@ void ARM_Dynarmic_64::Step() {
199 cb->InterpreterFallback(jit->GetPC(), 1); 199 cb->InterpreterFallback(jit->GetPC(), 1);
200} 200}
201 201
202ARM_Dynarmic_64::ARM_Dynarmic_64(System& system, CPUInterruptHandler& interrupt_handler, 202ARM_Dynarmic_64::ARM_Dynarmic_64(System& system, CPUInterrupts& interrupt_handlers,
203 ExclusiveMonitor& exclusive_monitor, std::size_t core_index) 203 ExclusiveMonitor& exclusive_monitor, std::size_t core_index)
204 : ARM_Interface{system, interrupt_handler}, cb(std::make_unique<DynarmicCallbacks64>(*this)), 204 : ARM_Interface{system, interrupt_handler},
205 inner_unicorn{system, interrupt_handler, ARM_Unicorn::Arch::AArch64}, core_index{core_index}, 205 cb(std::make_unique<DynarmicCallbacks64>(*this)), inner_unicorn{system, interrupt_handler,
206 exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} 206 ARM_Unicorn::Arch::AArch64,
207 core_index},
208 core_index{core_index}, exclusive_monitor{
209 dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {}
207 210
208ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; 211ARM_Dynarmic_64::~ARM_Dynarmic_64() = default;
209 212
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h
index 5560578ad..1c6791d4e 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_64.h
+++ b/src/core/arm/dynarmic/arm_dynarmic_64.h
@@ -28,7 +28,7 @@ class System;
28 28
29class ARM_Dynarmic_64 final : public ARM_Interface { 29class ARM_Dynarmic_64 final : public ARM_Interface {
30public: 30public:
31 ARM_Dynarmic_64(System& system, CPUInterruptHandler& interrupt_handler, 31 ARM_Dynarmic_64(System& system, CPUInterrupts& interrupt_handlers,
32 ExclusiveMonitor& exclusive_monitor, std::size_t core_index); 32 ExclusiveMonitor& exclusive_monitor, std::size_t core_index);
33 ~ARM_Dynarmic_64() override; 33 ~ARM_Dynarmic_64() override;
34 34
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp
index 0393fe641..d81d1b5b0 100644
--- a/src/core/arm/unicorn/arm_unicorn.cpp
+++ b/src/core/arm/unicorn/arm_unicorn.cpp
@@ -63,8 +63,9 @@ static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int si
63 return false; 63 return false;
64} 64}
65 65
66ARM_Unicorn::ARM_Unicorn(System& system, CPUInterruptHandler& interrupt_handler, Arch architecture) 66ARM_Unicorn::ARM_Unicorn(System& system, CPUInterruptHandler& interrupt_handler, Arch architecture,
67 : ARM_Interface{system, interrupt_handler} { 67 std::size_t core_index)
68 : ARM_Interface{system, interrupt_handler}, core_index{core_index} {
68 const auto arch = architecture == Arch::AArch32 ? UC_ARCH_ARM : UC_ARCH_ARM64; 69 const auto arch = architecture == Arch::AArch32 ? UC_ARCH_ARM : UC_ARCH_ARM64;
69 CHECKED(uc_open(arch, UC_MODE_ARM, &uc)); 70 CHECKED(uc_open(arch, UC_MODE_ARM, &uc));
70 71
@@ -163,7 +164,7 @@ void ARM_Unicorn::Run() {
163 ExecuteInstructions(std::max(4000000U, 0U)); 164 ExecuteInstructions(std::max(4000000U, 0U));
164 } else { 165 } else {
165 while (true) { 166 while (true) {
166 if (interrupt_handler.IsInterrupted()) { 167 if (interrupt_handlers[core_index].IsInterrupted()) {
167 return; 168 return;
168 } 169 }
169 ExecuteInstructions(10); 170 ExecuteInstructions(10);
diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h
index 0a4c087cd..e3da368de 100644
--- a/src/core/arm/unicorn/arm_unicorn.h
+++ b/src/core/arm/unicorn/arm_unicorn.h
@@ -11,7 +11,6 @@
11 11
12namespace Core { 12namespace Core {
13 13
14class CPUInterruptHandler;
15class System; 14class System;
16 15
17class ARM_Unicorn final : public ARM_Interface { 16class ARM_Unicorn final : public ARM_Interface {
@@ -21,7 +20,8 @@ public:
21 AArch64, // 64-bit ARM 20 AArch64, // 64-bit ARM
22 }; 21 };
23 22
24 explicit ARM_Unicorn(System& system, CPUInterruptHandler& interrupt_handler, Arch architecture); 23 explicit ARM_Unicorn(System& system, CPUInterruptHandler& interrupt_handler, Arch architecture,
24 std::size_t core_index);
25 ~ARM_Unicorn() override; 25 ~ARM_Unicorn() override;
26 26
27 void SetPC(u64 pc) override; 27 void SetPC(u64 pc) override;
@@ -56,6 +56,7 @@ private:
56 uc_engine* uc{}; 56 uc_engine* uc{};
57 GDBStub::BreakpointAddress last_bkpt{}; 57 GDBStub::BreakpointAddress last_bkpt{};
58 bool last_bkpt_hit = false; 58 bool last_bkpt_hit = false;
59 std::size_t core_index;
59}; 60};
60 61
61} // namespace Core 62} // namespace Core