summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Lioncash2019-11-26 14:10:49 -0500
committerGravatar Lioncash2019-11-26 21:55:37 -0500
commit536fc7f0ea77e08d68c760f387c307d258804e3b (patch)
treee979df531bf1222788cc26144531c6e6f5cca1d1 /src/core
parentcore/memory: Move memory read/write implementation functions into an anonymou... (diff)
downloadyuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.gz
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.xz
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.zip
core: Prepare various classes for memory read/write migration
Amends a few interfaces to be able to handle the migration over to the new Memory class by passing the class by reference as a function parameter where necessary. Notably, within the filesystem services, this eliminates two ReadBlock() calls by using the helper functions of HLERequestContext to do that for us.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/arm/arm_interface.cpp3
-rw-r--r--src/core/arm/arm_interface.h8
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp8
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.h1
-rw-r--r--src/core/arm/unicorn/arm_unicorn.cpp2
-rw-r--r--src/core/arm/unicorn/arm_unicorn.h1
-rw-r--r--src/core/hle/kernel/client_session.cpp4
-rw-r--r--src/core/hle/kernel/client_session.h6
-rw-r--r--src/core/hle/kernel/server_session.cpp3
-rw-r--r--src/core/hle/kernel/server_session.h9
-rw-r--r--src/core/hle/kernel/svc.cpp2
-rw-r--r--src/core/hle/service/audio/audren_u.cpp5
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp7
-rw-r--r--src/core/hle/service/lm/lm.cpp13
-rw-r--r--src/core/reporter.cpp14
-rw-r--r--src/core/tools/freezer.cpp14
-rw-r--r--src/core/tools/freezer.h7
17 files changed, 66 insertions, 41 deletions
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp
index 372612c9b..dea192869 100644
--- a/src/core/arm/arm_interface.cpp
+++ b/src/core/arm/arm_interface.cpp
@@ -13,7 +13,6 @@
13#include "core/memory.h" 13#include "core/memory.h"
14 14
15namespace Core { 15namespace Core {
16
17namespace { 16namespace {
18 17
19constexpr u64 ELF_DYNAMIC_TAG_NULL = 0; 18constexpr u64 ELF_DYNAMIC_TAG_NULL = 0;
@@ -156,7 +155,7 @@ std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
156 } 155 }
157 156
158 std::map<VAddr, std::string> modules; 157 std::map<VAddr, std::string> modules;
159 auto& loader{System::GetInstance().GetAppLoader()}; 158 auto& loader{system.GetAppLoader()};
160 if (loader.ReadNSOModules(modules) != Loader::ResultStatus::Success) { 159 if (loader.ReadNSOModules(modules) != Loader::ResultStatus::Success) {
161 return {}; 160 return {};
162 } 161 }
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 45e94e625..47b964eb7 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -17,11 +17,13 @@ enum class VMAPermission : u8;
17} 17}
18 18
19namespace Core { 19namespace Core {
20class System;
20 21
21/// Generic ARMv8 CPU interface 22/// Generic ARMv8 CPU interface
22class ARM_Interface : NonCopyable { 23class ARM_Interface : NonCopyable {
23public: 24public:
24 virtual ~ARM_Interface() {} 25 explicit ARM_Interface(System& system_) : system{system_} {}
26 virtual ~ARM_Interface() = default;
25 27
26 struct ThreadContext { 28 struct ThreadContext {
27 std::array<u64, 31> cpu_registers; 29 std::array<u64, 31> cpu_registers;
@@ -163,6 +165,10 @@ public:
163 /// fp+0 : pointer to previous frame record 165 /// fp+0 : pointer to previous frame record
164 /// fp+8 : value of lr for frame 166 /// fp+8 : value of lr for frame
165 void LogBacktrace() const; 167 void LogBacktrace() const;
168
169protected:
170 /// System context that this ARM interface is running under.
171 System& system;
166}; 172};
167 173
168} // namespace Core 174} // namespace Core
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index a0705b2b8..2b396f1d6 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -28,6 +28,7 @@ public:
28 explicit ARM_Dynarmic_Callbacks(ARM_Dynarmic& parent) : parent(parent) {} 28 explicit ARM_Dynarmic_Callbacks(ARM_Dynarmic& parent) : parent(parent) {}
29 29
30 u8 MemoryRead8(u64 vaddr) override { 30 u8 MemoryRead8(u64 vaddr) override {
31 auto& s = parent.system;
31 return Memory::Read8(vaddr); 32 return Memory::Read8(vaddr);
32 } 33 }
33 u16 MemoryRead16(u64 vaddr) override { 34 u16 MemoryRead16(u64 vaddr) override {
@@ -171,9 +172,10 @@ void ARM_Dynarmic::Step() {
171 172
172ARM_Dynarmic::ARM_Dynarmic(System& system, ExclusiveMonitor& exclusive_monitor, 173ARM_Dynarmic::ARM_Dynarmic(System& system, ExclusiveMonitor& exclusive_monitor,
173 std::size_t core_index) 174 std::size_t core_index)
174 : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), inner_unicorn{system}, 175 : ARM_Interface{system},
175 core_index{core_index}, system{system}, 176 cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), inner_unicorn{system},
176 exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} 177 core_index{core_index}, exclusive_monitor{
178 dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {}
177 179
178ARM_Dynarmic::~ARM_Dynarmic() = default; 180ARM_Dynarmic::~ARM_Dynarmic() = default;
179 181
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h
index 504d46c68..d08de475f 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.h
+++ b/src/core/arm/dynarmic/arm_dynarmic.h
@@ -58,7 +58,6 @@ private:
58 ARM_Unicorn inner_unicorn; 58 ARM_Unicorn inner_unicorn;
59 59
60 std::size_t core_index; 60 std::size_t core_index;
61 System& system;
62 DynarmicExclusiveMonitor& exclusive_monitor; 61 DynarmicExclusiveMonitor& exclusive_monitor;
63}; 62};
64 63
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp
index 9698172db..48182c99a 100644
--- a/src/core/arm/unicorn/arm_unicorn.cpp
+++ b/src/core/arm/unicorn/arm_unicorn.cpp
@@ -60,7 +60,7 @@ static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int si
60 return false; 60 return false;
61} 61}
62 62
63ARM_Unicorn::ARM_Unicorn(System& system) : system{system} { 63ARM_Unicorn::ARM_Unicorn(System& system) : ARM_Interface{system} {
64 CHECKED(uc_open(UC_ARCH_ARM64, UC_MODE_ARM, &uc)); 64 CHECKED(uc_open(UC_ARCH_ARM64, UC_MODE_ARM, &uc));
65 65
66 auto fpv = 3 << 20; 66 auto fpv = 3 << 20;
diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h
index b39426ea0..3c5b155f9 100644
--- a/src/core/arm/unicorn/arm_unicorn.h
+++ b/src/core/arm/unicorn/arm_unicorn.h
@@ -45,7 +45,6 @@ private:
45 static void InterruptHook(uc_engine* uc, u32 int_no, void* user_data); 45 static void InterruptHook(uc_engine* uc, u32 int_no, void* user_data);
46 46
47 uc_engine* uc{}; 47 uc_engine* uc{};
48 System& system;
49 GDBStub::BreakpointAddress last_bkpt{}; 48 GDBStub::BreakpointAddress last_bkpt{};
50 bool last_bkpt_hit = false; 49 bool last_bkpt_hit = false;
51}; 50};
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp
index 5995a6556..9849dbe91 100644
--- a/src/core/hle/kernel/client_session.cpp
+++ b/src/core/hle/kernel/client_session.cpp
@@ -21,10 +21,10 @@ ClientSession::~ClientSession() {
21 } 21 }
22} 22}
23 23
24ResultCode ClientSession::SendSyncRequest(Thread* thread) { 24ResultCode ClientSession::SendSyncRequest(Thread* thread, Memory::Memory& memory) {
25 // Signal the server session that new data is available 25 // Signal the server session that new data is available
26 if (auto server = parent->server.lock()) { 26 if (auto server = parent->server.lock()) {
27 return server->HandleSyncRequest(SharedFrom(thread)); 27 return server->HandleSyncRequest(SharedFrom(thread), memory);
28 } 28 }
29 29
30 return ERR_SESSION_CLOSED_BY_REMOTE; 30 return ERR_SESSION_CLOSED_BY_REMOTE;
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index 5ae41db29..484dd7bc9 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -10,6 +10,10 @@
10 10
11union ResultCode; 11union ResultCode;
12 12
13namespace Memory {
14class Memory;
15}
16
13namespace Kernel { 17namespace Kernel {
14 18
15class KernelCore; 19class KernelCore;
@@ -37,7 +41,7 @@ public:
37 return HANDLE_TYPE; 41 return HANDLE_TYPE;
38 } 42 }
39 43
40 ResultCode SendSyncRequest(Thread* thread); 44 ResultCode SendSyncRequest(Thread* thread, Memory::Memory& memory);
41 45
42private: 46private:
43 /// The parent session, which links to the server endpoint. 47 /// The parent session, which links to the server endpoint.
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index c7db21eb2..57878514d 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -127,7 +127,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con
127 return RESULT_SUCCESS; 127 return RESULT_SUCCESS;
128} 128}
129 129
130ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) { 130ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread,
131 Memory::Memory& memory) {
131 // The ServerSession received a sync request, this means that there's new data available 132 // The ServerSession received a sync request, this means that there's new data available
132 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or 133 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
133 // similar. 134 // similar.
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 8a65647b6..641709a45 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -13,6 +13,10 @@
13#include "core/hle/kernel/wait_object.h" 13#include "core/hle/kernel/wait_object.h"
14#include "core/hle/result.h" 14#include "core/hle/result.h"
15 15
16namespace Memory {
17class Memory;
18}
19
16namespace Kernel { 20namespace Kernel {
17 21
18class ClientPort; 22class ClientPort;
@@ -85,10 +89,13 @@ public:
85 89
86 /** 90 /**
87 * Handle a sync request from the emulated application. 91 * Handle a sync request from the emulated application.
92 *
88 * @param thread Thread that initiated the request. 93 * @param thread Thread that initiated the request.
94 * @param memory Memory context to handle the sync request under.
95 *
89 * @returns ResultCode from the operation. 96 * @returns ResultCode from the operation.
90 */ 97 */
91 ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread); 98 ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory);
92 99
93 bool ShouldWait(const Thread* thread) const override; 100 bool ShouldWait(const Thread* thread) const override;
94 101
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index eddafaf60..68bff11ec 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -383,7 +383,7 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
383 383
384 // TODO(Subv): svcSendSyncRequest should put the caller thread to sleep while the server 384 // TODO(Subv): svcSendSyncRequest should put the caller thread to sleep while the server
385 // responds and cause a reschedule. 385 // responds and cause a reschedule.
386 return session->SendSyncRequest(system.CurrentScheduler().GetCurrentThread()); 386 return session->SendSyncRequest(system.CurrentScheduler().GetCurrentThread(), system.Memory());
387} 387}
388 388
389/// Get the ID for the specified thread. 389/// Get the ID for the specified thread.
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 4ea7ade6e..82a5dbf14 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -49,8 +49,9 @@ public:
49 49
50 system_event = 50 system_event =
51 Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent"); 51 Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent");
52 renderer = std::make_unique<AudioCore::AudioRenderer>( 52 renderer = std::make_unique<AudioCore::AudioRenderer>(system.CoreTiming(), system.Memory(),
53 system.CoreTiming(), audren_params, system_event.writable, instance_number); 53 audren_params, system_event.writable,
54 instance_number);
54 } 55 }
55 56
56private: 57private:
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 5874ed6bd..89e1957f9 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -391,13 +391,10 @@ public:
391 } 391 }
392 392
393 void RenameFile(Kernel::HLERequestContext& ctx) { 393 void RenameFile(Kernel::HLERequestContext& ctx) {
394 std::vector<u8> buffer; 394 std::vector<u8> buffer = ctx.ReadBuffer(0);
395 buffer.resize(ctx.BufferDescriptorX()[0].Size());
396 Memory::ReadBlock(ctx.BufferDescriptorX()[0].Address(), buffer.data(), buffer.size());
397 const std::string src_name = Common::StringFromBuffer(buffer); 395 const std::string src_name = Common::StringFromBuffer(buffer);
398 396
399 buffer.resize(ctx.BufferDescriptorX()[1].Size()); 397 buffer = ctx.ReadBuffer(1);
400 Memory::ReadBlock(ctx.BufferDescriptorX()[1].Address(), buffer.data(), buffer.size());
401 const std::string dst_name = Common::StringFromBuffer(buffer); 398 const std::string dst_name = Common::StringFromBuffer(buffer);
402 399
403 LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name); 400 LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name);
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 435f2d286..74ecaef1b 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -17,7 +17,8 @@ namespace Service::LM {
17 17
18class ILogger final : public ServiceFramework<ILogger> { 18class ILogger final : public ServiceFramework<ILogger> {
19public: 19public:
20 ILogger(Manager& manager) : ServiceFramework("ILogger"), manager(manager) { 20 explicit ILogger(Manager& manager_, Memory::Memory& memory_)
21 : ServiceFramework("ILogger"), manager{manager_}, memory{memory_} {
21 static const FunctionInfo functions[] = { 22 static const FunctionInfo functions[] = {
22 {0, &ILogger::Log, "Log"}, 23 {0, &ILogger::Log, "Log"},
23 {1, &ILogger::SetDestination, "SetDestination"}, 24 {1, &ILogger::SetDestination, "SetDestination"},
@@ -74,11 +75,13 @@ private:
74 } 75 }
75 76
76 Manager& manager; 77 Manager& manager;
78 Memory::Memory& memory;
77}; 79};
78 80
79class LM final : public ServiceFramework<LM> { 81class LM final : public ServiceFramework<LM> {
80public: 82public:
81 explicit LM(Manager& manager) : ServiceFramework{"lm"}, manager(manager) { 83 explicit LM(Manager& manager_, Memory::Memory& memory_)
84 : ServiceFramework{"lm"}, manager{manager_}, memory{memory_} {
82 // clang-format off 85 // clang-format off
83 static const FunctionInfo functions[] = { 86 static const FunctionInfo functions[] = {
84 {0, &LM::OpenLogger, "OpenLogger"}, 87 {0, &LM::OpenLogger, "OpenLogger"},
@@ -94,14 +97,16 @@ private:
94 97
95 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 98 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
96 rb.Push(RESULT_SUCCESS); 99 rb.Push(RESULT_SUCCESS);
97 rb.PushIpcInterface<ILogger>(manager); 100 rb.PushIpcInterface<ILogger>(manager, memory);
98 } 101 }
99 102
100 Manager& manager; 103 Manager& manager;
104 Memory::Memory& memory;
101}; 105};
102 106
103void InstallInterfaces(Core::System& system) { 107void InstallInterfaces(Core::System& system) {
104 std::make_shared<LM>(system.GetLogManager())->InstallAsService(system.ServiceManager()); 108 std::make_shared<LM>(system.GetLogManager(), system.Memory())
109 ->InstallAsService(system.ServiceManager());
105} 110}
106 111
107} // namespace Service::LM 112} // namespace Service::LM
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp
index 6f4af77fd..af0988d62 100644
--- a/src/core/reporter.cpp
+++ b/src/core/reporter.cpp
@@ -147,7 +147,7 @@ json GetFullDataAuto(const std::string& timestamp, u64 title_id, Core::System& s
147} 147}
148 148
149template <bool read_value, typename DescriptorType> 149template <bool read_value, typename DescriptorType>
150json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer) { 150json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer, Memory::Memory& memory) {
151 auto buffer_out = json::array(); 151 auto buffer_out = json::array();
152 for (const auto& desc : buffer) { 152 for (const auto& desc : buffer) {
153 auto entry = json{ 153 auto entry = json{
@@ -167,7 +167,7 @@ json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer) {
167 return buffer_out; 167 return buffer_out;
168} 168}
169 169
170json GetHLERequestContextData(Kernel::HLERequestContext& ctx) { 170json GetHLERequestContextData(Kernel::HLERequestContext& ctx, Memory::Memory& memory) {
171 json out; 171 json out;
172 172
173 auto cmd_buf = json::array(); 173 auto cmd_buf = json::array();
@@ -177,10 +177,10 @@ json GetHLERequestContextData(Kernel::HLERequestContext& ctx) {
177 177
178 out["command_buffer"] = std::move(cmd_buf); 178 out["command_buffer"] = std::move(cmd_buf);
179 179
180 out["buffer_descriptor_a"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorA()); 180 out["buffer_descriptor_a"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorA(), memory);
181 out["buffer_descriptor_b"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorB()); 181 out["buffer_descriptor_b"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorB(), memory);
182 out["buffer_descriptor_c"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorC()); 182 out["buffer_descriptor_c"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorC(), memory);
183 out["buffer_descriptor_x"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorX()); 183 out["buffer_descriptor_x"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorX(), memory);
184 184
185 return out; 185 return out;
186} 186}
@@ -259,7 +259,7 @@ void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u
259 const auto title_id = system.CurrentProcess()->GetTitleID(); 259 const auto title_id = system.CurrentProcess()->GetTitleID();
260 auto out = GetFullDataAuto(timestamp, title_id, system); 260 auto out = GetFullDataAuto(timestamp, title_id, system);
261 261
262 auto function_out = GetHLERequestContextData(ctx); 262 auto function_out = GetHLERequestContextData(ctx, system.Memory());
263 function_out["command_id"] = command_id; 263 function_out["command_id"] = command_id;
264 function_out["function_name"] = name; 264 function_out["function_name"] = name;
265 function_out["service_name"] = service_name; 265 function_out["service_name"] = service_name;
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp
index 19b531ecb..c7f42388f 100644
--- a/src/core/tools/freezer.cpp
+++ b/src/core/tools/freezer.cpp
@@ -11,12 +11,11 @@
11#include "core/tools/freezer.h" 11#include "core/tools/freezer.h"
12 12
13namespace Tools { 13namespace Tools {
14
15namespace { 14namespace {
16 15
17constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); 16constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60);
18 17
19u64 MemoryReadWidth(u32 width, VAddr addr) { 18u64 MemoryReadWidth(Memory::Memory& memory, u32 width, VAddr addr) {
20 switch (width) { 19 switch (width) {
21 case 1: 20 case 1:
22 return Memory::Read8(addr); 21 return Memory::Read8(addr);
@@ -32,7 +31,7 @@ u64 MemoryReadWidth(u32 width, VAddr addr) {
32 } 31 }
33} 32}
34 33
35void MemoryWriteWidth(u32 width, VAddr addr, u64 value) { 34void MemoryWriteWidth(Memory::Memory& memory, u32 width, VAddr addr, u64 value) {
36 switch (width) { 35 switch (width) {
37 case 1: 36 case 1:
38 Memory::Write8(addr, static_cast<u8>(value)); 37 Memory::Write8(addr, static_cast<u8>(value));
@@ -53,7 +52,8 @@ void MemoryWriteWidth(u32 width, VAddr addr, u64 value) {
53 52
54} // Anonymous namespace 53} // Anonymous namespace
55 54
56Freezer::Freezer(Core::Timing::CoreTiming& core_timing) : core_timing(core_timing) { 55Freezer::Freezer(Core::Timing::CoreTiming& core_timing_, Memory::Memory& memory_)
56 : core_timing{core_timing_}, memory{memory_} {
57 event = Core::Timing::CreateEvent( 57 event = Core::Timing::CreateEvent(
58 "MemoryFreezer::FrameCallback", 58 "MemoryFreezer::FrameCallback",
59 [this](u64 userdata, s64 cycles_late) { FrameCallback(userdata, cycles_late); }); 59 [this](u64 userdata, s64 cycles_late) { FrameCallback(userdata, cycles_late); });
@@ -89,7 +89,7 @@ void Freezer::Clear() {
89u64 Freezer::Freeze(VAddr address, u32 width) { 89u64 Freezer::Freeze(VAddr address, u32 width) {
90 std::lock_guard lock{entries_mutex}; 90 std::lock_guard lock{entries_mutex};
91 91
92 const auto current_value = MemoryReadWidth(width, address); 92 const auto current_value = MemoryReadWidth(memory, width, address);
93 entries.push_back({address, width, current_value}); 93 entries.push_back({address, width, current_value});
94 94
95 LOG_DEBUG(Common_Memory, 95 LOG_DEBUG(Common_Memory,
@@ -169,7 +169,7 @@ void Freezer::FrameCallback(u64 userdata, s64 cycles_late) {
169 LOG_DEBUG(Common_Memory, 169 LOG_DEBUG(Common_Memory,
170 "Enforcing memory freeze at address={:016X}, value={:016X}, width={:02X}", 170 "Enforcing memory freeze at address={:016X}, value={:016X}, width={:02X}",
171 entry.address, entry.value, entry.width); 171 entry.address, entry.value, entry.width);
172 MemoryWriteWidth(entry.width, entry.address, entry.value); 172 MemoryWriteWidth(memory, entry.width, entry.address, entry.value);
173 } 173 }
174 174
175 core_timing.ScheduleEvent(MEMORY_FREEZER_TICKS - cycles_late, event); 175 core_timing.ScheduleEvent(MEMORY_FREEZER_TICKS - cycles_late, event);
@@ -181,7 +181,7 @@ void Freezer::FillEntryReads() {
181 LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values."); 181 LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values.");
182 182
183 for (auto& entry : entries) { 183 for (auto& entry : entries) {
184 entry.value = MemoryReadWidth(entry.width, entry.address); 184 entry.value = MemoryReadWidth(memory, entry.width, entry.address);
185 } 185 }
186} 186}
187 187
diff --git a/src/core/tools/freezer.h b/src/core/tools/freezer.h
index 90b1a885c..916339c6c 100644
--- a/src/core/tools/freezer.h
+++ b/src/core/tools/freezer.h
@@ -16,6 +16,10 @@ class CoreTiming;
16struct EventType; 16struct EventType;
17} // namespace Core::Timing 17} // namespace Core::Timing
18 18
19namespace Memory {
20class Memory;
21}
22
19namespace Tools { 23namespace Tools {
20 24
21/** 25/**
@@ -34,7 +38,7 @@ public:
34 u64 value; 38 u64 value;
35 }; 39 };
36 40
37 explicit Freezer(Core::Timing::CoreTiming& core_timing); 41 explicit Freezer(Core::Timing::CoreTiming& core_timing_, Memory::Memory& memory_);
38 ~Freezer(); 42 ~Freezer();
39 43
40 // Enables or disables the entire memory freezer. 44 // Enables or disables the entire memory freezer.
@@ -78,6 +82,7 @@ private:
78 82
79 std::shared_ptr<Core::Timing::EventType> event; 83 std::shared_ptr<Core::Timing::EventType> event;
80 Core::Timing::CoreTiming& core_timing; 84 Core::Timing::CoreTiming& core_timing;
85 Memory::Memory& memory;
81}; 86};
82 87
83} // namespace Tools 88} // namespace Tools