summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-05-07 23:30:17 -0700
committerGravatar GitHub2021-05-07 23:30:17 -0700
commitfaa067f175cbf5e916ed75776817f0046e6731c4 (patch)
tree8ab02a72a6e4d6578848c8da2c02af02684aeec7 /src/core/core.cpp
parentMerge pull request #6287 from lioncash/ldr-copy (diff)
parenthle: kernel: KPageTable: CanContain should not be constexpr. (diff)
downloadyuzu-faa067f175cbf5e916ed75776817f0046e6731c4.tar.gz
yuzu-faa067f175cbf5e916ed75776817f0046e6731c4.tar.xz
yuzu-faa067f175cbf5e916ed75776817f0046e6731c4.zip
Merge pull request #6266 from bunnei/kautoobject-refactor
Kernel Rework: Migrate kernel objects to KAutoObject
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index d459d6c34..434bf3262 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -27,12 +27,12 @@
27#include "core/file_sys/vfs_concat.h" 27#include "core/file_sys/vfs_concat.h"
28#include "core/file_sys/vfs_real.h" 28#include "core/file_sys/vfs_real.h"
29#include "core/hardware_interrupt_manager.h" 29#include "core/hardware_interrupt_manager.h"
30#include "core/hle/kernel/client_port.h" 30#include "core/hle/kernel/k_client_port.h"
31#include "core/hle/kernel/k_process.h"
31#include "core/hle/kernel/k_scheduler.h" 32#include "core/hle/kernel/k_scheduler.h"
32#include "core/hle/kernel/k_thread.h" 33#include "core/hle/kernel/k_thread.h"
33#include "core/hle/kernel/kernel.h" 34#include "core/hle/kernel/kernel.h"
34#include "core/hle/kernel/physical_core.h" 35#include "core/hle/kernel/physical_core.h"
35#include "core/hle/kernel/process.h"
36#include "core/hle/service/am/applets/applets.h" 36#include "core/hle/service/am/applets/applets.h"
37#include "core/hle/service/apm/controller.h" 37#include "core/hle/service/apm/controller.h"
38#include "core/hle/service/filesystem/filesystem.h" 38#include "core/hle/service/filesystem/filesystem.h"
@@ -166,9 +166,9 @@ struct System::Impl {
166 cpu_manager.SetAsyncGpu(is_async_gpu); 166 cpu_manager.SetAsyncGpu(is_async_gpu);
167 core_timing.SetMulticore(is_multicore); 167 core_timing.SetMulticore(is_multicore);
168 168
169 core_timing.Initialize([&system]() { system.RegisterHostThread(); });
170 kernel.Initialize(); 169 kernel.Initialize();
171 cpu_manager.Initialize(); 170 cpu_manager.Initialize();
171 core_timing.Initialize([&system]() { system.RegisterHostThread(); });
172 172
173 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( 173 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
174 std::chrono::system_clock::now().time_since_epoch()); 174 std::chrono::system_clock::now().time_since_epoch());
@@ -233,8 +233,11 @@ struct System::Impl {
233 } 233 }
234 234
235 telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider); 235 telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider);
236 auto main_process = 236 auto main_process = Kernel::KProcess::Create(system.Kernel());
237 Kernel::Process::Create(system, "main", Kernel::Process::ProcessType::Userland); 237 ASSERT(Kernel::KProcess::Initialize(main_process, system, "main",
238 Kernel::KProcess::ProcessType::Userland)
239 .IsSuccess());
240 main_process->Open();
238 const auto [load_result, load_parameters] = app_loader->Load(*main_process, system); 241 const auto [load_result, load_parameters] = app_loader->Load(*main_process, system);
239 if (load_result != Loader::ResultStatus::Success) { 242 if (load_result != Loader::ResultStatus::Success) {
240 LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result); 243 LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result);
@@ -244,7 +247,7 @@ struct System::Impl {
244 static_cast<u32>(load_result)); 247 static_cast<u32>(load_result));
245 } 248 }
246 AddGlueRegistrationForProcess(*app_loader, *main_process); 249 AddGlueRegistrationForProcess(*app_loader, *main_process);
247 kernel.MakeCurrentProcess(main_process.get()); 250 kernel.MakeCurrentProcess(main_process);
248 kernel.InitializeCores(); 251 kernel.InitializeCores();
249 252
250 // Initialize cheat engine 253 // Initialize cheat engine
@@ -311,6 +314,7 @@ struct System::Impl {
311 gpu_core.reset(); 314 gpu_core.reset();
312 perf_stats.reset(); 315 perf_stats.reset();
313 kernel.Shutdown(); 316 kernel.Shutdown();
317 memory.Reset();
314 applet_manager.ClearAll(); 318 applet_manager.ClearAll();
315 319
316 LOG_DEBUG(Core, "Shutdown OK"); 320 LOG_DEBUG(Core, "Shutdown OK");
@@ -322,7 +326,7 @@ struct System::Impl {
322 return app_loader->ReadTitle(out); 326 return app_loader->ReadTitle(out);
323 } 327 }
324 328
325 void AddGlueRegistrationForProcess(Loader::AppLoader& loader, Kernel::Process& process) { 329 void AddGlueRegistrationForProcess(Loader::AppLoader& loader, Kernel::KProcess& process) {
326 std::vector<u8> nacp_data; 330 std::vector<u8> nacp_data;
327 FileSys::NACP nacp; 331 FileSys::NACP nacp;
328 if (loader.ReadControlData(nacp) == Loader::ResultStatus::Success) { 332 if (loader.ReadControlData(nacp) == Loader::ResultStatus::Success) {
@@ -513,7 +517,7 @@ const Kernel::GlobalSchedulerContext& System::GlobalSchedulerContext() const {
513 return impl->kernel.GlobalSchedulerContext(); 517 return impl->kernel.GlobalSchedulerContext();
514} 518}
515 519
516Kernel::Process* System::CurrentProcess() { 520Kernel::KProcess* System::CurrentProcess() {
517 return impl->kernel.CurrentProcess(); 521 return impl->kernel.CurrentProcess();
518} 522}
519 523
@@ -525,7 +529,7 @@ const Core::DeviceMemory& System::DeviceMemory() const {
525 return *impl->device_memory; 529 return *impl->device_memory;
526} 530}
527 531
528const Kernel::Process* System::CurrentProcess() const { 532const Kernel::KProcess* System::CurrentProcess() const {
529 return impl->kernel.CurrentProcess(); 533 return impl->kernel.CurrentProcess();
530} 534}
531 535