diff options
| author | 2019-11-28 11:43:17 -0500 | |
|---|---|---|
| committer | 2019-11-28 11:43:17 -0500 | |
| commit | e3ee017e91ef4d713f1af8cb60c5157e40d43f18 (patch) | |
| tree | e0a5b47cac1d548599b8ceba7f71b40746fe6b48 /src/core/tools/freezer.cpp | |
| parent | Merge pull request #3171 from lioncash/internal-link (diff) | |
| parent | core/memory; Migrate over SetCurrentPageTable() to the Memory class (diff) | |
| download | yuzu-e3ee017e91ef4d713f1af8cb60c5157e40d43f18.tar.gz yuzu-e3ee017e91ef4d713f1af8cb60c5157e40d43f18.tar.xz yuzu-e3ee017e91ef4d713f1af8cb60c5157e40d43f18.zip | |
Merge pull request #3169 from lioncash/memory
core/memory: Deglobalize memory management code
Diffstat (limited to 'src/core/tools/freezer.cpp')
| -rw-r--r-- | src/core/tools/freezer.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp index 19b531ecb..55e0dbc49 100644 --- a/src/core/tools/freezer.cpp +++ b/src/core/tools/freezer.cpp | |||
| @@ -11,40 +11,39 @@ | |||
| 11 | #include "core/tools/freezer.h" | 11 | #include "core/tools/freezer.h" |
| 12 | 12 | ||
| 13 | namespace Tools { | 13 | namespace Tools { |
| 14 | |||
| 15 | namespace { | 14 | namespace { |
| 16 | 15 | ||
| 17 | constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); | 16 | constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); |
| 18 | 17 | ||
| 19 | u64 MemoryReadWidth(u32 width, VAddr addr) { | 18 | u64 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); |
| 23 | case 2: | 22 | case 2: |
| 24 | return Memory::Read16(addr); | 23 | return memory.Read16(addr); |
| 25 | case 4: | 24 | case 4: |
| 26 | return Memory::Read32(addr); | 25 | return memory.Read32(addr); |
| 27 | case 8: | 26 | case 8: |
| 28 | return Memory::Read64(addr); | 27 | return memory.Read64(addr); |
| 29 | default: | 28 | default: |
| 30 | UNREACHABLE(); | 29 | UNREACHABLE(); |
| 31 | return 0; | 30 | return 0; |
| 32 | } | 31 | } |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | void MemoryWriteWidth(u32 width, VAddr addr, u64 value) { | 34 | void 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)); |
| 39 | break; | 38 | break; |
| 40 | case 2: | 39 | case 2: |
| 41 | Memory::Write16(addr, static_cast<u16>(value)); | 40 | memory.Write16(addr, static_cast<u16>(value)); |
| 42 | break; | 41 | break; |
| 43 | case 4: | 42 | case 4: |
| 44 | Memory::Write32(addr, static_cast<u32>(value)); | 43 | memory.Write32(addr, static_cast<u32>(value)); |
| 45 | break; | 44 | break; |
| 46 | case 8: | 45 | case 8: |
| 47 | Memory::Write64(addr, value); | 46 | memory.Write64(addr, value); |
| 48 | break; | 47 | break; |
| 49 | default: | 48 | default: |
| 50 | UNREACHABLE(); | 49 | UNREACHABLE(); |
| @@ -53,7 +52,8 @@ void MemoryWriteWidth(u32 width, VAddr addr, u64 value) { | |||
| 53 | 52 | ||
| 54 | } // Anonymous namespace | 53 | } // Anonymous namespace |
| 55 | 54 | ||
| 56 | Freezer::Freezer(Core::Timing::CoreTiming& core_timing) : core_timing(core_timing) { | 55 | Freezer::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() { | |||
| 89 | u64 Freezer::Freeze(VAddr address, u32 width) { | 89 | u64 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 | ||