From 1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 26 Nov 2020 15:19:08 -0500 Subject: 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. --- src/core/hle/service/apm/apm.cpp | 9 +++++---- src/core/hle/service/apm/apm.h | 4 +++- src/core/hle/service/apm/interface.cpp | 15 +++++++++------ src/core/hle/service/apm/interface.h | 5 +++-- 4 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src/core/hle/service/apm') diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp index e2d8f0027..97d6619dd 100644 --- a/src/core/hle/service/apm/apm.cpp +++ b/src/core/hle/service/apm/apm.cpp @@ -14,13 +14,14 @@ Module::~Module() = default; void InstallInterfaces(Core::System& system) { auto module_ = std::make_shared(); - std::make_shared(module_, system.GetAPMController(), "apm") + std::make_shared(system, module_, system.GetAPMController(), "apm") ->InstallAsService(system.ServiceManager()); - std::make_shared(module_, system.GetAPMController(), "apm:p") + std::make_shared(system, module_, system.GetAPMController(), "apm:p") ->InstallAsService(system.ServiceManager()); - std::make_shared(module_, system.GetAPMController(), "apm:am") + std::make_shared(system, module_, system.GetAPMController(), "apm:am") + ->InstallAsService(system.ServiceManager()); + std::make_shared(system, system.GetAPMController()) ->InstallAsService(system.ServiceManager()); - std::make_shared(system.GetAPMController())->InstallAsService(system.ServiceManager()); } } // namespace Service::APM diff --git a/src/core/hle/service/apm/apm.h b/src/core/hle/service/apm/apm.h index cf4c2bb11..691fe6c16 100644 --- a/src/core/hle/service/apm/apm.h +++ b/src/core/hle/service/apm/apm.h @@ -4,7 +4,9 @@ #pragma once -#include "core/hle/service/service.h" +namespace Core { +class System; +} namespace Service::APM { diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp index 06f0f8edd..89442e21e 100644 --- a/src/core/hle/service/apm/interface.cpp +++ b/src/core/hle/service/apm/interface.cpp @@ -12,7 +12,8 @@ namespace Service::APM { class ISession final : public ServiceFramework { public: - ISession(Controller& controller) : ServiceFramework("ISession"), controller(controller) { + explicit ISession(Core::System& system_, Controller& controller_) + : ServiceFramework{system_, "ISession"}, controller{controller_} { static const FunctionInfo functions[] = { {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"}, {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"}, @@ -50,8 +51,9 @@ private: Controller& controller; }; -APM::APM(std::shared_ptr apm, Controller& controller, const char* name) - : ServiceFramework(name), apm(std::move(apm)), controller(controller) { +APM::APM(Core::System& system_, std::shared_ptr apm_, Controller& controller_, + const char* name) + : ServiceFramework{system_, name}, apm(std::move(apm_)), controller{controller_} { static const FunctionInfo functions[] = { {0, &APM::OpenSession, "OpenSession"}, {1, &APM::GetPerformanceMode, "GetPerformanceMode"}, @@ -67,7 +69,7 @@ void APM::OpenSession(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(controller); + rb.PushIpcInterface(system, controller); } void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) { @@ -77,7 +79,8 @@ void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) { rb.PushEnum(controller.GetCurrentPerformanceMode()); } -APM_Sys::APM_Sys(Controller& controller) : ServiceFramework{"apm:sys"}, controller(controller) { +APM_Sys::APM_Sys(Core::System& system_, Controller& controller_) + : ServiceFramework{system_, "apm:sys"}, controller{controller_} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestPerformanceMode"}, @@ -101,7 +104,7 @@ void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(controller); + rb.PushIpcInterface(system, controller); } void APM_Sys::SetCpuBoostMode(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/apm/interface.h b/src/core/hle/service/apm/interface.h index de1b89437..7d57c4978 100644 --- a/src/core/hle/service/apm/interface.h +++ b/src/core/hle/service/apm/interface.h @@ -13,7 +13,8 @@ class Module; class APM final : public ServiceFramework { public: - explicit APM(std::shared_ptr apm, Controller& controller, const char* name); + explicit APM(Core::System& system_, std::shared_ptr apm_, Controller& controller_, + const char* name); ~APM() override; private: @@ -26,7 +27,7 @@ private: class APM_Sys final : public ServiceFramework { public: - explicit APM_Sys(Controller& controller); + explicit APM_Sys(Core::System& system_, Controller& controller); ~APM_Sys() override; void SetCpuBoostMode(Kernel::HLERequestContext& ctx); -- cgit v1.2.3