summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-01-25 18:55:32 -0400
committerGravatar Fernando Sahmkow2020-01-25 18:55:32 -0400
commit4d6a86b03fe6ae0d98838a21613b66d5196150af (patch)
tree21f4b8e63e6435b2d816936af8b494882a3cdfb2 /src/core/core.cpp
parentKernel: Implement Physical Core. (diff)
downloadyuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.gz
yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.xz
yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.zip
Core: Refactor CPU Management.
This commit moves ARM Interface and Scheduler handling into the kernel.
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index d697b80ef..27b8d3408 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -28,6 +28,7 @@
28#include "core/hardware_interrupt_manager.h" 28#include "core/hardware_interrupt_manager.h"
29#include "core/hle/kernel/client_port.h" 29#include "core/hle/kernel/client_port.h"
30#include "core/hle/kernel/kernel.h" 30#include "core/hle/kernel/kernel.h"
31#include "core/hle/kernel/physical_core.h"
31#include "core/hle/kernel/process.h" 32#include "core/hle/kernel/process.h"
32#include "core/hle/kernel/scheduler.h" 33#include "core/hle/kernel/scheduler.h"
33#include "core/hle/kernel/thread.h" 34#include "core/hle/kernel/thread.h"
@@ -119,6 +120,15 @@ struct System::Impl {
119 return cpu_core_manager.GetCurrentCore(); 120 return cpu_core_manager.GetCurrentCore();
120 } 121 }
121 122
123 Kernel::PhysicalCore& CurrentPhysicalCore() {
124 const auto i = cpu_core_manager.GetCurrentCoreIndex();
125 return kernel.PhysicalCore(i);
126 }
127
128 Kernel::PhysicalCore& GetPhysicalCore(std::size_t index) {
129 return kernel.PhysicalCore(index);
130 }
131
122 ResultStatus RunLoop(bool tight_loop) { 132 ResultStatus RunLoop(bool tight_loop) {
123 status = ResultStatus::Success; 133 status = ResultStatus::Success;
124 134
@@ -131,8 +141,8 @@ struct System::Impl {
131 LOG_DEBUG(HW_Memory, "initialized OK"); 141 LOG_DEBUG(HW_Memory, "initialized OK");
132 142
133 core_timing.Initialize(); 143 core_timing.Initialize();
134 cpu_core_manager.Initialize();
135 kernel.Initialize(); 144 kernel.Initialize();
145 cpu_core_manager.Initialize();
136 146
137 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( 147 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
138 std::chrono::system_clock::now().time_since_epoch()); 148 std::chrono::system_clock::now().time_since_epoch());
@@ -205,7 +215,6 @@ struct System::Impl {
205 // Main process has been loaded and been made current. 215 // Main process has been loaded and been made current.
206 // Begin GPU and CPU execution. 216 // Begin GPU and CPU execution.
207 gpu_core->Start(); 217 gpu_core->Start();
208 cpu_core_manager.StartThreads();
209 218
210 // Initialize cheat engine 219 // Initialize cheat engine
211 if (cheat_engine) { 220 if (cheat_engine) {
@@ -394,7 +403,7 @@ System::ResultStatus System::SingleStep() {
394} 403}
395 404
396void System::InvalidateCpuInstructionCaches() { 405void System::InvalidateCpuInstructionCaches() {
397 impl->cpu_core_manager.InvalidateAllInstructionCaches(); 406 impl->kernel.InvalidateAllInstructionCaches();
398} 407}
399 408
400System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) { 409System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) {
@@ -428,11 +437,11 @@ const TelemetrySession& System::TelemetrySession() const {
428} 437}
429 438
430ARM_Interface& System::CurrentArmInterface() { 439ARM_Interface& System::CurrentArmInterface() {
431 return CurrentCpuCore().ArmInterface(); 440 return impl->CurrentPhysicalCore().ArmInterface();
432} 441}
433 442
434const ARM_Interface& System::CurrentArmInterface() const { 443const ARM_Interface& System::CurrentArmInterface() const {
435 return CurrentCpuCore().ArmInterface(); 444 return impl->CurrentPhysicalCore().ArmInterface();
436} 445}
437 446
438std::size_t System::CurrentCoreIndex() const { 447std::size_t System::CurrentCoreIndex() const {
@@ -440,19 +449,19 @@ std::size_t System::CurrentCoreIndex() const {
440} 449}
441 450
442Kernel::Scheduler& System::CurrentScheduler() { 451Kernel::Scheduler& System::CurrentScheduler() {
443 return CurrentCpuCore().Scheduler(); 452 return impl->CurrentPhysicalCore().Scheduler();
444} 453}
445 454
446const Kernel::Scheduler& System::CurrentScheduler() const { 455const Kernel::Scheduler& System::CurrentScheduler() const {
447 return CurrentCpuCore().Scheduler(); 456 return impl->CurrentPhysicalCore().Scheduler();
448} 457}
449 458
450Kernel::Scheduler& System::Scheduler(std::size_t core_index) { 459Kernel::Scheduler& System::Scheduler(std::size_t core_index) {
451 return CpuCore(core_index).Scheduler(); 460 return impl->GetPhysicalCore(core_index).Scheduler();
452} 461}
453 462
454const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const { 463const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const {
455 return CpuCore(core_index).Scheduler(); 464 return impl->GetPhysicalCore(core_index).Scheduler();
456} 465}
457 466
458/// Gets the global scheduler 467/// Gets the global scheduler
@@ -474,11 +483,11 @@ const Kernel::Process* System::CurrentProcess() const {
474} 483}
475 484
476ARM_Interface& System::ArmInterface(std::size_t core_index) { 485ARM_Interface& System::ArmInterface(std::size_t core_index) {
477 return CpuCore(core_index).ArmInterface(); 486 return impl->GetPhysicalCore(core_index).ArmInterface();
478} 487}
479 488
480const ARM_Interface& System::ArmInterface(std::size_t core_index) const { 489const ARM_Interface& System::ArmInterface(std::size_t core_index) const {
481 return CpuCore(core_index).ArmInterface(); 490 return impl->GetPhysicalCore(core_index).ArmInterface();
482} 491}
483 492
484Cpu& System::CpuCore(std::size_t core_index) { 493Cpu& System::CpuCore(std::size_t core_index) {
@@ -491,11 +500,11 @@ const Cpu& System::CpuCore(std::size_t core_index) const {
491} 500}
492 501
493ExclusiveMonitor& System::Monitor() { 502ExclusiveMonitor& System::Monitor() {
494 return impl->cpu_core_manager.GetExclusiveMonitor(); 503 return impl->kernel.GetExclusiveMonitor();
495} 504}
496 505
497const ExclusiveMonitor& System::Monitor() const { 506const ExclusiveMonitor& System::Monitor() const {
498 return impl->cpu_core_manager.GetExclusiveMonitor(); 507 return impl->kernel.GetExclusiveMonitor();
499} 508}
500 509
501Memory::Memory& System::Memory() { 510Memory::Memory& System::Memory() {