diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 24 | ||||
| -rw-r--r-- | src/core/memory.cpp | 11 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 283d20831..e7f6bf8c2 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <dynarmic/A64/a64.h> | 7 | #include <dynarmic/A64/a64.h> |
| 8 | #include <dynarmic/A64/config.h> | 8 | #include <dynarmic/A64/config.h> |
| 9 | #include "common/logging/log.h" | ||
| 9 | #include "core/arm/dynarmic/arm_dynarmic.h" | 10 | #include "core/arm/dynarmic/arm_dynarmic.h" |
| 10 | #include "core/core_timing.h" | 11 | #include "core/core_timing.h" |
| 11 | #include "core/hle/kernel/memory.h" | 12 | #include "core/hle/kernel/memory.h" |
| @@ -53,6 +54,9 @@ public: | |||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | void InterpreterFallback(u64 pc, size_t num_instructions) override { | 56 | void InterpreterFallback(u64 pc, size_t num_instructions) override { |
| 57 | LOG_INFO(Core_ARM, "Unicorn fallback @ 0x%" PRIx64 " for %zu instructions (instr = %08x)", | ||
| 58 | pc, num_instructions, MemoryReadCode(pc)); | ||
| 59 | |||
| 56 | ARM_Interface::ThreadContext ctx; | 60 | ARM_Interface::ThreadContext ctx; |
| 57 | parent.SaveContext(ctx); | 61 | parent.SaveContext(ctx); |
| 58 | parent.inner_unicorn.LoadContext(ctx); | 62 | parent.inner_unicorn.LoadContext(ctx); |
| @@ -63,8 +67,17 @@ public: | |||
| 63 | } | 67 | } |
| 64 | 68 | ||
| 65 | void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { | 69 | void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { |
| 66 | ASSERT_MSG(false, "ExceptionRaised(exception = %zu, pc = %" PRIx64 ")", | 70 | switch (exception) { |
| 67 | static_cast<size_t>(exception), pc); | 71 | case Dynarmic::A64::Exception::WaitForInterrupt: |
| 72 | case Dynarmic::A64::Exception::WaitForEvent: | ||
| 73 | case Dynarmic::A64::Exception::SendEvent: | ||
| 74 | case Dynarmic::A64::Exception::SendEventLocal: | ||
| 75 | case Dynarmic::A64::Exception::Yield: | ||
| 76 | return; | ||
| 77 | default: | ||
| 78 | ASSERT_MSG(false, "ExceptionRaised(exception = %zu, pc = %" PRIx64 ")", | ||
| 79 | static_cast<size_t>(exception), pc); | ||
| 80 | } | ||
| 68 | } | 81 | } |
| 69 | 82 | ||
| 70 | void CallSVC(u32 swi) override { | 83 | void CallSVC(u32 swi) override { |
| @@ -81,11 +94,15 @@ public: | |||
| 81 | u64 GetTicksRemaining() override { | 94 | u64 GetTicksRemaining() override { |
| 82 | return ticks_remaining; | 95 | return ticks_remaining; |
| 83 | } | 96 | } |
| 97 | u64 GetCNTPCT() override { | ||
| 98 | return CoreTiming::GetTicks(); | ||
| 99 | } | ||
| 84 | 100 | ||
| 85 | ARM_Dynarmic& parent; | 101 | ARM_Dynarmic& parent; |
| 86 | size_t ticks_remaining = 0; | 102 | size_t ticks_remaining = 0; |
| 87 | size_t num_interpreted_instructions = 0; | 103 | size_t num_interpreted_instructions = 0; |
| 88 | u64 tpidrro_el0 = 0; | 104 | u64 tpidrro_el0 = 0; |
| 105 | u64 tpidr_el0 = 0; | ||
| 89 | }; | 106 | }; |
| 90 | 107 | ||
| 91 | std::unique_ptr<Dynarmic::A64::Jit> MakeJit(const std::unique_ptr<ARM_Dynarmic_Callbacks>& cb) { | 108 | std::unique_ptr<Dynarmic::A64::Jit> MakeJit(const std::unique_ptr<ARM_Dynarmic_Callbacks>& cb) { |
| @@ -94,10 +111,13 @@ std::unique_ptr<Dynarmic::A64::Jit> MakeJit(const std::unique_ptr<ARM_Dynarmic_C | |||
| 94 | Dynarmic::A64::UserConfig config; | 111 | Dynarmic::A64::UserConfig config; |
| 95 | config.callbacks = cb.get(); | 112 | config.callbacks = cb.get(); |
| 96 | config.tpidrro_el0 = &cb->tpidrro_el0; | 113 | config.tpidrro_el0 = &cb->tpidrro_el0; |
| 114 | config.tpidr_el0 = &cb->tpidr_el0; | ||
| 97 | config.dczid_el0 = 4; | 115 | config.dczid_el0 = 4; |
| 116 | config.ctr_el0 = 0x8444c004; | ||
| 98 | config.page_table = reinterpret_cast<void**>(page_table); | 117 | config.page_table = reinterpret_cast<void**>(page_table); |
| 99 | config.page_table_address_space_bits = Memory::ADDRESS_SPACE_BITS; | 118 | config.page_table_address_space_bits = Memory::ADDRESS_SPACE_BITS; |
| 100 | config.silently_mirror_page_table = false; | 119 | config.silently_mirror_page_table = false; |
| 120 | |||
| 101 | return std::make_unique<Dynarmic::A64::Jit>(config); | 121 | return std::make_unique<Dynarmic::A64::Jit>(config); |
| 102 | } | 122 | } |
| 103 | 123 | ||
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index cc1ed16b6..ce62666d7 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -118,6 +118,11 @@ boost::optional<T> ReadSpecial(VAddr addr); | |||
| 118 | 118 | ||
| 119 | template <typename T> | 119 | template <typename T> |
| 120 | T Read(const VAddr vaddr) { | 120 | T Read(const VAddr vaddr) { |
| 121 | if ((vaddr >> PAGE_BITS) >= PAGE_TABLE_NUM_ENTRIES) { | ||
| 122 | LOG_ERROR(HW_Memory, "Read%lu after page table @ 0x%016" PRIX64, sizeof(T) * 8, vaddr); | ||
| 123 | return 0; | ||
| 124 | } | ||
| 125 | |||
| 121 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 126 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 122 | switch (type) { | 127 | switch (type) { |
| 123 | case PageType::Unmapped: | 128 | case PageType::Unmapped: |
| @@ -146,6 +151,12 @@ bool WriteSpecial(VAddr addr, const T data); | |||
| 146 | 151 | ||
| 147 | template <typename T> | 152 | template <typename T> |
| 148 | void Write(const VAddr vaddr, const T data) { | 153 | void Write(const VAddr vaddr, const T data) { |
| 154 | if ((vaddr >> PAGE_BITS) >= PAGE_TABLE_NUM_ENTRIES) { | ||
| 155 | LOG_ERROR(HW_Memory, "Write%lu after page table 0x%08X @ 0x%016" PRIX64, sizeof(data) * 8, | ||
| 156 | (u32)data, vaddr); | ||
| 157 | return; | ||
| 158 | } | ||
| 159 | |||
| 149 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 160 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 150 | switch (type) { | 161 | switch (type) { |
| 151 | case PageType::Unmapped: | 162 | case PageType::Unmapped: |