summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-01-30 18:13:59 -0500
committerGravatar GitHub2020-01-30 18:13:59 -0500
commit985d0f35e55f0752c6e147d0140b367708499cb4 (patch)
tree119249aee3acc2cc2ee6a5d391288b52c126765b /src/core/core.cpp
parentMerge pull request #3151 from FearlessTobi/fix-korean (diff)
parentSystem: Address Feedback (diff)
downloadyuzu-985d0f35e55f0752c6e147d0140b367708499cb4.tar.gz
yuzu-985d0f35e55f0752c6e147d0140b367708499cb4.tar.xz
yuzu-985d0f35e55f0752c6e147d0140b367708499cb4.zip
Merge pull request #3353 from FernandoS27/aries
System: Refactor CPU Core management and move ARMInterface and Schedulers to Kernel
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index d697b80ef..c53d122be 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -11,9 +11,9 @@
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_cpu.h" 14#include "core/core_manager.h"
15#include "core/core_timing.h" 15#include "core/core_timing.h"
16#include "core/cpu_core_manager.h" 16#include "core/cpu_manager.h"
17#include "core/file_sys/bis_factory.h" 17#include "core/file_sys/bis_factory.h"
18#include "core/file_sys/card_image.h" 18#include "core/file_sys/card_image.h"
19#include "core/file_sys/mode.h" 19#include "core/file_sys/mode.h"
@@ -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"
@@ -113,16 +114,25 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
113struct System::Impl { 114struct System::Impl {
114 explicit Impl(System& system) 115 explicit Impl(System& system)
115 : kernel{system}, fs_controller{system}, memory{system}, 116 : kernel{system}, fs_controller{system}, memory{system},
116 cpu_core_manager{system}, reporter{system}, applet_manager{system} {} 117 cpu_manager{system}, reporter{system}, applet_manager{system} {}
117 118
118 Cpu& CurrentCpuCore() { 119 CoreManager& CurrentCoreManager() {
119 return cpu_core_manager.GetCurrentCore(); 120 return cpu_manager.GetCurrentCoreManager();
121 }
122
123 Kernel::PhysicalCore& CurrentPhysicalCore() {
124 const auto index = cpu_manager.GetActiveCoreIndex();
125 return kernel.PhysicalCore(index);
126 }
127
128 Kernel::PhysicalCore& GetPhysicalCore(std::size_t index) {
129 return kernel.PhysicalCore(index);
120 } 130 }
121 131
122 ResultStatus RunLoop(bool tight_loop) { 132 ResultStatus RunLoop(bool tight_loop) {
123 status = ResultStatus::Success; 133 status = ResultStatus::Success;
124 134
125 cpu_core_manager.RunLoop(tight_loop); 135 cpu_manager.RunLoop(tight_loop);
126 136
127 return status; 137 return status;
128 } 138 }
@@ -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_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) {
@@ -272,7 +281,7 @@ struct System::Impl {
272 gpu_core.reset(); 281 gpu_core.reset();
273 282
274 // Close all CPU/threading state 283 // Close all CPU/threading state
275 cpu_core_manager.Shutdown(); 284 cpu_manager.Shutdown();
276 285
277 // Shutdown kernel and core timing 286 // Shutdown kernel and core timing
278 kernel.Shutdown(); 287 kernel.Shutdown();
@@ -342,7 +351,7 @@ struct System::Impl {
342 std::unique_ptr<Tegra::GPU> gpu_core; 351 std::unique_ptr<Tegra::GPU> gpu_core;
343 std::unique_ptr<Hardware::InterruptManager> interrupt_manager; 352 std::unique_ptr<Hardware::InterruptManager> interrupt_manager;
344 Memory::Memory memory; 353 Memory::Memory memory;
345 CpuCoreManager cpu_core_manager; 354 CpuManager cpu_manager;
346 bool is_powered_on = false; 355 bool is_powered_on = false;
347 bool exit_lock = false; 356 bool exit_lock = false;
348 357
@@ -377,12 +386,12 @@ struct System::Impl {
377System::System() : impl{std::make_unique<Impl>(*this)} {} 386System::System() : impl{std::make_unique<Impl>(*this)} {}
378System::~System() = default; 387System::~System() = default;
379 388
380Cpu& System::CurrentCpuCore() { 389CoreManager& System::CurrentCoreManager() {
381 return impl->CurrentCpuCore(); 390 return impl->CurrentCoreManager();
382} 391}
383 392
384const Cpu& System::CurrentCpuCore() const { 393const CoreManager& System::CurrentCoreManager() const {
385 return impl->CurrentCpuCore(); 394 return impl->CurrentCoreManager();
386} 395}
387 396
388System::ResultStatus System::RunLoop(bool tight_loop) { 397System::ResultStatus System::RunLoop(bool tight_loop) {
@@ -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) {
@@ -406,13 +415,11 @@ bool System::IsPoweredOn() const {
406} 415}
407 416
408void System::PrepareReschedule() { 417void System::PrepareReschedule() {
409 CurrentCpuCore().PrepareReschedule(); 418 impl->CurrentPhysicalCore().Stop();
410} 419}
411 420
412void System::PrepareReschedule(const u32 core_index) { 421void System::PrepareReschedule(const u32 core_index) {
413 if (core_index < GlobalScheduler().CpuCoresCount()) { 422 impl->kernel.PrepareReschedule(core_index);
414 CpuCore(core_index).PrepareReschedule();
415 }
416} 423}
417 424
418PerfStatsResults System::GetAndResetPerfStats() { 425PerfStatsResults System::GetAndResetPerfStats() {
@@ -428,31 +435,31 @@ const TelemetrySession& System::TelemetrySession() const {
428} 435}
429 436
430ARM_Interface& System::CurrentArmInterface() { 437ARM_Interface& System::CurrentArmInterface() {
431 return CurrentCpuCore().ArmInterface(); 438 return impl->CurrentPhysicalCore().ArmInterface();
432} 439}
433 440
434const ARM_Interface& System::CurrentArmInterface() const { 441const ARM_Interface& System::CurrentArmInterface() const {
435 return CurrentCpuCore().ArmInterface(); 442 return impl->CurrentPhysicalCore().ArmInterface();
436} 443}
437 444
438std::size_t System::CurrentCoreIndex() const { 445std::size_t System::CurrentCoreIndex() const {
439 return CurrentCpuCore().CoreIndex(); 446 return impl->cpu_manager.GetActiveCoreIndex();
440} 447}
441 448
442Kernel::Scheduler& System::CurrentScheduler() { 449Kernel::Scheduler& System::CurrentScheduler() {
443 return CurrentCpuCore().Scheduler(); 450 return impl->CurrentPhysicalCore().Scheduler();
444} 451}
445 452
446const Kernel::Scheduler& System::CurrentScheduler() const { 453const Kernel::Scheduler& System::CurrentScheduler() const {
447 return CurrentCpuCore().Scheduler(); 454 return impl->CurrentPhysicalCore().Scheduler();
448} 455}
449 456
450Kernel::Scheduler& System::Scheduler(std::size_t core_index) { 457Kernel::Scheduler& System::Scheduler(std::size_t core_index) {
451 return CpuCore(core_index).Scheduler(); 458 return impl->GetPhysicalCore(core_index).Scheduler();
452} 459}
453 460
454const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const { 461const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const {
455 return CpuCore(core_index).Scheduler(); 462 return impl->GetPhysicalCore(core_index).Scheduler();
456} 463}
457 464
458/// Gets the global scheduler 465/// Gets the global scheduler
@@ -474,28 +481,28 @@ const Kernel::Process* System::CurrentProcess() const {
474} 481}
475 482
476ARM_Interface& System::ArmInterface(std::size_t core_index) { 483ARM_Interface& System::ArmInterface(std::size_t core_index) {
477 return CpuCore(core_index).ArmInterface(); 484 return impl->GetPhysicalCore(core_index).ArmInterface();
478} 485}
479 486
480const ARM_Interface& System::ArmInterface(std::size_t core_index) const { 487const ARM_Interface& System::ArmInterface(std::size_t core_index) const {
481 return CpuCore(core_index).ArmInterface(); 488 return impl->GetPhysicalCore(core_index).ArmInterface();
482} 489}
483 490
484Cpu& System::CpuCore(std::size_t core_index) { 491CoreManager& System::GetCoreManager(std::size_t core_index) {
485 return impl->cpu_core_manager.GetCore(core_index); 492 return impl->cpu_manager.GetCoreManager(core_index);
486} 493}
487 494
488const Cpu& System::CpuCore(std::size_t core_index) const { 495const CoreManager& System::GetCoreManager(std::size_t core_index) const {
489 ASSERT(core_index < NUM_CPU_CORES); 496 ASSERT(core_index < NUM_CPU_CORES);
490 return impl->cpu_core_manager.GetCore(core_index); 497 return impl->cpu_manager.GetCoreManager(core_index);
491} 498}
492 499
493ExclusiveMonitor& System::Monitor() { 500ExclusiveMonitor& System::Monitor() {
494 return impl->cpu_core_manager.GetExclusiveMonitor(); 501 return impl->kernel.GetExclusiveMonitor();
495} 502}
496 503
497const ExclusiveMonitor& System::Monitor() const { 504const ExclusiveMonitor& System::Monitor() const {
498 return impl->cpu_core_manager.GetExclusiveMonitor(); 505 return impl->kernel.GetExclusiveMonitor();
499} 506}
500 507
501Memory::Memory& System::Memory() { 508Memory::Memory& System::Memory() {