diff options
| author | 2020-03-01 12:14:17 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:58 -0400 | |
| commit | 1567824d2da8e9b49b433f3d1d753d8ad84e65f9 (patch) | |
| tree | c9553bb3f1693e430054695737d2f87ba4b58955 /src/core/hle/kernel/kernel.cpp | |
| parent | Core: Refactor ARM Interface. (diff) | |
| download | yuzu-1567824d2da8e9b49b433f3d1d753d8ad84e65f9.tar.gz yuzu-1567824d2da8e9b49b433f3d1d753d8ad84e65f9.tar.xz yuzu-1567824d2da8e9b49b433f3d1d753d8ad84e65f9.zip | |
General: Move ARM_Interface into Threads.
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index e33ef5323..3feddd9ad 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #include "core/arm/arm_interface.h" | 19 | #include "core/arm/arm_interface.h" |
| 20 | #include "core/arm/cpu_interrupt_handler.h" | 20 | #include "core/arm/cpu_interrupt_handler.h" |
| 21 | #include "core/arm/exclusive_monitor.h" | 21 | #include "core/arm/exclusive_monitor.h" |
| 22 | #include "core/arm/unicorn/arm_unicorn.h" | ||
| 23 | #include "core/core.h" | 22 | #include "core/core.h" |
| 24 | #include "core/core_timing.h" | 23 | #include "core/core_timing.h" |
| 25 | #include "core/core_timing_util.h" | 24 | #include "core/core_timing_util.h" |
| @@ -45,11 +44,6 @@ | |||
| 45 | #include "core/hle/result.h" | 44 | #include "core/hle/result.h" |
| 46 | #include "core/memory.h" | 45 | #include "core/memory.h" |
| 47 | 46 | ||
| 48 | #ifdef ARCHITECTURE_x86_64 | ||
| 49 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | ||
| 50 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | ||
| 51 | #endif | ||
| 52 | |||
| 53 | MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); | 47 | MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); |
| 54 | 48 | ||
| 55 | namespace Kernel { | 49 | namespace Kernel { |
| @@ -186,20 +180,8 @@ struct KernelCore::Impl { | |||
| 186 | exclusive_monitor = | 180 | exclusive_monitor = |
| 187 | Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); | 181 | Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); |
| 188 | for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | 182 | for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { |
| 189 | #ifdef ARCHITECTURE_x86_64 | 183 | schedulers[i] = std::make_unique<Kernel::Scheduler>(system, i); |
| 190 | arm_interfaces_32[i] = | 184 | cores.emplace_back(system, i, *schedulers[i], interrupts[i]); |
| 191 | std::make_unique<Core::ARM_Dynarmic_32>(system, interrupts, *exclusive_monitor, i); | ||
| 192 | arm_interfaces_64[i] = | ||
| 193 | std::make_unique<Core::ARM_Dynarmic_64>(system, interrupts, *exclusive_monitor, i); | ||
| 194 | #else | ||
| 195 | arm_interfaces_32[i] = std::make_shared<Core::ARM_Unicorn>( | ||
| 196 | system, interrupts, ARM_Unicorn::Arch::AArch32, i); | ||
| 197 | arm_interfaces_64[i] = std::make_shared<Core::ARM_Unicorn>( | ||
| 198 | system, interrupts, ARM_Unicorn::Arch::AArch64, i); | ||
| 199 | LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available"); | ||
| 200 | #endif | ||
| 201 | cores.emplace_back(system, i, *exclusive_monitor, interrupts[i], *arm_interfaces_32[i], | ||
| 202 | *arm_interfaces_64[i]); | ||
| 203 | } | 185 | } |
| 204 | } | 186 | } |
| 205 | 187 | ||
| @@ -268,10 +250,6 @@ struct KernelCore::Impl { | |||
| 268 | return; | 250 | return; |
| 269 | } | 251 | } |
| 270 | 252 | ||
| 271 | for (auto& core : cores) { | ||
| 272 | core.SetIs64Bit(process->Is64BitProcess()); | ||
| 273 | } | ||
| 274 | |||
| 275 | u32 core_id = GetCurrentHostThreadID(); | 253 | u32 core_id = GetCurrentHostThreadID(); |
| 276 | if (core_id < Core::Hardware::NUM_CPU_CORES) { | 254 | if (core_id < Core::Hardware::NUM_CPU_CORES) { |
| 277 | system.Memory().SetCurrentPageTable(*process, core_id); | 255 | system.Memory().SetCurrentPageTable(*process, core_id); |
| @@ -429,10 +407,7 @@ struct KernelCore::Impl { | |||
| 429 | 407 | ||
| 430 | std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; | 408 | std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; |
| 431 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; | 409 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; |
| 432 | std::array<std::unique_ptr<Core::ARM_Interface>, Core::Hardware::NUM_CPU_CORES> | 410 | std::array<std::unique_ptr<Kernel::Scheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; |
| 433 | arm_interfaces_32{}; | ||
| 434 | std::array<std::unique_ptr<Core::ARM_Interface>, Core::Hardware::NUM_CPU_CORES> | ||
| 435 | arm_interfaces_64{}; | ||
| 436 | 411 | ||
| 437 | bool is_multicore{}; | 412 | bool is_multicore{}; |
| 438 | std::thread::id single_core_thread_id{}; | 413 | std::thread::id single_core_thread_id{}; |
| @@ -497,11 +472,11 @@ const Kernel::GlobalScheduler& KernelCore::GlobalScheduler() const { | |||
| 497 | } | 472 | } |
| 498 | 473 | ||
| 499 | Kernel::Scheduler& KernelCore::Scheduler(std::size_t id) { | 474 | Kernel::Scheduler& KernelCore::Scheduler(std::size_t id) { |
| 500 | return impl->cores[id].Scheduler(); | 475 | return *impl->schedulers[id]; |
| 501 | } | 476 | } |
| 502 | 477 | ||
| 503 | const Kernel::Scheduler& KernelCore::Scheduler(std::size_t id) const { | 478 | const Kernel::Scheduler& KernelCore::Scheduler(std::size_t id) const { |
| 504 | return impl->cores[id].Scheduler(); | 479 | return *impl->schedulers[id]; |
| 505 | } | 480 | } |
| 506 | 481 | ||
| 507 | Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) { | 482 | Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) { |
| @@ -525,11 +500,23 @@ const Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() const { | |||
| 525 | } | 500 | } |
| 526 | 501 | ||
| 527 | Kernel::Scheduler& KernelCore::CurrentScheduler() { | 502 | Kernel::Scheduler& KernelCore::CurrentScheduler() { |
| 528 | return CurrentPhysicalCore().Scheduler(); | 503 | u32 core_id = impl->GetCurrentHostThreadID(); |
| 504 | ASSERT(core_id < Core::Hardware::NUM_CPU_CORES); | ||
| 505 | return *impl->schedulers[core_id]; | ||
| 529 | } | 506 | } |
| 530 | 507 | ||
| 531 | const Kernel::Scheduler& KernelCore::CurrentScheduler() const { | 508 | const Kernel::Scheduler& KernelCore::CurrentScheduler() const { |
| 532 | return CurrentPhysicalCore().Scheduler(); | 509 | u32 core_id = impl->GetCurrentHostThreadID(); |
| 510 | ASSERT(core_id < Core::Hardware::NUM_CPU_CORES); | ||
| 511 | return *impl->schedulers[core_id]; | ||
| 512 | } | ||
| 513 | |||
| 514 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>& KernelCore::Interrupts() { | ||
| 515 | return impl->interrupts; | ||
| 516 | } | ||
| 517 | |||
| 518 | const std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>& KernelCore::Interrupts() const { | ||
| 519 | return impl->interrupts; | ||
| 533 | } | 520 | } |
| 534 | 521 | ||
| 535 | Kernel::Synchronization& KernelCore::Synchronization() { | 522 | Kernel::Synchronization& KernelCore::Synchronization() { |
| @@ -557,15 +544,11 @@ const Core::ExclusiveMonitor& KernelCore::GetExclusiveMonitor() const { | |||
| 557 | } | 544 | } |
| 558 | 545 | ||
| 559 | void KernelCore::InvalidateAllInstructionCaches() { | 546 | void KernelCore::InvalidateAllInstructionCaches() { |
| 560 | for (std::size_t i = 0; i < impl->global_scheduler.CpuCoresCount(); i++) { | 547 | //TODO: Reimplement, this |
| 561 | PhysicalCore(i).ArmInterface().ClearInstructionCache(); | ||
| 562 | } | ||
| 563 | } | 548 | } |
| 564 | 549 | ||
| 565 | void KernelCore::PrepareReschedule(std::size_t id) { | 550 | void KernelCore::PrepareReschedule(std::size_t id) { |
| 566 | if (id < impl->global_scheduler.CpuCoresCount()) { | 551 | // TODO: Reimplement, this |
| 567 | impl->cores[id].Stop(); | ||
| 568 | } | ||
| 569 | } | 552 | } |
| 570 | 553 | ||
| 571 | void KernelCore::AddNamedPort(std::string name, std::shared_ptr<ClientPort> port) { | 554 | void KernelCore::AddNamedPort(std::string name, std::shared_ptr<ClientPort> port) { |