diff options
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index f9f8a3000..e8936b09d 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include "common/string_util.h" | 11 | #include "common/string_util.h" |
| 12 | #include "core/arm/exclusive_monitor.h" | 12 | #include "core/arm/exclusive_monitor.h" |
| 13 | #include "core/core.h" | 13 | #include "core/core.h" |
| 14 | #include "core/core_manager.h" | ||
| 15 | #include "core/core_timing.h" | 14 | #include "core/core_timing.h" |
| 16 | #include "core/cpu_manager.h" | 15 | #include "core/cpu_manager.h" |
| 17 | #include "core/device_memory.h" | 16 | #include "core/device_memory.h" |
| @@ -117,23 +116,30 @@ struct System::Impl { | |||
| 117 | : kernel{system}, fs_controller{system}, memory{system}, | 116 | : kernel{system}, fs_controller{system}, memory{system}, |
| 118 | cpu_manager{system}, reporter{system}, applet_manager{system} {} | 117 | cpu_manager{system}, reporter{system}, applet_manager{system} {} |
| 119 | 118 | ||
| 120 | CoreManager& CurrentCoreManager() { | ||
| 121 | return cpu_manager.GetCurrentCoreManager(); | ||
| 122 | } | ||
| 123 | |||
| 124 | Kernel::PhysicalCore& CurrentPhysicalCore() { | 119 | Kernel::PhysicalCore& CurrentPhysicalCore() { |
| 125 | const auto index = cpu_manager.GetActiveCoreIndex(); | 120 | return kernel.CurrentPhysicalCore(); |
| 126 | return kernel.PhysicalCore(index); | ||
| 127 | } | 121 | } |
| 128 | 122 | ||
| 129 | Kernel::PhysicalCore& GetPhysicalCore(std::size_t index) { | 123 | Kernel::PhysicalCore& GetPhysicalCore(std::size_t index) { |
| 130 | return kernel.PhysicalCore(index); | 124 | return kernel.PhysicalCore(index); |
| 131 | } | 125 | } |
| 132 | 126 | ||
| 133 | ResultStatus RunLoop(bool tight_loop) { | 127 | ResultStatus Run() { |
| 134 | status = ResultStatus::Success; | 128 | status = ResultStatus::Success; |
| 135 | 129 | ||
| 136 | cpu_manager.RunLoop(tight_loop); | 130 | kernel.Suspend(false); |
| 131 | core_timing.SyncPause(false); | ||
| 132 | cpu_manager.Pause(false); | ||
| 133 | |||
| 134 | return status; | ||
| 135 | } | ||
| 136 | |||
| 137 | ResultStatus Pause() { | ||
| 138 | status = ResultStatus::Success; | ||
| 139 | |||
| 140 | kernel.Suspend(true); | ||
| 141 | core_timing.SyncPause(true); | ||
| 142 | cpu_manager.Pause(true); | ||
| 137 | 143 | ||
| 138 | return status; | 144 | return status; |
| 139 | } | 145 | } |
| @@ -143,7 +149,7 @@ struct System::Impl { | |||
| 143 | 149 | ||
| 144 | device_memory = std::make_unique<Core::DeviceMemory>(system); | 150 | device_memory = std::make_unique<Core::DeviceMemory>(system); |
| 145 | 151 | ||
| 146 | core_timing.Initialize(); | 152 | core_timing.Initialize([&system]() { system.RegisterHostThread(); }); |
| 147 | kernel.Initialize(); | 153 | kernel.Initialize(); |
| 148 | cpu_manager.Initialize(); | 154 | cpu_manager.Initialize(); |
| 149 | 155 | ||
| @@ -387,20 +393,24 @@ struct System::Impl { | |||
| 387 | System::System() : impl{std::make_unique<Impl>(*this)} {} | 393 | System::System() : impl{std::make_unique<Impl>(*this)} {} |
| 388 | System::~System() = default; | 394 | System::~System() = default; |
| 389 | 395 | ||
| 390 | CoreManager& System::CurrentCoreManager() { | 396 | CpuManager& System::GetCpuManager() { |
| 391 | return impl->CurrentCoreManager(); | 397 | return impl->cpu_manager; |
| 398 | } | ||
| 399 | |||
| 400 | const CpuManager& System::GetCpuManager() const { | ||
| 401 | return impl->cpu_manager; | ||
| 392 | } | 402 | } |
| 393 | 403 | ||
| 394 | const CoreManager& System::CurrentCoreManager() const { | 404 | System::ResultStatus System::Run() { |
| 395 | return impl->CurrentCoreManager(); | 405 | return impl->Run(); |
| 396 | } | 406 | } |
| 397 | 407 | ||
| 398 | System::ResultStatus System::RunLoop(bool tight_loop) { | 408 | System::ResultStatus System::Pause() { |
| 399 | return impl->RunLoop(tight_loop); | 409 | return impl->Pause(); |
| 400 | } | 410 | } |
| 401 | 411 | ||
| 402 | System::ResultStatus System::SingleStep() { | 412 | System::ResultStatus System::SingleStep() { |
| 403 | return RunLoop(false); | 413 | return ResultStatus::Success; |
| 404 | } | 414 | } |
| 405 | 415 | ||
| 406 | void System::InvalidateCpuInstructionCaches() { | 416 | void System::InvalidateCpuInstructionCaches() { |
| @@ -444,7 +454,9 @@ const ARM_Interface& System::CurrentArmInterface() const { | |||
| 444 | } | 454 | } |
| 445 | 455 | ||
| 446 | std::size_t System::CurrentCoreIndex() const { | 456 | std::size_t System::CurrentCoreIndex() const { |
| 447 | return impl->cpu_manager.GetActiveCoreIndex(); | 457 | std::size_t core = impl->kernel.GetCurrentHostThreadID(); |
| 458 | ASSERT(core < Core::Hardware::NUM_CPU_CORES); | ||
| 459 | return core; | ||
| 448 | } | 460 | } |
| 449 | 461 | ||
| 450 | Kernel::Scheduler& System::CurrentScheduler() { | 462 | Kernel::Scheduler& System::CurrentScheduler() { |
| @@ -497,15 +509,6 @@ const ARM_Interface& System::ArmInterface(std::size_t core_index) const { | |||
| 497 | return impl->GetPhysicalCore(core_index).ArmInterface(); | 509 | return impl->GetPhysicalCore(core_index).ArmInterface(); |
| 498 | } | 510 | } |
| 499 | 511 | ||
| 500 | CoreManager& System::GetCoreManager(std::size_t core_index) { | ||
| 501 | return impl->cpu_manager.GetCoreManager(core_index); | ||
| 502 | } | ||
| 503 | |||
| 504 | const CoreManager& System::GetCoreManager(std::size_t core_index) const { | ||
| 505 | ASSERT(core_index < NUM_CPU_CORES); | ||
| 506 | return impl->cpu_manager.GetCoreManager(core_index); | ||
| 507 | } | ||
| 508 | |||
| 509 | ExclusiveMonitor& System::Monitor() { | 512 | ExclusiveMonitor& System::Monitor() { |
| 510 | return impl->kernel.GetExclusiveMonitor(); | 513 | return impl->kernel.GetExclusiveMonitor(); |
| 511 | } | 514 | } |