diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 31 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.h | 5 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.cpp | 38 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.h | 5 |
4 files changed, 26 insertions, 53 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 53d78de32..4b2a62b4f 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp | |||
| @@ -114,18 +114,17 @@ public: | |||
| 114 | static constexpr u64 minimum_run_cycles = 1000U; | 114 | static constexpr u64 minimum_run_cycles = 1000U; |
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable& page_table, | 117 | std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* page_table) const { |
| 118 | std::size_t address_space_bits) const { | ||
| 119 | Dynarmic::A32::UserConfig config; | 118 | Dynarmic::A32::UserConfig config; |
| 120 | config.callbacks = cb.get(); | 119 | config.callbacks = cb.get(); |
| 121 | // TODO(bunnei): Implement page table for 32-bit | ||
| 122 | // config.page_table = &page_table.pointers; | ||
| 123 | config.coprocessors[15] = cp15; | 120 | config.coprocessors[15] = cp15; |
| 124 | config.define_unpredictable_behaviour = true; | 121 | config.define_unpredictable_behaviour = true; |
| 125 | static constexpr std::size_t PAGE_BITS = 12; | 122 | static constexpr std::size_t PAGE_BITS = 12; |
| 126 | static constexpr std::size_t NUM_PAGE_TABLE_ENTRIES = 1 << (32 - PAGE_BITS); | 123 | static constexpr std::size_t NUM_PAGE_TABLE_ENTRIES = 1 << (32 - PAGE_BITS); |
| 127 | config.page_table = reinterpret_cast<std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>*>( | 124 | if (page_table) { |
| 128 | page_table.pointers.data()); | 125 | config.page_table = reinterpret_cast<std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>*>( |
| 126 | page_table->pointers.data()); | ||
| 127 | } | ||
| 129 | config.absolute_offset_page_table = true; | 128 | config.absolute_offset_page_table = true; |
| 130 | config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; | 129 | config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; |
| 131 | config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; | 130 | config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; |
| @@ -201,7 +200,8 @@ ARM_Dynarmic_32::ARM_Dynarmic_32(System& system, CPUInterrupts& interrupt_handle | |||
| 201 | : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, | 200 | : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, |
| 202 | cb(std::make_unique<DynarmicCallbacks32>(*this)), | 201 | cb(std::make_unique<DynarmicCallbacks32>(*this)), |
| 203 | cp15(std::make_shared<DynarmicCP15>(*this)), core_index{core_index}, | 202 | cp15(std::make_shared<DynarmicCP15>(*this)), core_index{core_index}, |
| 204 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} | 203 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)}, |
| 204 | jit(MakeJit(nullptr)) {} | ||
| 205 | 205 | ||
| 206 | ARM_Dynarmic_32::~ARM_Dynarmic_32() = default; | 206 | ARM_Dynarmic_32::~ARM_Dynarmic_32() = default; |
| 207 | 207 | ||
| @@ -256,9 +256,6 @@ void ARM_Dynarmic_32::ChangeProcessorID(std::size_t new_core_id) { | |||
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { | 258 | void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { |
| 259 | if (!jit) { | ||
| 260 | return; | ||
| 261 | } | ||
| 262 | Dynarmic::A32::Context context; | 259 | Dynarmic::A32::Context context; |
| 263 | jit->SaveContext(context); | 260 | jit->SaveContext(context); |
| 264 | ctx.cpu_registers = context.Regs(); | 261 | ctx.cpu_registers = context.Regs(); |
| @@ -268,9 +265,6 @@ void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { | |||
| 268 | } | 265 | } |
| 269 | 266 | ||
| 270 | void ARM_Dynarmic_32::LoadContext(const ThreadContext32& ctx) { | 267 | void ARM_Dynarmic_32::LoadContext(const ThreadContext32& ctx) { |
| 271 | if (!jit) { | ||
| 272 | return; | ||
| 273 | } | ||
| 274 | Dynarmic::A32::Context context; | 268 | Dynarmic::A32::Context context; |
| 275 | context.Regs() = ctx.cpu_registers; | 269 | context.Regs() = ctx.cpu_registers; |
| 276 | context.ExtRegs() = ctx.extension_registers; | 270 | context.ExtRegs() = ctx.extension_registers; |
| @@ -284,23 +278,14 @@ void ARM_Dynarmic_32::PrepareReschedule() { | |||
| 284 | } | 278 | } |
| 285 | 279 | ||
| 286 | void ARM_Dynarmic_32::ClearInstructionCache() { | 280 | void ARM_Dynarmic_32::ClearInstructionCache() { |
| 287 | if (!jit) { | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | jit->ClearCache(); | 281 | jit->ClearCache(); |
| 291 | } | 282 | } |
| 292 | 283 | ||
| 293 | void ARM_Dynarmic_32::InvalidateCacheRange(VAddr addr, std::size_t size) { | 284 | void ARM_Dynarmic_32::InvalidateCacheRange(VAddr addr, std::size_t size) { |
| 294 | if (!jit) { | ||
| 295 | return; | ||
| 296 | } | ||
| 297 | jit->InvalidateCacheRange(static_cast<u32>(addr), size); | 285 | jit->InvalidateCacheRange(static_cast<u32>(addr), size); |
| 298 | } | 286 | } |
| 299 | 287 | ||
| 300 | void ARM_Dynarmic_32::ClearExclusiveState() { | 288 | void ARM_Dynarmic_32::ClearExclusiveState() { |
| 301 | if (!jit) { | ||
| 302 | return; | ||
| 303 | } | ||
| 304 | jit->ClearExclusiveState(); | 289 | jit->ClearExclusiveState(); |
| 305 | } | 290 | } |
| 306 | 291 | ||
| @@ -316,7 +301,7 @@ void ARM_Dynarmic_32::PageTableChanged(Common::PageTable& page_table, | |||
| 316 | LoadContext(ctx); | 301 | LoadContext(ctx); |
| 317 | return; | 302 | return; |
| 318 | } | 303 | } |
| 319 | jit = MakeJit(page_table, new_address_space_size_in_bits); | 304 | jit = MakeJit(&page_table); |
| 320 | LoadContext(ctx); | 305 | LoadContext(ctx); |
| 321 | jit_cache.emplace(key, jit); | 306 | jit_cache.emplace(key, jit); |
| 322 | } | 307 | } |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h index f6c4d4db9..d40aef7a9 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.h +++ b/src/core/arm/dynarmic/arm_dynarmic_32.h | |||
| @@ -68,8 +68,7 @@ public: | |||
| 68 | std::size_t new_address_space_size_in_bits) override; | 68 | std::size_t new_address_space_size_in_bits) override; |
| 69 | 69 | ||
| 70 | private: | 70 | private: |
| 71 | std::shared_ptr<Dynarmic::A32::Jit> MakeJit(Common::PageTable& page_table, | 71 | std::shared_ptr<Dynarmic::A32::Jit> MakeJit(Common::PageTable* page_table) const; |
| 72 | std::size_t address_space_bits) const; | ||
| 73 | 72 | ||
| 74 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; | 73 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; |
| 75 | using JitCacheType = | 74 | using JitCacheType = |
| @@ -80,10 +79,10 @@ private: | |||
| 80 | 79 | ||
| 81 | std::unique_ptr<DynarmicCallbacks32> cb; | 80 | std::unique_ptr<DynarmicCallbacks32> cb; |
| 82 | JitCacheType jit_cache; | 81 | JitCacheType jit_cache; |
| 83 | std::shared_ptr<Dynarmic::A32::Jit> jit; | ||
| 84 | std::shared_ptr<DynarmicCP15> cp15; | 82 | std::shared_ptr<DynarmicCP15> cp15; |
| 85 | std::size_t core_index; | 83 | std::size_t core_index; |
| 86 | DynarmicExclusiveMonitor& exclusive_monitor; | 84 | DynarmicExclusiveMonitor& exclusive_monitor; |
| 85 | std::shared_ptr<Dynarmic::A32::Jit> jit; | ||
| 87 | }; | 86 | }; |
| 88 | 87 | ||
| 89 | } // namespace Core | 88 | } // namespace Core |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index b36b7d918..083c2bdee 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp | |||
| @@ -142,7 +142,7 @@ public: | |||
| 142 | static constexpr u64 minimum_run_cycles = 1000U; | 142 | static constexpr u64 minimum_run_cycles = 1000U; |
| 143 | }; | 143 | }; |
| 144 | 144 | ||
| 145 | std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable& page_table, | 145 | std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* page_table, |
| 146 | std::size_t address_space_bits) const { | 146 | std::size_t address_space_bits) const { |
| 147 | Dynarmic::A64::UserConfig config; | 147 | Dynarmic::A64::UserConfig config; |
| 148 | 148 | ||
| @@ -150,13 +150,15 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable& | |||
| 150 | config.callbacks = cb.get(); | 150 | config.callbacks = cb.get(); |
| 151 | 151 | ||
| 152 | // Memory | 152 | // Memory |
| 153 | config.page_table = reinterpret_cast<void**>(page_table.pointers.data()); | 153 | if (page_table) { |
| 154 | config.page_table_address_space_bits = address_space_bits; | 154 | config.page_table = reinterpret_cast<void**>(page_table->pointers.data()); |
| 155 | config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; | 155 | config.page_table_address_space_bits = address_space_bits; |
| 156 | config.silently_mirror_page_table = false; | 156 | config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; |
| 157 | config.absolute_offset_page_table = true; | 157 | config.silently_mirror_page_table = false; |
| 158 | config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; | 158 | config.absolute_offset_page_table = true; |
| 159 | config.only_detect_misalignment_via_page_table_on_page_boundary = true; | 159 | config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; |
| 160 | config.only_detect_misalignment_via_page_table_on_page_boundary = true; | ||
| 161 | } | ||
| 160 | 162 | ||
| 161 | // Multi-process state | 163 | // Multi-process state |
| 162 | config.processor_id = core_index; | 164 | config.processor_id = core_index; |
| @@ -237,7 +239,8 @@ ARM_Dynarmic_64::ARM_Dynarmic_64(System& system, CPUInterrupts& interrupt_handle | |||
| 237 | std::size_t core_index) | 239 | std::size_t core_index) |
| 238 | : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, | 240 | : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, |
| 239 | cb(std::make_unique<DynarmicCallbacks64>(*this)), core_index{core_index}, | 241 | cb(std::make_unique<DynarmicCallbacks64>(*this)), core_index{core_index}, |
| 240 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} | 242 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)}, |
| 243 | jit(MakeJit(nullptr, 48)) {} | ||
| 241 | 244 | ||
| 242 | ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; | 245 | ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; |
| 243 | 246 | ||
| @@ -294,9 +297,6 @@ void ARM_Dynarmic_64::ChangeProcessorID(std::size_t new_core_id) { | |||
| 294 | } | 297 | } |
| 295 | 298 | ||
| 296 | void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { | 299 | void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { |
| 297 | if (!jit) { | ||
| 298 | return; | ||
| 299 | } | ||
| 300 | ctx.cpu_registers = jit->GetRegisters(); | 300 | ctx.cpu_registers = jit->GetRegisters(); |
| 301 | ctx.sp = jit->GetSP(); | 301 | ctx.sp = jit->GetSP(); |
| 302 | ctx.pc = jit->GetPC(); | 302 | ctx.pc = jit->GetPC(); |
| @@ -308,9 +308,6 @@ void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { | |||
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | void ARM_Dynarmic_64::LoadContext(const ThreadContext64& ctx) { | 310 | void ARM_Dynarmic_64::LoadContext(const ThreadContext64& ctx) { |
| 311 | if (!jit) { | ||
| 312 | return; | ||
| 313 | } | ||
| 314 | jit->SetRegisters(ctx.cpu_registers); | 311 | jit->SetRegisters(ctx.cpu_registers); |
| 315 | jit->SetSP(ctx.sp); | 312 | jit->SetSP(ctx.sp); |
| 316 | jit->SetPC(ctx.pc); | 313 | jit->SetPC(ctx.pc); |
| @@ -326,23 +323,14 @@ void ARM_Dynarmic_64::PrepareReschedule() { | |||
| 326 | } | 323 | } |
| 327 | 324 | ||
| 328 | void ARM_Dynarmic_64::ClearInstructionCache() { | 325 | void ARM_Dynarmic_64::ClearInstructionCache() { |
| 329 | if (!jit) { | ||
| 330 | return; | ||
| 331 | } | ||
| 332 | jit->ClearCache(); | 326 | jit->ClearCache(); |
| 333 | } | 327 | } |
| 334 | 328 | ||
| 335 | void ARM_Dynarmic_64::InvalidateCacheRange(VAddr addr, std::size_t size) { | 329 | void ARM_Dynarmic_64::InvalidateCacheRange(VAddr addr, std::size_t size) { |
| 336 | if (!jit) { | ||
| 337 | return; | ||
| 338 | } | ||
| 339 | jit->InvalidateCacheRange(addr, size); | 330 | jit->InvalidateCacheRange(addr, size); |
| 340 | } | 331 | } |
| 341 | 332 | ||
| 342 | void ARM_Dynarmic_64::ClearExclusiveState() { | 333 | void ARM_Dynarmic_64::ClearExclusiveState() { |
| 343 | if (!jit) { | ||
| 344 | return; | ||
| 345 | } | ||
| 346 | jit->ClearExclusiveState(); | 334 | jit->ClearExclusiveState(); |
| 347 | } | 335 | } |
| 348 | 336 | ||
| @@ -358,7 +346,7 @@ void ARM_Dynarmic_64::PageTableChanged(Common::PageTable& page_table, | |||
| 358 | LoadContext(ctx); | 346 | LoadContext(ctx); |
| 359 | return; | 347 | return; |
| 360 | } | 348 | } |
| 361 | jit = MakeJit(page_table, new_address_space_size_in_bits); | 349 | jit = MakeJit(&page_table, new_address_space_size_in_bits); |
| 362 | LoadContext(ctx); | 350 | LoadContext(ctx); |
| 363 | jit_cache.emplace(key, jit); | 351 | jit_cache.emplace(key, jit); |
| 364 | } | 352 | } |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h index 329b59a32..edef04376 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.h +++ b/src/core/arm/dynarmic/arm_dynarmic_64.h | |||
| @@ -61,7 +61,7 @@ public: | |||
| 61 | std::size_t new_address_space_size_in_bits) override; | 61 | std::size_t new_address_space_size_in_bits) override; |
| 62 | 62 | ||
| 63 | private: | 63 | private: |
| 64 | std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable& page_table, | 64 | std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable* page_table, |
| 65 | std::size_t address_space_bits) const; | 65 | std::size_t address_space_bits) const; |
| 66 | 66 | ||
| 67 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; | 67 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; |
| @@ -71,10 +71,11 @@ private: | |||
| 71 | friend class DynarmicCallbacks64; | 71 | friend class DynarmicCallbacks64; |
| 72 | std::unique_ptr<DynarmicCallbacks64> cb; | 72 | std::unique_ptr<DynarmicCallbacks64> cb; |
| 73 | JitCacheType jit_cache; | 73 | JitCacheType jit_cache; |
| 74 | std::shared_ptr<Dynarmic::A64::Jit> jit; | ||
| 75 | 74 | ||
| 76 | std::size_t core_index; | 75 | std::size_t core_index; |
| 77 | DynarmicExclusiveMonitor& exclusive_monitor; | 76 | DynarmicExclusiveMonitor& exclusive_monitor; |
| 77 | |||
| 78 | std::shared_ptr<Dynarmic::A64::Jit> jit; | ||
| 78 | }; | 79 | }; |
| 79 | 80 | ||
| 80 | } // namespace Core | 81 | } // namespace Core |