From f5f5ac2197f496d5f9aa69ad47424fadc1aeb969 Mon Sep 17 00:00:00 2001 From: NarcolepticK Date: Fri, 29 Jun 2018 03:36:37 -0400 Subject: [PATCH] service/dlp: Migrate to ServiceFramework --- src/core/hle/service/dlp/dlp.cpp | 11 ++---- src/core/hle/service/dlp/dlp.h | 7 ++-- src/core/hle/service/dlp/dlp_clnt.cpp | 51 ++++++++++++++------------ src/core/hle/service/dlp/dlp_clnt.h | 9 ++--- src/core/hle/service/dlp/dlp_fkcl.cpp | 45 ++++++++++++----------- src/core/hle/service/dlp/dlp_fkcl.h | 9 ++--- src/core/hle/service/dlp/dlp_srvr.cpp | 53 ++++++++++++++------------- src/core/hle/service/dlp/dlp_srvr.h | 10 ++--- src/core/hle/service/service.cpp | 3 +- 9 files changed, 98 insertions(+), 100 deletions(-) diff --git a/src/core/hle/service/dlp/dlp.cpp b/src/core/hle/service/dlp/dlp.cpp index 8f4b67a5d..5d2f68b74 100644 --- a/src/core/hle/service/dlp/dlp.cpp +++ b/src/core/hle/service/dlp/dlp.cpp @@ -6,18 +6,15 @@ #include "core/hle/service/dlp/dlp_clnt.h" #include "core/hle/service/dlp/dlp_fkcl.h" #include "core/hle/service/dlp/dlp_srvr.h" -#include "core/hle/service/service.h" namespace Service { namespace DLP { -void Init() { - AddService(new DLP_CLNT_Interface); - AddService(new DLP_FKCL_Interface); - AddService(new DLP_SRVR_Interface); +void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared()->InstallAsService(service_manager); + std::make_shared()->InstallAsService(service_manager); + std::make_shared()->InstallAsService(service_manager); } -void Shutdown() {} - } // namespace DLP } // namespace Service diff --git a/src/core/hle/service/dlp/dlp.h b/src/core/hle/service/dlp/dlp.h index 3185fe322..d45d8c5db 100644 --- a/src/core/hle/service/dlp/dlp.h +++ b/src/core/hle/service/dlp/dlp.h @@ -4,14 +4,13 @@ #pragma once +#include "core/hle/service/service.h" + namespace Service { namespace DLP { /// Initializes the DLP services. -void Init(); - -/// Shuts down the DLP services. -void Shutdown(); +void InstallInterfaces(SM::ServiceManager& service_manager); } // namespace DLP } // namespace Service diff --git a/src/core/hle/service/dlp/dlp_clnt.cpp b/src/core/hle/service/dlp/dlp_clnt.cpp index 6f2bf2061..dbf61ab13 100644 --- a/src/core/hle/service/dlp/dlp_clnt.cpp +++ b/src/core/hle/service/dlp/dlp_clnt.cpp @@ -2,36 +2,39 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/hle/ipc_helpers.h" #include "core/hle/service/dlp/dlp_clnt.h" namespace Service { namespace DLP { -const Interface::FunctionInfo FunctionTable[] = { - {0x000100C3, nullptr, "Initialize"}, - {0x00020000, nullptr, "Finalize"}, - {0x00030000, nullptr, "GetEventDesc"}, - {0x00040000, nullptr, "GetChannel"}, - {0x00050180, nullptr, "StartScan"}, - {0x00060000, nullptr, "StopScan"}, - {0x00070080, nullptr, "GetServerInfo"}, - {0x00080100, nullptr, "GetTitleInfo"}, - {0x00090040, nullptr, "GetTitleInfoInOrder"}, - {0x000A0080, nullptr, "DeleteScanInfo"}, - {0x000B0100, nullptr, "PrepareForSystemDownload"}, - {0x000C0000, nullptr, "StartSystemDownload"}, - {0x000D0100, nullptr, "StartTitleDownload"}, - {0x000E0000, nullptr, "GetMyStatus"}, - {0x000F0040, nullptr, "GetConnectingNodes"}, - {0x00100040, nullptr, "GetNodeInfo"}, - {0x00110000, nullptr, "GetWirelessRebootPassphrase"}, - {0x00120000, nullptr, "StopSession"}, - {0x00130100, nullptr, "GetCupVersion"}, - {0x00140100, nullptr, "GetDupAvailability"}, -}; +DLP_CLNT::DLP_CLNT() : ServiceFramework("dlp:CLNT", 1) { + static const FunctionInfo functions[] = { + // clang-format off + {0x000100C3, nullptr, "Initialize"}, + {0x00020000, nullptr, "Finalize"}, + {0x00030000, nullptr, "GetEventDesc"}, + {0x00040000, nullptr, "GetChannel"}, + {0x00050180, nullptr, "StartScan"}, + {0x00060000, nullptr, "StopScan"}, + {0x00070080, nullptr, "GetServerInfo"}, + {0x00080100, nullptr, "GetTitleInfo"}, + {0x00090040, nullptr, "GetTitleInfoInOrder"}, + {0x000A0080, nullptr, "DeleteScanInfo"}, + {0x000B0100, nullptr, "PrepareForSystemDownload"}, + {0x000C0000, nullptr, "StartSystemDownload"}, + {0x000D0100, nullptr, "StartTitleDownload"}, + {0x000E0000, nullptr, "GetMyStatus"}, + {0x000F0040, nullptr, "GetConnectingNodes"}, + {0x00100040, nullptr, "GetNodeInfo"}, + {0x00110000, nullptr, "GetWirelessRebootPassphrase"}, + {0x00120000, nullptr, "StopSession"}, + {0x00130100, nullptr, "GetCupVersion"}, + {0x00140100, nullptr, "GetDupAvailability"}, + // clang-format on + }; -DLP_CLNT_Interface::DLP_CLNT_Interface() { - Register(FunctionTable); + RegisterHandlers(functions); } } // namespace DLP diff --git a/src/core/hle/service/dlp/dlp_clnt.h b/src/core/hle/service/dlp/dlp_clnt.h index 067f11e37..a1a5078e8 100644 --- a/src/core/hle/service/dlp/dlp_clnt.h +++ b/src/core/hle/service/dlp/dlp_clnt.h @@ -9,13 +9,10 @@ namespace Service { namespace DLP { -class DLP_CLNT_Interface final : public Interface { +class DLP_CLNT final : public ServiceFramework { public: - DLP_CLNT_Interface(); - - std::string GetPortName() const override { - return "dlp:CLNT"; - } + DLP_CLNT(); + ~DLP_CLNT() = default; }; } // namespace DLP diff --git a/src/core/hle/service/dlp/dlp_fkcl.cpp b/src/core/hle/service/dlp/dlp_fkcl.cpp index fe6be7d32..8003ee580 100644 --- a/src/core/hle/service/dlp/dlp_fkcl.cpp +++ b/src/core/hle/service/dlp/dlp_fkcl.cpp @@ -2,33 +2,36 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/hle/ipc_helpers.h" #include "core/hle/service/dlp/dlp_fkcl.h" namespace Service { namespace DLP { -const Interface::FunctionInfo FunctionTable[] = { - {0x00010083, nullptr, "Initialize"}, - {0x00020000, nullptr, "Finalize"}, - {0x00030000, nullptr, "GetEventDesc"}, - {0x00040000, nullptr, "GetChannels"}, - {0x00050180, nullptr, "StartScan"}, - {0x00060000, nullptr, "StopScan"}, - {0x00070080, nullptr, "GetServerInfo"}, - {0x00080100, nullptr, "GetTitleInfo"}, - {0x00090040, nullptr, "GetTitleInfoInOrder"}, - {0x000A0080, nullptr, "DeleteScanInfo"}, - {0x000B0100, nullptr, "StartFakeSession"}, - {0x000C0000, nullptr, "GetMyStatus"}, - {0x000D0040, nullptr, "GetConnectingNodes"}, - {0x000E0040, nullptr, "GetNodeInfo"}, - {0x000F0000, nullptr, "GetWirelessRebootPassphrase"}, - {0x00100000, nullptr, "StopSession"}, - {0x00110203, nullptr, "Initialize2"}, -}; +DLP_FKCL::DLP_FKCL() : ServiceFramework("dlp:FKCL", 1) { + static const FunctionInfo functions[] = { + // clang-format off + {0x00010083, nullptr, "Initialize"}, + {0x00020000, nullptr, "Finalize"}, + {0x00030000, nullptr, "GetEventDesc"}, + {0x00040000, nullptr, "GetChannels"}, + {0x00050180, nullptr, "StartScan"}, + {0x00060000, nullptr, "StopScan"}, + {0x00070080, nullptr, "GetServerInfo"}, + {0x00080100, nullptr, "GetTitleInfo"}, + {0x00090040, nullptr, "GetTitleInfoInOrder"}, + {0x000A0080, nullptr, "DeleteScanInfo"}, + {0x000B0100, nullptr, "StartFakeSession"}, + {0x000C0000, nullptr, "GetMyStatus"}, + {0x000D0040, nullptr, "GetConnectingNodes"}, + {0x000E0040, nullptr, "GetNodeInfo"}, + {0x000F0000, nullptr, "GetWirelessRebootPassphrase"}, + {0x00100000, nullptr, "StopSession"}, + {0x00110203, nullptr, "Initialize2"}, + // clang-format on + }; -DLP_FKCL_Interface::DLP_FKCL_Interface() { - Register(FunctionTable); + RegisterHandlers(functions); } } // namespace DLP diff --git a/src/core/hle/service/dlp/dlp_fkcl.h b/src/core/hle/service/dlp/dlp_fkcl.h index e4837a167..cc95f77f1 100644 --- a/src/core/hle/service/dlp/dlp_fkcl.h +++ b/src/core/hle/service/dlp/dlp_fkcl.h @@ -9,13 +9,10 @@ namespace Service { namespace DLP { -class DLP_FKCL_Interface final : public Interface { +class DLP_FKCL final : public ServiceFramework { public: - DLP_FKCL_Interface(); - - std::string GetPortName() const override { - return "dlp:FKCL"; - } + DLP_FKCL(); + ~DLP_FKCL() = default; }; } // namespace DLP diff --git a/src/core/hle/service/dlp/dlp_srvr.cpp b/src/core/hle/service/dlp/dlp_srvr.cpp index 514585df4..0d8fe13cd 100644 --- a/src/core/hle/service/dlp/dlp_srvr.cpp +++ b/src/core/hle/service/dlp/dlp_srvr.cpp @@ -4,43 +4,46 @@ #include "common/common_types.h" #include "common/logging/log.h" -#include "core/hle/ipc.h" +#include "core/hle/ipc_helpers.h" #include "core/hle/result.h" #include "core/hle/service/dlp/dlp_srvr.h" namespace Service { namespace DLP { -static void IsChild(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void DLP_SRVR::IsChild(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x0E, 0, 0); - cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = 0; + IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); + rb.Push(RESULT_SUCCESS); + rb.PushRaw(0); NGLOG_WARNING(Service_DLP, "(STUBBED) called"); } -const Interface::FunctionInfo FunctionTable[] = { - {0x00010183, nullptr, "Initialize"}, - {0x00020000, nullptr, "Finalize"}, - {0x00030000, nullptr, "GetServerState"}, - {0x00040000, nullptr, "GetEventDescription"}, - {0x00050080, nullptr, "StartAccepting"}, - {0x00060000, nullptr, "EndAccepting"}, - {0x00070000, nullptr, "StartDistribution"}, - {0x000800C0, nullptr, "SendWirelessRebootPassphrase"}, - {0x00090040, nullptr, "AcceptClient"}, - {0x000A0040, nullptr, "DisconnectClient"}, - {0x000B0042, nullptr, "GetConnectingClients"}, - {0x000C0040, nullptr, "GetClientInfo"}, - {0x000D0040, nullptr, "GetClientState"}, - {0x000E0040, IsChild, "IsChild"}, - {0x000F0303, nullptr, "InitializeWithName"}, - {0x00100000, nullptr, "GetDupNoticeNeed"}, -}; +DLP_SRVR::DLP_SRVR() : ServiceFramework("dlp:SRVR", 1) { + static const FunctionInfo functions[] = { + // clang-format off + {0x00010183, nullptr, "Initialize"}, + {0x00020000, nullptr, "Finalize"}, + {0x00030000, nullptr, "GetServerState"}, + {0x00040000, nullptr, "GetEventDescription"}, + {0x00050080, nullptr, "StartAccepting"}, + {0x00060000, nullptr, "EndAccepting"}, + {0x00070000, nullptr, "StartDistribution"}, + {0x000800C0, nullptr, "SendWirelessRebootPassphrase"}, + {0x00090040, nullptr, "AcceptClient"}, + {0x000A0040, nullptr, "DisconnectClient"}, + {0x000B0042, nullptr, "GetConnectingClients"}, + {0x000C0040, nullptr, "GetClientInfo"}, + {0x000D0040, nullptr, "GetClientState"}, + {0x000E0040, &DLP_SRVR::IsChild, "IsChild"}, + {0x000F0303, nullptr, "InitializeWithName"}, + {0x00100000, nullptr, "GetDupNoticeNeed"}, + // clang-format on + }; -DLP_SRVR_Interface::DLP_SRVR_Interface() { - Register(FunctionTable); + RegisterHandlers(functions); } } // namespace DLP diff --git a/src/core/hle/service/dlp/dlp_srvr.h b/src/core/hle/service/dlp/dlp_srvr.h index 19fe17840..ce16f42ff 100644 --- a/src/core/hle/service/dlp/dlp_srvr.h +++ b/src/core/hle/service/dlp/dlp_srvr.h @@ -9,13 +9,13 @@ namespace Service { namespace DLP { -class DLP_SRVR_Interface final : public Interface { +class DLP_SRVR final : public ServiceFramework { public: - DLP_SRVR_Interface(); + DLP_SRVR(); + ~DLP_SRVR() = default; - std::string GetPortName() const override { - return "dlp:SRVR"; - } +private: + void IsChild(Kernel::HLERequestContext& ctx); }; } // namespace DLP diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 443f32ee9..fc610773c 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -242,7 +242,7 @@ void Init(std::shared_ptr& sm) { CAM::InstallInterfaces(*sm); CECD::Init(); CFG::InstallInterfaces(*sm); - DLP::Init(); + DLP::InstallInterfaces(*sm); FRD::InstallInterfaces(*sm); GSP::InstallInterfaces(*sm); HID::InstallInterfaces(*sm); @@ -269,7 +269,6 @@ void Init(std::shared_ptr& sm) { /// Shutdown ServiceManager void Shutdown() { - DLP::Shutdown(); CECD::Shutdown(); BOSS::Shutdown(); FS::ArchiveShutdown();