From ad53dc010688bb1059dfb933f202c159c81331cb Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sat, 21 Sep 2019 19:07:13 +1000 Subject: Deglobalize System: Nifm --- src/core/hle/service/nifm/nifm.cpp | 30 ++++++++++++++++++------------ src/core/hle/service/nifm/nifm.h | 6 +++++- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 76b12b482..24d1813a7 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -31,7 +31,7 @@ public: class IRequest final : public ServiceFramework { public: - explicit IRequest() : ServiceFramework("IRequest") { + explicit IRequest(Core::System& system) : ServiceFramework("IRequest") { static const FunctionInfo functions[] = { {0, &IRequest::GetRequestState, "GetRequestState"}, {1, &IRequest::GetResult, "GetResult"}, @@ -61,7 +61,7 @@ public: }; RegisterHandlers(functions); - auto& kernel = Core::System::GetInstance().Kernel(); + auto& kernel = system.Kernel(); event1 = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, "IRequest:Event1"); event2 = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, @@ -130,7 +130,7 @@ public: class IGeneralService final : public ServiceFramework { public: - IGeneralService(); + IGeneralService(Core::System& system); private: void GetClientId(Kernel::HLERequestContext& ctx) { @@ -155,7 +155,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); @@ -198,9 +198,11 @@ private: rb.Push(RESULT_SUCCESS); rb.Push(0); } + Core::System& system; }; -IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { +IGeneralService::IGeneralService(Core::System& system) + : ServiceFramework("IGeneralService"), system(system) { static const FunctionInfo functions[] = { {1, &IGeneralService::GetClientId, "GetClientId"}, {2, &IGeneralService::CreateScanRequest, "CreateScanRequest"}, @@ -245,7 +247,8 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { class NetworkInterface final : public ServiceFramework { public: - explicit NetworkInterface(const char* name) : ServiceFramework{name} { + explicit NetworkInterface(const char* name, Core::System& system) + : ServiceFramework{name}, system(system) { static const FunctionInfo functions[] = { {4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, {5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"}, @@ -258,7 +261,7 @@ public: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } void CreateGeneralService(Kernel::HLERequestContext& ctx) { @@ -266,14 +269,17 @@ public: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } + +private: + Core::System& system; }; -void InstallInterfaces(SM::ServiceManager& service_manager) { - std::make_shared("nifm:a")->InstallAsService(service_manager); - std::make_shared("nifm:s")->InstallAsService(service_manager); - std::make_shared("nifm:u")->InstallAsService(service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { + std::make_shared("nifm:a", system)->InstallAsService(service_manager); + std::make_shared("nifm:s", system)->InstallAsService(service_manager); + std::make_shared("nifm:u", system)->InstallAsService(service_manager); } } // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h index 4616b3b48..6857e18f9 100644 --- a/src/core/hle/service/nifm/nifm.h +++ b/src/core/hle/service/nifm/nifm.h @@ -8,9 +8,13 @@ namespace Service::SM { class ServiceManager; } +namespace Core { +class System; +} + namespace Service::NIFM { /// Registers all NIFM services with the specified service manager. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); } // namespace Service::NIFM -- cgit v1.2.3