Skip to content
Snippets Groups Projects
Commit a4b0a855 authored by Lioncash's avatar Lioncash
Browse files

core/core: Move main process creation into Load()

Now that we have dependencies on the initialization order, we can move
the creation of the main process to a more sensible area: where we
actually load in the executable data.

This allows localizing the creation and loading of the process in one
location, making the initialization of the process much nicer to trace.
parent 6d055119
No related branches found
No related tags found
No related merge requests found
...@@ -117,9 +117,6 @@ struct System::Impl { ...@@ -117,9 +117,6 @@ struct System::Impl {
if (web_browser == nullptr) if (web_browser == nullptr)
web_browser = std::make_unique<Core::Frontend::DefaultWebBrowserApplet>(); web_browser = std::make_unique<Core::Frontend::DefaultWebBrowserApplet>();
auto main_process = Kernel::Process::Create(system, "main");
kernel.MakeCurrentProcess(main_process.get());
telemetry_session = std::make_unique<Core::TelemetrySession>(); telemetry_session = std::make_unique<Core::TelemetrySession>();
service_manager = std::make_shared<Service::SM::ServiceManager>(); service_manager = std::make_shared<Service::SM::ServiceManager>();
...@@ -170,7 +167,8 @@ struct System::Impl { ...@@ -170,7 +167,8 @@ struct System::Impl {
return init_result; return init_result;
} }
const Loader::ResultStatus load_result{app_loader->Load(*kernel.CurrentProcess())}; auto main_process = Kernel::Process::Create(system, "main");
const Loader::ResultStatus load_result{app_loader->Load(*main_process)};
if (load_result != Loader::ResultStatus::Success) { if (load_result != Loader::ResultStatus::Success) {
LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result));
Shutdown(); Shutdown();
...@@ -178,6 +176,7 @@ struct System::Impl { ...@@ -178,6 +176,7 @@ struct System::Impl {
return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) +
static_cast<u32>(load_result)); static_cast<u32>(load_result));
} }
kernel.MakeCurrentProcess(main_process.get());
// Main process has been loaded and been made current. // Main process has been loaded and been made current.
// Begin GPU and CPU execution. // Begin GPU and CPU execution.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment