service: Eliminate usages of the global system instance

Completely removes all usages of the global system instance within the
services code by passing in the using system instance to the services.
This commit is contained in:
Lioncash 2020-11-26 15:19:08 -05:00
parent 322349e8cc
commit 1a954b2a59
222 changed files with 1221 additions and 907 deletions

View file

@ -115,7 +115,7 @@ static_assert(sizeof(NROInfo) == 0x60, "NROInfo has invalid size.");
class DebugMonitor final : public ServiceFramework<DebugMonitor> {
public:
explicit DebugMonitor() : ServiceFramework{"ldr:dmnt"} {
explicit DebugMonitor(Core::System& system_) : ServiceFramework{system_, "ldr:dmnt"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "AddProcessToDebugLaunchQueue"},
@ -130,7 +130,7 @@ public:
class ProcessManager final : public ServiceFramework<ProcessManager> {
public:
explicit ProcessManager() : ServiceFramework{"ldr:pm"} {
explicit ProcessManager(Core::System& system_) : ServiceFramework{system_, "ldr:pm"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "CreateProcess"},
@ -147,7 +147,7 @@ public:
class Shell final : public ServiceFramework<Shell> {
public:
explicit Shell() : ServiceFramework{"ldr:shel"} {
explicit Shell(Core::System& system_) : ServiceFramework{system_, "ldr:shel"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "AddProcessToLaunchQueue"},
@ -161,7 +161,7 @@ public:
class RelocatableObject final : public ServiceFramework<RelocatableObject> {
public:
explicit RelocatableObject(Core::System& system) : ServiceFramework{"ldr:ro"}, system(system) {
explicit RelocatableObject(Core::System& system_) : ServiceFramework{system_, "ldr:ro"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &RelocatableObject::LoadNro, "LoadNro"},
@ -639,13 +639,12 @@ private:
Common::Is4KBAligned(header.segment_headers[RO_INDEX].memory_size) &&
Common::Is4KBAligned(header.segment_headers[DATA_INDEX].memory_size);
}
Core::System& system;
};
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
std::make_shared<DebugMonitor>()->InstallAsService(sm);
std::make_shared<ProcessManager>()->InstallAsService(sm);
std::make_shared<Shell>()->InstallAsService(sm);
std::make_shared<DebugMonitor>(system)->InstallAsService(sm);
std::make_shared<ProcessManager>(system)->InstallAsService(sm);
std::make_shared<Shell>(system)->InstallAsService(sm);
std::make_shared<RelocatableObject>(system)->InstallAsService(sm);
}

View file

@ -4,6 +4,10 @@
#pragma once
namespace Core {
class System;
}
namespace Service::SM {
class ServiceManager;
}