diff options
| author | 2019-11-26 17:39:57 -0500 | |
|---|---|---|
| committer | 2019-11-26 21:55:39 -0500 | |
| commit | e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1 (patch) | |
| tree | 14b95ea207543f3884558ebdf8673a511bf64dc3 /src/core/arm | |
| parent | core/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory class (diff) | |
| download | yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.tar.gz yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.tar.xz yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.zip | |
core/memory: Migrate over Write{8, 16, 32, 64, Block} to the Memory class
The Write functions are used slightly less than the Read functions,
which make these a bit nicer to move over.
The only adjustments we really need to make here are to Dynarmic's
exclusive monitor instance. We need to keep a reference to the currently
active memory instance to perform exclusive read/write operations.
Diffstat (limited to 'src/core/arm')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 30 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.h | 7 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 585fb55a9..f8c7f0efd 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -45,20 +45,21 @@ public: | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void MemoryWrite8(u64 vaddr, u8 value) override { | 47 | void MemoryWrite8(u64 vaddr, u8 value) override { |
| 48 | Memory::Write8(vaddr, value); | 48 | parent.system.Memory().Write8(vaddr, value); |
| 49 | } | 49 | } |
| 50 | void MemoryWrite16(u64 vaddr, u16 value) override { | 50 | void MemoryWrite16(u64 vaddr, u16 value) override { |
| 51 | Memory::Write16(vaddr, value); | 51 | parent.system.Memory().Write16(vaddr, value); |
| 52 | } | 52 | } |
| 53 | void MemoryWrite32(u64 vaddr, u32 value) override { | 53 | void MemoryWrite32(u64 vaddr, u32 value) override { |
| 54 | Memory::Write32(vaddr, value); | 54 | parent.system.Memory().Write32(vaddr, value); |
| 55 | } | 55 | } |
| 56 | void MemoryWrite64(u64 vaddr, u64 value) override { | 56 | void MemoryWrite64(u64 vaddr, u64 value) override { |
| 57 | Memory::Write64(vaddr, value); | 57 | parent.system.Memory().Write64(vaddr, value); |
| 58 | } | 58 | } |
| 59 | void MemoryWrite128(u64 vaddr, Vector value) override { | 59 | void MemoryWrite128(u64 vaddr, Vector value) override { |
| 60 | Memory::Write64(vaddr, value[0]); | 60 | auto& memory = parent.system.Memory(); |
| 61 | Memory::Write64(vaddr + 8, value[1]); | 61 | memory.Write64(vaddr, value[0]); |
| 62 | memory.Write64(vaddr + 8, value[1]); | ||
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | void InterpreterFallback(u64 pc, std::size_t num_instructions) override { | 65 | void InterpreterFallback(u64 pc, std::size_t num_instructions) override { |
| @@ -266,7 +267,9 @@ void ARM_Dynarmic::PageTableChanged(Common::PageTable& page_table, | |||
| 266 | jit = MakeJit(page_table, new_address_space_size_in_bits); | 267 | jit = MakeJit(page_table, new_address_space_size_in_bits); |
| 267 | } | 268 | } |
| 268 | 269 | ||
| 269 | DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(std::size_t core_count) : monitor(core_count) {} | 270 | DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count) |
| 271 | : monitor(core_count), memory{memory_} {} | ||
| 272 | |||
| 270 | DynarmicExclusiveMonitor::~DynarmicExclusiveMonitor() = default; | 273 | DynarmicExclusiveMonitor::~DynarmicExclusiveMonitor() = default; |
| 271 | 274 | ||
| 272 | void DynarmicExclusiveMonitor::SetExclusive(std::size_t core_index, VAddr addr) { | 275 | void DynarmicExclusiveMonitor::SetExclusive(std::size_t core_index, VAddr addr) { |
| @@ -279,29 +282,28 @@ void DynarmicExclusiveMonitor::ClearExclusive() { | |||
| 279 | } | 282 | } |
| 280 | 283 | ||
| 281 | bool DynarmicExclusiveMonitor::ExclusiveWrite8(std::size_t core_index, VAddr vaddr, u8 value) { | 284 | bool DynarmicExclusiveMonitor::ExclusiveWrite8(std::size_t core_index, VAddr vaddr, u8 value) { |
| 282 | return monitor.DoExclusiveOperation(core_index, vaddr, 1, | 285 | return monitor.DoExclusiveOperation(core_index, vaddr, 1, [&] { memory.Write8(vaddr, value); }); |
| 283 | [&] { Memory::Write8(vaddr, value); }); | ||
| 284 | } | 286 | } |
| 285 | 287 | ||
| 286 | bool DynarmicExclusiveMonitor::ExclusiveWrite16(std::size_t core_index, VAddr vaddr, u16 value) { | 288 | bool DynarmicExclusiveMonitor::ExclusiveWrite16(std::size_t core_index, VAddr vaddr, u16 value) { |
| 287 | return monitor.DoExclusiveOperation(core_index, vaddr, 2, | 289 | return monitor.DoExclusiveOperation(core_index, vaddr, 2, |
| 288 | [&] { Memory::Write16(vaddr, value); }); | 290 | [&] { memory.Write16(vaddr, value); }); |
| 289 | } | 291 | } |
| 290 | 292 | ||
| 291 | bool DynarmicExclusiveMonitor::ExclusiveWrite32(std::size_t core_index, VAddr vaddr, u32 value) { | 293 | bool DynarmicExclusiveMonitor::ExclusiveWrite32(std::size_t core_index, VAddr vaddr, u32 value) { |
| 292 | return monitor.DoExclusiveOperation(core_index, vaddr, 4, | 294 | return monitor.DoExclusiveOperation(core_index, vaddr, 4, |
| 293 | [&] { Memory::Write32(vaddr, value); }); | 295 | [&] { memory.Write32(vaddr, value); }); |
| 294 | } | 296 | } |
| 295 | 297 | ||
| 296 | bool DynarmicExclusiveMonitor::ExclusiveWrite64(std::size_t core_index, VAddr vaddr, u64 value) { | 298 | bool DynarmicExclusiveMonitor::ExclusiveWrite64(std::size_t core_index, VAddr vaddr, u64 value) { |
| 297 | return monitor.DoExclusiveOperation(core_index, vaddr, 8, | 299 | return monitor.DoExclusiveOperation(core_index, vaddr, 8, |
| 298 | [&] { Memory::Write64(vaddr, value); }); | 300 | [&] { memory.Write64(vaddr, value); }); |
| 299 | } | 301 | } |
| 300 | 302 | ||
| 301 | bool DynarmicExclusiveMonitor::ExclusiveWrite128(std::size_t core_index, VAddr vaddr, u128 value) { | 303 | bool DynarmicExclusiveMonitor::ExclusiveWrite128(std::size_t core_index, VAddr vaddr, u128 value) { |
| 302 | return monitor.DoExclusiveOperation(core_index, vaddr, 16, [&] { | 304 | return monitor.DoExclusiveOperation(core_index, vaddr, 16, [&] { |
| 303 | Memory::Write64(vaddr + 0, value[0]); | 305 | memory.Write64(vaddr + 0, value[0]); |
| 304 | Memory::Write64(vaddr + 8, value[1]); | 306 | memory.Write64(vaddr + 8, value[1]); |
| 305 | }); | 307 | }); |
| 306 | } | 308 | } |
| 307 | 309 | ||
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index d08de475f..9cd475cfb 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -12,6 +12,10 @@ | |||
| 12 | #include "core/arm/exclusive_monitor.h" | 12 | #include "core/arm/exclusive_monitor.h" |
| 13 | #include "core/arm/unicorn/arm_unicorn.h" | 13 | #include "core/arm/unicorn/arm_unicorn.h" |
| 14 | 14 | ||
| 15 | namespace Memory { | ||
| 16 | class Memory; | ||
| 17 | } | ||
| 18 | |||
| 15 | namespace Core { | 19 | namespace Core { |
| 16 | 20 | ||
| 17 | class ARM_Dynarmic_Callbacks; | 21 | class ARM_Dynarmic_Callbacks; |
| @@ -63,7 +67,7 @@ private: | |||
| 63 | 67 | ||
| 64 | class DynarmicExclusiveMonitor final : public ExclusiveMonitor { | 68 | class DynarmicExclusiveMonitor final : public ExclusiveMonitor { |
| 65 | public: | 69 | public: |
| 66 | explicit DynarmicExclusiveMonitor(std::size_t core_count); | 70 | explicit DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count); |
| 67 | ~DynarmicExclusiveMonitor() override; | 71 | ~DynarmicExclusiveMonitor() override; |
| 68 | 72 | ||
| 69 | void SetExclusive(std::size_t core_index, VAddr addr) override; | 73 | void SetExclusive(std::size_t core_index, VAddr addr) override; |
| @@ -78,6 +82,7 @@ public: | |||
| 78 | private: | 82 | private: |
| 79 | friend class ARM_Dynarmic; | 83 | friend class ARM_Dynarmic; |
| 80 | Dynarmic::A64::ExclusiveMonitor monitor; | 84 | Dynarmic::A64::ExclusiveMonitor monitor; |
| 85 | Memory::Memory& memory; | ||
| 81 | }; | 86 | }; |
| 82 | 87 | ||
| 83 | } // namespace Core | 88 | } // namespace Core |