From ec030a542fe4830b76e5645791ba825d50e51ddd Mon Sep 17 00:00:00 2001 From: mailwl Date: Fri, 16 Mar 2018 11:00:29 +0300 Subject: [PATCH 1/3] Service/NIFM: convert to module --- src/core/hle/service/nifm/nifm.cpp | 84 +++++++++++++++++----------- src/core/hle/service/nifm/nifm.h | 18 +++--- src/core/hle/service/nifm/nifm_a.cpp | 19 +------ src/core/hle/service/nifm/nifm_a.h | 12 +--- src/core/hle/service/nifm/nifm_s.cpp | 19 +------ src/core/hle/service/nifm/nifm_s.h | 12 +--- src/core/hle/service/nifm/nifm_u.cpp | 19 +------ src/core/hle/service/nifm/nifm_u.h | 12 +--- 8 files changed, 74 insertions(+), 121 deletions(-) diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index e6f05eae5..d4108eafd 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -96,6 +96,48 @@ public: } }; +class IGeneralService final : public ServiceFramework { +public: + IGeneralService(); + +private: + void GetClientId(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_NIFM, "(STUBBED) called"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(0); + } + void CreateScanRequest(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + + LOG_DEBUG(Service_NIFM, "called"); + } + void CreateRequest(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + + LOG_DEBUG(Service_NIFM, "called"); + } + void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_NIFM, "(STUBBED) called"); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } + void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + + LOG_DEBUG(Service_NIFM, "called"); + } +}; + IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { static const FunctionInfo functions[] = { {1, &IGeneralService::GetClientId, "GetClientId"}, @@ -137,50 +179,28 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { RegisterHandlers(functions); } -void IGeneralService::GetClientId(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_NIFM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(RESULT_SUCCESS); - rb.Push(0); -} - -void IGeneralService::CreateScanRequest(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - + rb.PushIpcInterface(); LOG_DEBUG(Service_NIFM, "called"); } -void IGeneralService::CreateRequest(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateGeneralService(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - + rb.PushIpcInterface(); LOG_DEBUG(Service_NIFM, "called"); } -void IGeneralService::RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_NIFM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(RESULT_SUCCESS); -} - -void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - - LOG_DEBUG(Service_NIFM, "called"); -} +Module::Interface::Interface(std::shared_ptr module, const char* name) + : ServiceFramework(name), module(std::move(module)) {} void InstallInterfaces(SM::ServiceManager& service_manager) { - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); + auto module = std::make_shared(); + std::make_shared(module)->InstallAsService(service_manager); + std::make_shared(module)->InstallAsService(service_manager); + std::make_shared(module)->InstallAsService(service_manager); } } // namespace NIFM diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h index 6edbfe4a4..11d263b12 100644 --- a/src/core/hle/service/nifm/nifm.h +++ b/src/core/hle/service/nifm/nifm.h @@ -9,16 +9,18 @@ namespace Service { namespace NIFM { -class IGeneralService final : public ServiceFramework { +class Module final { public: - IGeneralService(); + class Interface : public ServiceFramework { + public: + Interface(std::shared_ptr module, const char* name); -private: - void GetClientId(Kernel::HLERequestContext& ctx); - void CreateScanRequest(Kernel::HLERequestContext& ctx); - void CreateRequest(Kernel::HLERequestContext& ctx); - void RemoveNetworkProfile(Kernel::HLERequestContext& ctx); - void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx); + void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx); + void CreateGeneralService(Kernel::HLERequestContext& ctx); + + protected: + std::shared_ptr module; + }; }; void InstallInterfaces(SM::ServiceManager& service_manager); diff --git a/src/core/hle/service/nifm/nifm_a.cpp b/src/core/hle/service/nifm/nifm_a.cpp index ee61d8ff4..f75df8c04 100644 --- a/src/core/hle/service/nifm/nifm_a.cpp +++ b/src/core/hle/service/nifm/nifm_a.cpp @@ -2,29 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/service/nifm/nifm.h" #include "core/hle/service/nifm/nifm_a.h" namespace Service { namespace NIFM { -void NIFM_A::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} - -void NIFM_A::CreateGeneralService(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} - -NIFM_A::NIFM_A() : ServiceFramework("nifm:a") { +NIFM_A::NIFM_A(std::shared_ptr module) : Module::Interface(std::move(module), "nifm:a") { static const FunctionInfo functions[] = { {4, &NIFM_A::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, {5, &NIFM_A::CreateGeneralService, "CreateGeneralService"}, diff --git a/src/core/hle/service/nifm/nifm_a.h b/src/core/hle/service/nifm/nifm_a.h index 06a92a93c..eaea14e29 100644 --- a/src/core/hle/service/nifm/nifm_a.h +++ b/src/core/hle/service/nifm/nifm_a.h @@ -4,20 +4,14 @@ #pragma once -#include "core/hle/kernel/hle_ipc.h" -#include "core/hle/service/service.h" +#include "core/hle/service/nifm/nifm.h" namespace Service { namespace NIFM { -class NIFM_A final : public ServiceFramework { +class NIFM_A final : public Module::Interface { public: - NIFM_A(); - ~NIFM_A() = default; - -private: - void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx); - void CreateGeneralService(Kernel::HLERequestContext& ctx); + explicit NIFM_A(std::shared_ptr module); }; } // namespace NIFM diff --git a/src/core/hle/service/nifm/nifm_s.cpp b/src/core/hle/service/nifm/nifm_s.cpp index c38b2a4c7..9c0b300e4 100644 --- a/src/core/hle/service/nifm/nifm_s.cpp +++ b/src/core/hle/service/nifm/nifm_s.cpp @@ -2,29 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/service/nifm/nifm.h" #include "core/hle/service/nifm/nifm_s.h" namespace Service { namespace NIFM { -void NIFM_S::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} - -void NIFM_S::CreateGeneralService(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} - -NIFM_S::NIFM_S() : ServiceFramework("nifm:s") { +NIFM_S::NIFM_S(std::shared_ptr module) : Module::Interface(std::move(module), "nifm:s") { static const FunctionInfo functions[] = { {4, &NIFM_S::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, {5, &NIFM_S::CreateGeneralService, "CreateGeneralService"}, diff --git a/src/core/hle/service/nifm/nifm_s.h b/src/core/hle/service/nifm/nifm_s.h index d11a1ec29..f9e2d8039 100644 --- a/src/core/hle/service/nifm/nifm_s.h +++ b/src/core/hle/service/nifm/nifm_s.h @@ -4,20 +4,14 @@ #pragma once -#include "core/hle/kernel/hle_ipc.h" -#include "core/hle/service/service.h" +#include "core/hle/service/nifm/nifm.h" namespace Service { namespace NIFM { -class NIFM_S final : public ServiceFramework { +class NIFM_S final : public Module::Interface { public: - NIFM_S(); - ~NIFM_S() = default; - -private: - void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx); - void CreateGeneralService(Kernel::HLERequestContext& ctx); + explicit NIFM_S(std::shared_ptr module); }; } // namespace NIFM diff --git a/src/core/hle/service/nifm/nifm_u.cpp b/src/core/hle/service/nifm/nifm_u.cpp index a5895c13c..44e6f483d 100644 --- a/src/core/hle/service/nifm/nifm_u.cpp +++ b/src/core/hle/service/nifm/nifm_u.cpp @@ -2,29 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/service/nifm/nifm.h" #include "core/hle/service/nifm/nifm_u.h" namespace Service { namespace NIFM { -void NIFM_U::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} - -void NIFM_U::CreateGeneralService(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} - -NIFM_U::NIFM_U() : ServiceFramework("nifm:u") { +NIFM_U::NIFM_U(std::shared_ptr module) : Module::Interface(std::move(module), "nifm:u") { static const FunctionInfo functions[] = { {4, &NIFM_U::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, {5, &NIFM_U::CreateGeneralService, "CreateGeneralService"}, diff --git a/src/core/hle/service/nifm/nifm_u.h b/src/core/hle/service/nifm/nifm_u.h index da40b604f..912006775 100644 --- a/src/core/hle/service/nifm/nifm_u.h +++ b/src/core/hle/service/nifm/nifm_u.h @@ -4,20 +4,14 @@ #pragma once -#include "core/hle/kernel/hle_ipc.h" -#include "core/hle/service/service.h" +#include "core/hle/service/nifm/nifm.h" namespace Service { namespace NIFM { -class NIFM_U final : public ServiceFramework { +class NIFM_U final : public Module::Interface { public: - NIFM_U(); - ~NIFM_U() = default; - -private: - void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx); - void CreateGeneralService(Kernel::HLERequestContext& ctx); + explicit NIFM_U(std::shared_ptr module); }; } // namespace NIFM From 9289255314a0795654dc4c97b9e34e0a624bfb01 Mon Sep 17 00:00:00 2001 From: mailwl Date: Fri, 16 Mar 2018 11:08:22 +0300 Subject: [PATCH 2/3] Service/NIFM: stub cancel function --- src/core/hle/service/nifm/nifm.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index d4108eafd..876d0f614 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -32,7 +32,7 @@ public: {0, &IRequest::GetRequestState, "GetRequestState"}, {1, &IRequest::GetResult, "GetResult"}, {2, &IRequest::GetSystemEventReadableHandles, "GetSystemEventReadableHandles"}, - {3, nullptr, "Cancel"}, + {3, &IRequest::Cancel, "Cancel"}, {4, nullptr, "Submit"}, {5, nullptr, "SetRequirement"}, {6, nullptr, "SetRequirementPreset"}, @@ -80,6 +80,11 @@ private: rb.Push(RESULT_SUCCESS); rb.PushCopyObjects(event1, event2); } + void Cancel(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_NIFM, "(STUBBED) called"); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } Kernel::SharedPtr event1, event2; }; From fbfa7ddd624cd032695b84881647045f371b9475 Mon Sep 17 00:00:00 2001 From: mailwl Date: Fri, 16 Mar 2018 16:34:12 +0300 Subject: [PATCH 3/3] IGeneralService: fix function list --- src/core/hle/service/nifm/nifm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 876d0f614..dd2d5fe63 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -148,8 +148,9 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { {1, &IGeneralService::GetClientId, "GetClientId"}, {2, &IGeneralService::CreateScanRequest, "CreateScanRequest"}, {4, &IGeneralService::CreateRequest, "CreateRequest"}, - {6, nullptr, "GetCurrentNetworkProfile"}, - {7, nullptr, "EnumerateNetworkInterfaces"}, + {5, nullptr, "GetCurrentNetworkProfile"}, + {6, nullptr, "EnumerateNetworkInterfaces"}, + {7, nullptr, "EnumerateNetworkProfiles"}, {8, nullptr, "GetNetworkProfile"}, {9, nullptr, "SetNetworkProfile"}, {10, &IGeneralService::RemoveNetworkProfile, "RemoveNetworkProfile"},