summaryrefslogtreecommitdiffstats
path: root/src/core/arm/unicorn
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-04-07 00:46:18 +0200
committerLioncash <mathew1800@gmail.com>2019-04-08 02:30:05 +0200
commitb117ca5fce0344997a09260d835b27dbd2602507 (patch)
treea351c981e559de4cb31142b4b7436a638511c0f3 /src/core/arm/unicorn
parentMerge pull request #2300 from FernandoS27/null-shader (diff)
downloadyuzu-b117ca5fce0344997a09260d835b27dbd2602507.tar
yuzu-b117ca5fce0344997a09260d835b27dbd2602507.tar.gz
yuzu-b117ca5fce0344997a09260d835b27dbd2602507.tar.bz2
yuzu-b117ca5fce0344997a09260d835b27dbd2602507.tar.lz
yuzu-b117ca5fce0344997a09260d835b27dbd2602507.tar.xz
yuzu-b117ca5fce0344997a09260d835b27dbd2602507.tar.zst
yuzu-b117ca5fce0344997a09260d835b27dbd2602507.zip
Diffstat (limited to 'src/core/arm/unicorn')
-rw-r--r--src/core/arm/unicorn/arm_unicorn.cpp37
-rw-r--r--src/core/arm/unicorn/arm_unicorn.h12
2 files changed, 25 insertions, 24 deletions
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp
index 27309280c..4e07fe8b5 100644
--- a/src/core/arm/unicorn/arm_unicorn.cpp
+++ b/src/core/arm/unicorn/arm_unicorn.cpp
@@ -10,7 +10,6 @@
#include "core/core.h"
#include "core/core_timing.h"
#include "core/hle/kernel/svc.h"
-#include "core/memory.h"
namespace Core {
@@ -49,20 +48,6 @@ static void CodeHook(uc_engine* uc, uint64_t address, uint32_t size, void* user_
}
}
-static void InterruptHook(uc_engine* uc, u32 intNo, void* user_data) {
- u32 esr{};
- CHECKED(uc_reg_read(uc, UC_ARM64_REG_ESR, &esr));
-
- auto ec = esr >> 26;
- auto iss = esr & 0xFFFFFF;
-
- switch (ec) {
- case 0x15: // SVC
- Kernel::CallSVC(iss);
- break;
- }
-}
-
static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int size, u64 value,
void* user_data) {
ARM_Interface::ThreadContext ctx{};
@@ -72,7 +57,7 @@ static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int si
return {};
}
-ARM_Unicorn::ARM_Unicorn(Timing::CoreTiming& core_timing) : core_timing{core_timing} {
+ARM_Unicorn::ARM_Unicorn(System& system) : system{system} {
CHECKED(uc_open(UC_ARCH_ARM64, UC_MODE_ARM, &uc));
auto fpv = 3 << 20;
@@ -177,7 +162,7 @@ void ARM_Unicorn::Run() {
if (GDBStub::IsServerEnabled()) {
ExecuteInstructions(std::max(4000000, 0));
} else {
- ExecuteInstructions(std::max(core_timing.GetDowncount(), 0));
+ ExecuteInstructions(std::max(system.CoreTiming().GetDowncount(), 0));
}
}
@@ -190,7 +175,7 @@ MICROPROFILE_DEFINE(ARM_Jit_Unicorn, "ARM JIT", "Unicorn", MP_RGB(255, 64, 64));
void ARM_Unicorn::ExecuteInstructions(int num_instructions) {
MICROPROFILE_SCOPE(ARM_Jit_Unicorn);
CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions));
- core_timing.AddTicks(num_instructions);
+ system.CoreTiming().AddTicks(num_instructions);
if (GDBStub::IsServerEnabled()) {
if (last_bkpt_hit && last_bkpt.type == GDBStub::BreakpointType::Execute) {
uc_reg_write(uc, UC_ARM64_REG_PC, &last_bkpt.address);
@@ -273,4 +258,20 @@ void ARM_Unicorn::RecordBreak(GDBStub::BreakpointAddress bkpt) {
last_bkpt_hit = true;
}
+void ARM_Unicorn::InterruptHook(uc_engine* uc, u32 int_no, void* user_data) {
+ u32 esr{};
+ CHECKED(uc_reg_read(uc, UC_ARM64_REG_ESR, &esr));
+
+ const auto ec = esr >> 26;
+ const auto iss = esr & 0xFFFFFF;
+
+ auto* const arm_instance = static_cast<ARM_Unicorn*>(user_data);
+
+ switch (ec) {
+ case 0x15: // SVC
+ Kernel::CallSVC(arm_instance->system, iss);
+ break;
+ }
+}
+
} // namespace Core
diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h
index 1e44f0736..209fc16ad 100644
--- a/src/core/arm/unicorn/arm_unicorn.h
+++ b/src/core/arm/unicorn/arm_unicorn.h
@@ -9,15 +9,13 @@
#include "core/arm/arm_interface.h"
#include "core/gdbstub/gdbstub.h"
-namespace Core::Timing {
-class CoreTiming;
-}
-
namespace Core {
+class System;
+
class ARM_Unicorn final : public ARM_Interface {
public:
- explicit ARM_Unicorn(Timing::CoreTiming& core_timing);
+ explicit ARM_Unicorn(System& system);
~ARM_Unicorn() override;
void MapBackingMemory(VAddr address, std::size_t size, u8* memory,
@@ -47,8 +45,10 @@ public:
void RecordBreak(GDBStub::BreakpointAddress bkpt);
private:
+ static void InterruptHook(uc_engine* uc, u32 int_no, void* user_data);
+
uc_engine* uc{};
- Timing::CoreTiming& core_timing;
+ System& system;
GDBStub::BreakpointAddress last_bkpt{};
bool last_bkpt_hit = false;
};