From a77f91ee482b7928ad3d516fe19f259e34ee88ac Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 26 Sep 2026 10:59:22 +0000 Subject: [PATCH] 2026-09-26 10:59:22 Signed-off-by: lizzie --- src/core/hle/service/acc/acc.cpp | 38 ++- src/core/hle/service/apm/apm_interface.cpp | 18 +- src/core/hle/service/gpio/gpio.cpp | 16 +- src/core/hle/service/i2c/i2c.cpp | 54 +++-- src/core/hle/service/lm/lm.cpp | 20 +- src/core/hle/service/ncm/ncm.cpp | 12 +- src/core/hle/service/nfc/nfc.cpp | 153 ++++++------ src/core/hle/service/nfp/nfp.cpp | 225 +++++++++--------- src/core/hle/service/nifm/nifm.cpp | 116 ++++----- src/core/hle/service/nim/nim.cpp | 26 +- ...nly_application_control_data_interface.cpp | 17 +- src/core/hle/service/nvdrv/nvdrv.cpp | 74 +++--- src/core/hle/service/pm/pm.cpp | 42 ++-- src/core/hle/service/service.h | 55 +---- src/core/hle/service/sm/sm.cpp | 84 ++++--- src/core/hle/service/sm/sm.h | 24 +- src/core/hle/service/spl/spl_module.cpp | 15 +- src/core/hle/service/ssl/ssl.cpp | 42 ++-- src/core/hle/service/tma/tma.cpp | 12 +- 19 files changed, 515 insertions(+), 528 deletions(-) diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 62d54f04bf..8fffcdbba4 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -343,28 +343,8 @@ public: class IProfileCommon : public ServiceFramework { public: - explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands, - Common::UUID user_id_, ProfileManager& profile_manager_) + explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands, Common::UUID user_id_, ProfileManager& profile_manager_) : ServiceFramework{system_, name}, profile_manager{profile_manager_}, user_id{user_id_} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &IProfileCommon::Get, "Get"}, - FunctionInfo{1, &IProfileCommon::GetBase, "GetBase"}, - FunctionInfo{10, &IProfileCommon::GetImageSize, "GetImageSize"}, - FunctionInfo{11, &IProfileCommon::LoadImage, "LoadImage"}, - FunctionInfo{20, &IProfileCommon::Unknown20, "Unknown20"}, - FunctionInfo{21, &IProfileCommon::Unknown21, "Unknown21"}, - FunctionInfo{30, &IProfileCommon::Unknown30, "Unknown30"} - }; - RegisterHandlers(functions); - - if (editor_commands) { - static const FunctionInfo editor_functions[] = { - FunctionInfo{100, &IProfileCommon::Store, "Store"}, - FunctionInfo{101, &IProfileCommon::StoreWithImage, "StoreWithImage"}, - FunctionInfo{110, &IProfileCommon::Unknown110, "Unknown110"} - }; - RegisterHandlers(editor_functions); - } } protected: @@ -591,6 +571,22 @@ protected: rb.Push(ResultSuccess); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &IProfileCommon::Get, "Get"}, + FunctionInfo{1, &IProfileCommon::GetBase, "GetBase"}, + FunctionInfo{10, &IProfileCommon::GetImageSize, "GetImageSize"}, + FunctionInfo{11, &IProfileCommon::LoadImage, "LoadImage"}, + FunctionInfo{20, &IProfileCommon::Unknown20, "Unknown20"}, + FunctionInfo{21, &IProfileCommon::Unknown21, "Unknown21"}, + FunctionInfo{30, &IProfileCommon::Unknown30, "Unknown30"}, + // Editor commands + FunctionInfo{100, &IProfileCommon::Store, "Store"}, + FunctionInfo{101, &IProfileCommon::StoreWithImage, "StoreWithImage"}, + FunctionInfo{110, &IProfileCommon::Unknown110, "Unknown110"} + ); ProfileManager& profile_manager; Common::UUID user_id{}; ///< The user id this profile refers to. }; diff --git a/src/core/hle/service/apm/apm_interface.cpp b/src/core/hle/service/apm/apm_interface.cpp index 5371d5647d..11427fe836 100644 --- a/src/core/hle/service/apm/apm_interface.cpp +++ b/src/core/hle/service/apm/apm_interface.cpp @@ -14,15 +14,7 @@ namespace Service::APM { class ISession final : public ServiceFramework { public: - explicit ISession(Core::System& system_, Controller& controller_) - : ServiceFramework{system_, "ISession"}, controller{controller_} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"}, - FunctionInfo{1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"}, - FunctionInfo{2, &ISession::SetCpuOverclockEnabled, "SetCpuOverclockEnabled"} - }; - RegisterHandlers(functions); - } + explicit ISession(Core::System& system_, Controller& controller_) : ServiceFramework{system_, "ISession"}, controller{controller_} {} private: void SetPerformanceConfiguration(HLERequestContext& ctx) { @@ -61,6 +53,14 @@ private: rb.Push(ResultSuccess); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"}, + FunctionInfo{1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"}, + FunctionInfo{2, &ISession::SetCpuOverclockEnabled, "SetCpuOverclockEnabled"} + ); Controller& controller; }; diff --git a/src/core/hle/service/gpio/gpio.cpp b/src/core/hle/service/gpio/gpio.cpp index ab7ebea4e2..976630b274 100644 --- a/src/core/hle/service/gpio/gpio.cpp +++ b/src/core/hle/service/gpio/gpio.cpp @@ -13,15 +13,15 @@ namespace Service::GPIO { class GPIO final : public ServiceFramework { public: - explicit GPIO(Core::System& system_) - : ServiceFramework{system_, "gpio"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "Cmd0"} - }; - RegisterHandlers(functions); - } + explicit GPIO(Core::System& system_) : ServiceFramework{system_, "gpio"} {} ~GPIO() override = default; + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Cmd0"} + ); }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/i2c/i2c.cpp b/src/core/hle/service/i2c/i2c.cpp index e405f9a65e..3ee8023ef4 100644 --- a/src/core/hle/service/i2c/i2c.cpp +++ b/src/core/hle/service/i2c/i2c.cpp @@ -17,25 +17,26 @@ namespace Service::I2C { class I2CSession final : public ServiceFramework { public: - explicit I2CSession(Core::System& system_) - : ServiceFramework{system_, "I2CSession"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "SendOld"}, - FunctionInfo{1, nullptr, "ReceiveOld"}, - FunctionInfo{2, nullptr, "ExecuteCommandListOld"}, - FunctionInfo{10, C<&I2CSession::Send>, "Send"}, - FunctionInfo{11, nullptr, "Receive"}, - FunctionInfo{12, nullptr, "ExecuteCommandList"}, - FunctionInfo{13, nullptr, "SetRetryPolicy"} - }; - RegisterHandlers(functions); - } + explicit I2CSession(Core::System& system_) : ServiceFramework{system_, "I2CSession"} {} ~I2CSession() override = default; + Result Send(InBuffer in_data, u32 transaction_option) { LOG_WARNING(Service, "(stubbed) topt={}", transaction_option); R_THROW(ResultUnknown); } + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "SendOld"}, + FunctionInfo{1, nullptr, "ReceiveOld"}, + FunctionInfo{2, nullptr, "ExecuteCommandListOld"}, + FunctionInfo{10, C<&I2CSession::Send>, "Send"}, + FunctionInfo{11, nullptr, "Receive"}, + FunctionInfo{12, nullptr, "ExecuteCommandList"}, + FunctionInfo{13, nullptr, "SetRetryPolicy"} + ); }; enum class I2CDevice : u32 { @@ -45,19 +46,9 @@ enum class I2CDevice : u32 { class I2C final : public ServiceFramework { public: - explicit I2C(Core::System& system_) - : ServiceFramework{system_, "i2c"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, C<&I2C::OpenSessionForDev>, "OpenSessionForDev"}, - FunctionInfo{1, C<&I2C::OpenSession>, "OpenSession"}, - FunctionInfo{2, C<&I2C::HasDevice>, "HasDevice"}, - FunctionInfo{3, C<&I2C::HasDeviceForDev>, "HasDeviceForDev"}, - FunctionInfo{4, C<&I2C::OpenSession2>, "OpenSession2"} - }; - RegisterHandlers(functions); - } + explicit I2C(Core::System& system_) : ServiceFramework{system_, "i2c"} {} ~I2C() override = default; + Result OpenSessionForDev(OutInterface out_session, s32 bus_idx, u32 slave_address, u32 addressing_mode, u32 speed_mode) { LOG_DEBUG(Service, "(stubbed)"); *out_session = std::make_shared(system); @@ -83,6 +74,17 @@ public: *out_session = std::make_shared(system); R_SUCCEED(); } + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, C<&I2C::OpenSessionForDev>, "OpenSessionForDev"}, + FunctionInfo{1, C<&I2C::OpenSession>, "OpenSession"}, + FunctionInfo{2, C<&I2C::HasDevice>, "HasDevice"}, + FunctionInfo{3, C<&I2C::HasDeviceForDev>, "HasDeviceForDev"}, + FunctionInfo{4, C<&I2C::OpenSession2>, "OpenSession2"} + ); }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index d6f51ed308..49bfe819f2 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -87,16 +87,7 @@ DECLARE_ENUM_FLAG_OPERATORS(LogPacketFlags); class ILogger final : public ServiceFramework { public: - explicit ILogger(Core::System& system_) : ServiceFramework{system_, "ILogger"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &ILogger::Log, "Log"}, - FunctionInfo{1, &ILogger::SetDestination, "SetDestination"}, - FunctionInfo{2, nullptr, "TransmitHashedLog"}, //20.0.0+ - FunctionInfo{3, nullptr, "DevNotify"}, //20.0.0+ - }; - RegisterHandlers(functions); - } - + explicit ILogger(Core::System& system_) : ServiceFramework{system_, "ILogger"} {} private: void Log(HLERequestContext& ctx) { std::size_t offset{}; @@ -331,6 +322,15 @@ private: }; static_assert(sizeof(LogPacketHeader) == 0x18, "LogPacketHeader is an invalid size"); + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &ILogger::Log, "Log"}, + FunctionInfo{1, &ILogger::SetDestination, "SetDestination"}, + FunctionInfo{2, nullptr, "TransmitHashedLog"}, //20.0.0+ + FunctionInfo{3, nullptr, "DevNotify"} //20.0.0+ + ); ::Common::unordered_map> entries{}; LogDestination destination{LogDestination::All}; }; diff --git a/src/core/hle/service/ncm/ncm.cpp b/src/core/hle/service/ncm/ncm.cpp index 2ad7738b16..5748ab5a5d 100644 --- a/src/core/hle/service/ncm/ncm.cpp +++ b/src/core/hle/service/ncm/ncm.cpp @@ -425,12 +425,14 @@ class NCM_V final : public ServiceFramework { public: explicit NCM_V(Core::System& system_) : ServiceFramework{system_, "ncm:v"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "GetSystemVersion"} - }; - RegisterHandlers(functions); + {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "GetSystemVersion"} + ); }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index 74885cfa1d..1071304d21 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -18,68 +18,71 @@ namespace Service::NFC { class IUser final : public NfcInterface { public: - explicit IUser(Core::System& system_) : NfcInterface(system_, "NFC::IUser", BackendType::Nfc) { - static const FunctionInfoTyped functions[] = { - FunctionInfoTyped{0, &NfcInterface::Initialize, "InitializeOld"}, - FunctionInfoTyped{1, &NfcInterface::Finalize, "FinalizeOld"}, - FunctionInfoTyped{2, &NfcInterface::GetState, "GetStateOld"}, - FunctionInfoTyped{3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, - FunctionInfoTyped{400, &NfcInterface::Initialize, "Initialize"}, - FunctionInfoTyped{401, &NfcInterface::Finalize, "Finalize"}, - FunctionInfoTyped{402, &NfcInterface::GetState, "GetState"}, - FunctionInfoTyped{403, &NfcInterface::IsNfcEnabled, "IsNfcEnabled"}, - FunctionInfoTyped{404, &NfcInterface::ListDevices, "ListDevices"}, - FunctionInfoTyped{405, &NfcInterface::GetDeviceState, "GetDeviceState"}, - FunctionInfoTyped{406, &NfcInterface::GetNpadId, "GetNpadId"}, - FunctionInfoTyped{407, &NfcInterface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, - FunctionInfoTyped{408, &NfcInterface::StartDetection, "StartDetection"}, - FunctionInfoTyped{409, &NfcInterface::StopDetection, "StopDetection"}, - FunctionInfoTyped{410, &NfcInterface::GetTagInfo, "GetTagInfo"}, - FunctionInfoTyped{411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, - FunctionInfoTyped{412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, - FunctionInfoTyped{1000, &NfcInterface::ReadMifare, "ReadMifare"}, - FunctionInfoTyped{1001, &NfcInterface::WriteMifare ,"WriteMifare"}, - FunctionInfoTyped{1300, &NfcInterface::SendCommandByPassThrough, "SendCommandByPassThrough"}, - FunctionInfoTyped{1301, nullptr, "KeepPassThroughSession"}, - FunctionInfoTyped{1302, nullptr, "ReleasePassThroughSession"} - }; - RegisterHandlers(functions); + explicit IUser(Core::System& system_) : NfcInterface(system_, "NFC::IUser", BackendType::Nfc) {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMapWithClass( + FunctionInfoTyped{0, &NfcInterface::Initialize, "InitializeOld"}, + FunctionInfoTyped{1, &NfcInterface::Finalize, "FinalizeOld"}, + FunctionInfoTyped{2, &NfcInterface::GetState, "GetStateOld"}, + FunctionInfoTyped{3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, + FunctionInfoTyped{400, &NfcInterface::Initialize, "Initialize"}, + FunctionInfoTyped{401, &NfcInterface::Finalize, "Finalize"}, + FunctionInfoTyped{402, &NfcInterface::GetState, "GetState"}, + FunctionInfoTyped{403, &NfcInterface::IsNfcEnabled, "IsNfcEnabled"}, + FunctionInfoTyped{404, &NfcInterface::ListDevices, "ListDevices"}, + FunctionInfoTyped{405, &NfcInterface::GetDeviceState, "GetDeviceState"}, + FunctionInfoTyped{406, &NfcInterface::GetNpadId, "GetNpadId"}, + FunctionInfoTyped{407, &NfcInterface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, + FunctionInfoTyped{408, &NfcInterface::StartDetection, "StartDetection"}, + FunctionInfoTyped{409, &NfcInterface::StopDetection, "StopDetection"}, + FunctionInfoTyped{410, &NfcInterface::GetTagInfo, "GetTagInfo"}, + FunctionInfoTyped{411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, + FunctionInfoTyped{412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, + FunctionInfoTyped{1000, &NfcInterface::ReadMifare, "ReadMifare"}, + FunctionInfoTyped{1001, &NfcInterface::WriteMifare ,"WriteMifare"}, + FunctionInfoTyped{1300, &NfcInterface::SendCommandByPassThrough, "SendCommandByPassThrough"}, + FunctionInfoTyped{1301, nullptr, "KeepPassThroughSession"}, + FunctionInfoTyped{1302, nullptr, "ReleasePassThroughSession"} + ); }; class ISystem final : public NfcInterface { public: - explicit ISystem(Core::System& system_) - : NfcInterface{system_, "NFC::ISystem", BackendType::Nfc} { - static const FunctionInfoTyped functions[] = { - FunctionInfoTyped{0, &NfcInterface::Initialize, "InitializeOld"}, - FunctionInfoTyped{1, &NfcInterface::Finalize, "FinalizeOld"}, - FunctionInfoTyped{2, &NfcInterface::GetState, "GetStateOld"}, - FunctionInfoTyped{3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, - FunctionInfoTyped{100, &NfcInterface::SetNfcEnabled, "SetNfcEnabledOld"}, - FunctionInfoTyped{400, &NfcInterface::Initialize, "Initialize"}, - FunctionInfoTyped{401, &NfcInterface::Finalize, "Finalize"}, - FunctionInfoTyped{402, &NfcInterface::GetState, "GetState"}, - FunctionInfoTyped{403, &NfcInterface::IsNfcEnabled, "IsNfcEnabled"}, - FunctionInfoTyped{404, &NfcInterface::ListDevices, "ListDevices"}, - FunctionInfoTyped{405, &NfcInterface::GetDeviceState, "GetDeviceState"}, - FunctionInfoTyped{406, &NfcInterface::GetNpadId, "GetNpadId"}, - FunctionInfoTyped{407, &NfcInterface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, - FunctionInfoTyped{408, &NfcInterface::StartDetection, "StartDetection"}, - FunctionInfoTyped{409, &NfcInterface::StopDetection, "StopDetection"}, - FunctionInfoTyped{410, &NfcInterface::GetTagInfo, "GetTagInfo"}, - FunctionInfoTyped{411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, - FunctionInfoTyped{412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, - FunctionInfoTyped{500, &NfcInterface::SetNfcEnabled, "SetNfcEnabled"}, - FunctionInfoTyped{510, nullptr, "OutputTestWave"}, - FunctionInfoTyped{1000, &NfcInterface::ReadMifare, "ReadMifare"}, - FunctionInfoTyped{1001, &NfcInterface::WriteMifare, "WriteMifare"}, - FunctionInfoTyped{1300, &NfcInterface::SendCommandByPassThrough, "SendCommandByPassThrough"}, - FunctionInfoTyped{1301, nullptr, "KeepPassThroughSession"}, - FunctionInfoTyped{1302, nullptr, "ReleasePassThroughSession"} - }; - RegisterHandlers(functions); + explicit ISystem(Core::System& system_) : NfcInterface{system_, "NFC::ISystem", BackendType::Nfc} {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMapWithClass( + FunctionInfoTyped{0, &NfcInterface::Initialize, "InitializeOld"}, + FunctionInfoTyped{1, &NfcInterface::Finalize, "FinalizeOld"}, + FunctionInfoTyped{2, &NfcInterface::GetState, "GetStateOld"}, + FunctionInfoTyped{3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, + FunctionInfoTyped{100, &NfcInterface::SetNfcEnabled, "SetNfcEnabledOld"}, + FunctionInfoTyped{400, &NfcInterface::Initialize, "Initialize"}, + FunctionInfoTyped{401, &NfcInterface::Finalize, "Finalize"}, + FunctionInfoTyped{402, &NfcInterface::GetState, "GetState"}, + FunctionInfoTyped{403, &NfcInterface::IsNfcEnabled, "IsNfcEnabled"}, + FunctionInfoTyped{404, &NfcInterface::ListDevices, "ListDevices"}, + FunctionInfoTyped{405, &NfcInterface::GetDeviceState, "GetDeviceState"}, + FunctionInfoTyped{406, &NfcInterface::GetNpadId, "GetNpadId"}, + FunctionInfoTyped{407, &NfcInterface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, + FunctionInfoTyped{408, &NfcInterface::StartDetection, "StartDetection"}, + FunctionInfoTyped{409, &NfcInterface::StopDetection, "StopDetection"}, + FunctionInfoTyped{410, &NfcInterface::GetTagInfo, "GetTagInfo"}, + FunctionInfoTyped{411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, + FunctionInfoTyped{412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, + FunctionInfoTyped{500, &NfcInterface::SetNfcEnabled, "SetNfcEnabled"}, + FunctionInfoTyped{510, nullptr, "OutputTestWave"}, + FunctionInfoTyped{1000, &NfcInterface::ReadMifare, "ReadMifare"}, + FunctionInfoTyped{1001, &NfcInterface::WriteMifare, "WriteMifare"}, + FunctionInfoTyped{1300, &NfcInterface::SendCommandByPassThrough, "SendCommandByPassThrough"}, + FunctionInfoTyped{1301, nullptr, "KeepPassThroughSession"}, + FunctionInfoTyped{1302, nullptr, "ReleasePassThroughSession"} + ); }; // MFInterface has an unique interface but it's identical to NfcInterface so we can keep the code @@ -87,25 +90,27 @@ public: using MFInterface = NfcInterface; class MFIUser final : public MFInterface { public: - explicit MFIUser(Core::System& system_) : MFInterface{system_, "NFC::MFInterface", BackendType::Mifare} { - static const FunctionInfoTyped functions[] = { - FunctionInfoTyped{0, &MFIUser::Initialize, "Initialize"}, - FunctionInfoTyped{1, &MFIUser::Finalize, "Finalize"}, - FunctionInfoTyped{2, &MFIUser::ListDevices, "ListDevices"}, - FunctionInfoTyped{3, &MFIUser::StartDetection, "StartDetection"}, - FunctionInfoTyped{4, &MFIUser::StopDetection, "StopDetection"}, - FunctionInfoTyped{5, &MFIUser::ReadMifare, "Read"}, - FunctionInfoTyped{6, &MFIUser::WriteMifare, "Write"}, - FunctionInfoTyped{7, &MFIUser::GetTagInfo, "GetTagInfo"}, - FunctionInfoTyped{8, &MFIUser::AttachActivateEvent, "GetActivateEventHandle"}, - FunctionInfoTyped{9, &MFIUser::AttachDeactivateEvent, "GetDeactivateEventHandle"}, - FunctionInfoTyped{10, &MFIUser::GetState, "GetState"}, - FunctionInfoTyped{11, &MFIUser::GetDeviceState, "GetDeviceState"}, - FunctionInfoTyped{12, &MFIUser::GetNpadId, "GetNpadId"}, - FunctionInfoTyped{13, &MFIUser::AttachAvailabilityChangeEvent, "GetAvailabilityChangeEventHandle"} - }; - RegisterHandlers(functions); + explicit MFIUser(Core::System& system_) : MFInterface{system_, "NFC::MFInterface", BackendType::Mifare} {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMapWithClass( + FunctionInfoTyped{0, &MFIUser::Initialize, "Initialize"}, + FunctionInfoTyped{1, &MFIUser::Finalize, "Finalize"}, + FunctionInfoTyped{2, &MFIUser::ListDevices, "ListDevices"}, + FunctionInfoTyped{3, &MFIUser::StartDetection, "StartDetection"}, + FunctionInfoTyped{4, &MFIUser::StopDetection, "StopDetection"}, + FunctionInfoTyped{5, &MFIUser::ReadMifare, "Read"}, + FunctionInfoTyped{6, &MFIUser::WriteMifare, "Write"}, + FunctionInfoTyped{7, &MFIUser::GetTagInfo, "GetTagInfo"}, + FunctionInfoTyped{8, &MFIUser::AttachActivateEvent, "GetActivateEventHandle"}, + FunctionInfoTyped{9, &MFIUser::AttachDeactivateEvent, "GetDeactivateEventHandle"}, + FunctionInfoTyped{10, &MFIUser::GetState, "GetState"}, + FunctionInfoTyped{11, &MFIUser::GetDeviceState, "GetDeviceState"}, + FunctionInfoTyped{12, &MFIUser::GetNpadId, "GetNpadId"}, + FunctionInfoTyped{13, &MFIUser::AttachAvailabilityChangeEvent, "GetAvailabilityChangeEventHandle"} + ); }; class IAm final : public ServiceFramework { diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 871b477125..41c7a3b097 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -14,133 +14,135 @@ namespace Service::NFP { class IUser final : public Interface { public: - explicit IUser(Core::System& system_) : Interface(system_, "NFP:IUser") { - static const FunctionInfoTyped functions[] = { - FunctionInfoTyped{0, &IUser::Initialize, "Initialize"}, - FunctionInfoTyped{1, &IUser::Finalize, "Finalize"}, - FunctionInfoTyped{2, &IUser::ListDevices, "ListDevices"}, - FunctionInfoTyped{3, &IUser::StartDetection, "StartDetection"}, - FunctionInfoTyped{4, &IUser::StopDetection, "StopDetection"}, - FunctionInfoTyped{5, &IUser::Mount, "Mount"}, - FunctionInfoTyped{6, &IUser::Unmount, "Unmount"}, - FunctionInfoTyped{7, &IUser::OpenApplicationArea, "OpenApplicationArea"}, - FunctionInfoTyped{8, &IUser::GetApplicationArea, "GetApplicationArea"}, - FunctionInfoTyped{9, &IUser::SetApplicationArea, "SetApplicationArea"}, - FunctionInfoTyped{10, &IUser::Flush, "Flush"}, - FunctionInfoTyped{11, &IUser::Restore, "Restore"}, - FunctionInfoTyped{12, &IUser::CreateApplicationArea, "CreateApplicationArea"}, - FunctionInfoTyped{13, &IUser::GetTagInfo, "GetTagInfo"}, - FunctionInfoTyped{14, &IUser::GetRegisterInfo, "GetRegisterInfo"}, - FunctionInfoTyped{15, &IUser::GetCommonInfo, "GetCommonInfo"}, - FunctionInfoTyped{16, &IUser::GetModelInfo, "GetModelInfo"}, - FunctionInfoTyped{17, &IUser::AttachActivateEvent, "AttachActivateEvent"}, - FunctionInfoTyped{18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"}, - FunctionInfoTyped{19, &IUser::GetState, "GetState"}, - FunctionInfoTyped{20, &IUser::GetDeviceState, "GetDeviceState"}, - FunctionInfoTyped{21, &IUser::GetNpadId, "GetNpadId"}, - FunctionInfoTyped{22, &IUser::GetApplicationAreaSize, "GetApplicationAreaSize"}, - FunctionInfoTyped{23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, - FunctionInfoTyped{24, &IUser::RecreateApplicationArea, "RecreateApplicationArea"}, - FunctionInfoTyped{25, &IUser::StartDetection, "StartDetectionWithFilter"} - }; - RegisterHandlers(functions); + explicit IUser(Core::System& system_) : Interface(system_, "NFP:IUser") {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMapWithClass( + FunctionInfoTyped{0, &IUser::Initialize, "Initialize"}, + FunctionInfoTyped{1, &IUser::Finalize, "Finalize"}, + FunctionInfoTyped{2, &IUser::ListDevices, "ListDevices"}, + FunctionInfoTyped{3, &IUser::StartDetection, "StartDetection"}, + FunctionInfoTyped{4, &IUser::StopDetection, "StopDetection"}, + FunctionInfoTyped{5, &IUser::Mount, "Mount"}, + FunctionInfoTyped{6, &IUser::Unmount, "Unmount"}, + FunctionInfoTyped{7, &IUser::OpenApplicationArea, "OpenApplicationArea"}, + FunctionInfoTyped{8, &IUser::GetApplicationArea, "GetApplicationArea"}, + FunctionInfoTyped{9, &IUser::SetApplicationArea, "SetApplicationArea"}, + FunctionInfoTyped{10, &IUser::Flush, "Flush"}, + FunctionInfoTyped{11, &IUser::Restore, "Restore"}, + FunctionInfoTyped{12, &IUser::CreateApplicationArea, "CreateApplicationArea"}, + FunctionInfoTyped{13, &IUser::GetTagInfo, "GetTagInfo"}, + FunctionInfoTyped{14, &IUser::GetRegisterInfo, "GetRegisterInfo"}, + FunctionInfoTyped{15, &IUser::GetCommonInfo, "GetCommonInfo"}, + FunctionInfoTyped{16, &IUser::GetModelInfo, "GetModelInfo"}, + FunctionInfoTyped{17, &IUser::AttachActivateEvent, "AttachActivateEvent"}, + FunctionInfoTyped{18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"}, + FunctionInfoTyped{19, &IUser::GetState, "GetState"}, + FunctionInfoTyped{20, &IUser::GetDeviceState, "GetDeviceState"}, + FunctionInfoTyped{21, &IUser::GetNpadId, "GetNpadId"}, + FunctionInfoTyped{22, &IUser::GetApplicationAreaSize, "GetApplicationAreaSize"}, + FunctionInfoTyped{23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, + FunctionInfoTyped{24, &IUser::RecreateApplicationArea, "RecreateApplicationArea"}, + FunctionInfoTyped{25, &IUser::StartDetection, "StartDetectionWithFilter"} + ); }; class ISystem final : public Interface { public: - explicit ISystem(Core::System& system_) : Interface(system_, "NFP:ISystem") { - static const FunctionInfoTyped functions[] = { - FunctionInfoTyped{0, &ISystem::InitializeSystem, "InitializeSystem"}, - FunctionInfoTyped{1, &ISystem::FinalizeSystem, "FinalizeSystem"}, - FunctionInfoTyped{2, &ISystem::ListDevices, "ListDevices"}, - FunctionInfoTyped{3, &ISystem::StartDetection, "StartDetection"}, - FunctionInfoTyped{4, &ISystem::StopDetection, "StopDetection"}, - FunctionInfoTyped{5, &ISystem::Mount, "Mount"}, - FunctionInfoTyped{6, &ISystem::Unmount, "Unmount"}, - FunctionInfoTyped{10, &ISystem::Flush, "Flush"}, - FunctionInfoTyped{11, &ISystem::Restore, "Restore"}, - FunctionInfoTyped{12, &ISystem::CreateApplicationArea, "CreateApplicationArea"}, - FunctionInfoTyped{13, &ISystem::GetTagInfo, "GetTagInfo"}, - FunctionInfoTyped{14, &ISystem::GetRegisterInfo, "GetRegisterInfo"}, - FunctionInfoTyped{15, &ISystem::GetCommonInfo, "GetCommonInfo"}, - FunctionInfoTyped{16, &ISystem::GetModelInfo, "GetModelInfo"}, - FunctionInfoTyped{17, &ISystem::AttachActivateEvent, "AttachActivateEvent"}, - FunctionInfoTyped{18, &ISystem::AttachDeactivateEvent, "AttachDeactivateEvent"}, - FunctionInfoTyped{19, &ISystem::GetState, "GetState"}, - FunctionInfoTyped{20, &ISystem::GetDeviceState, "GetDeviceState"}, - FunctionInfoTyped{21, &ISystem::GetNpadId, "GetNpadId"}, - FunctionInfoTyped{23, &ISystem::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, - FunctionInfoTyped{25, &ISystem::StartDetection, "StartDetectionWithFilter"}, - FunctionInfoTyped{100, &ISystem::Format, "Format"}, - FunctionInfoTyped{101, &ISystem::GetAdminInfo, "GetAdminInfo"}, - FunctionInfoTyped{102, &ISystem::GetRegisterInfoPrivate, "GetRegisterInfoPrivate"}, - FunctionInfoTyped{103, &ISystem::SetRegisterInfoPrivate, "SetRegisterInfoPrivate"}, - FunctionInfoTyped{104, &ISystem::DeleteRegisterInfo, "DeleteRegisterInfo"}, - FunctionInfoTyped{105, &ISystem::DeleteApplicationArea, "DeleteApplicationArea"}, - FunctionInfoTyped{106, &ISystem::ExistsApplicationArea, "ExistsApplicationArea"} - }; - RegisterHandlers(functions); + explicit ISystem(Core::System& system_) : Interface(system_, "NFP:ISystem") {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMapWithClass( + FunctionInfoTyped{0, &ISystem::InitializeSystem, "InitializeSystem"}, + FunctionInfoTyped{1, &ISystem::FinalizeSystem, "FinalizeSystem"}, + FunctionInfoTyped{2, &ISystem::ListDevices, "ListDevices"}, + FunctionInfoTyped{3, &ISystem::StartDetection, "StartDetection"}, + FunctionInfoTyped{4, &ISystem::StopDetection, "StopDetection"}, + FunctionInfoTyped{5, &ISystem::Mount, "Mount"}, + FunctionInfoTyped{6, &ISystem::Unmount, "Unmount"}, + FunctionInfoTyped{10, &ISystem::Flush, "Flush"}, + FunctionInfoTyped{11, &ISystem::Restore, "Restore"}, + FunctionInfoTyped{12, &ISystem::CreateApplicationArea, "CreateApplicationArea"}, + FunctionInfoTyped{13, &ISystem::GetTagInfo, "GetTagInfo"}, + FunctionInfoTyped{14, &ISystem::GetRegisterInfo, "GetRegisterInfo"}, + FunctionInfoTyped{15, &ISystem::GetCommonInfo, "GetCommonInfo"}, + FunctionInfoTyped{16, &ISystem::GetModelInfo, "GetModelInfo"}, + FunctionInfoTyped{17, &ISystem::AttachActivateEvent, "AttachActivateEvent"}, + FunctionInfoTyped{18, &ISystem::AttachDeactivateEvent, "AttachDeactivateEvent"}, + FunctionInfoTyped{19, &ISystem::GetState, "GetState"}, + FunctionInfoTyped{20, &ISystem::GetDeviceState, "GetDeviceState"}, + FunctionInfoTyped{21, &ISystem::GetNpadId, "GetNpadId"}, + FunctionInfoTyped{23, &ISystem::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, + FunctionInfoTyped{25, &ISystem::StartDetection, "StartDetectionWithFilter"}, + FunctionInfoTyped{100, &ISystem::Format, "Format"}, + FunctionInfoTyped{101, &ISystem::GetAdminInfo, "GetAdminInfo"}, + FunctionInfoTyped{102, &ISystem::GetRegisterInfoPrivate, "GetRegisterInfoPrivate"}, + FunctionInfoTyped{103, &ISystem::SetRegisterInfoPrivate, "SetRegisterInfoPrivate"}, + FunctionInfoTyped{104, &ISystem::DeleteRegisterInfo, "DeleteRegisterInfo"}, + FunctionInfoTyped{105, &ISystem::DeleteApplicationArea, "DeleteApplicationArea"}, + FunctionInfoTyped{106, &ISystem::ExistsApplicationArea, "ExistsApplicationArea"} + ); }; class IDebug final : public Interface { public: - explicit IDebug(Core::System& system_) : Interface(system_, "NFP:IDebug") { - static const FunctionInfoTyped functions[] = { - FunctionInfoTyped{0, &IDebug::InitializeDebug, "InitializeDebug"}, - FunctionInfoTyped{1, &IDebug::FinalizeDebug, "FinalizeDebug"}, - FunctionInfoTyped{2, &IDebug::ListDevices, "ListDevices"}, - FunctionInfoTyped{3, &IDebug::StartDetection, "StartDetection"}, - FunctionInfoTyped{4, &IDebug::StopDetection, "StopDetection"}, - FunctionInfoTyped{5, &IDebug::Mount, "Mount"}, - FunctionInfoTyped{6, &IDebug::Unmount, "Unmount"}, - FunctionInfoTyped{7, &IDebug::OpenApplicationArea, "OpenApplicationArea"}, - FunctionInfoTyped{8, &IDebug::GetApplicationArea, "GetApplicationArea"}, - FunctionInfoTyped{9, &IDebug::SetApplicationArea, "SetApplicationArea"}, - FunctionInfoTyped{10, &IDebug::Flush, "Flush"}, - FunctionInfoTyped{11, &IDebug::Restore, "Restore"}, - FunctionInfoTyped{12, &IDebug::CreateApplicationArea, "CreateApplicationArea"}, - FunctionInfoTyped{13, &IDebug::GetTagInfo, "GetTagInfo"}, - FunctionInfoTyped{14, &IDebug::GetRegisterInfo, "GetRegisterInfo"}, - FunctionInfoTyped{15, &IDebug::GetCommonInfo, "GetCommonInfo"}, - FunctionInfoTyped{16, &IDebug::GetModelInfo, "GetModelInfo"}, - FunctionInfoTyped{17, &IDebug::AttachActivateEvent, "AttachActivateEvent"}, - FunctionInfoTyped{18, &IDebug::AttachDeactivateEvent, "AttachDeactivateEvent"}, - FunctionInfoTyped{19, &IDebug::GetState, "GetState"}, - FunctionInfoTyped{20, &IDebug::GetDeviceState, "GetDeviceState"}, - FunctionInfoTyped{21, &IDebug::GetNpadId, "GetNpadId"}, - FunctionInfoTyped{22, &IDebug::GetApplicationAreaSize, "GetApplicationAreaSize"}, - FunctionInfoTyped{23, &IDebug::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, - FunctionInfoTyped{24, &IDebug::RecreateApplicationArea, "RecreateApplicationArea"}, - FunctionInfoTyped{25, &IDebug::StartDetection, "StartDetectionWithFilter"}, - FunctionInfoTyped{100, &IDebug::Format, "Format"}, - FunctionInfoTyped{101, &IDebug::GetAdminInfo, "GetAdminInfo"}, - FunctionInfoTyped{102, &IDebug::GetRegisterInfoPrivate, "GetRegisterInfoPrivate"}, - FunctionInfoTyped{103, &IDebug::SetRegisterInfoPrivate, "SetRegisterInfoPrivate"}, - FunctionInfoTyped{104, &IDebug::DeleteRegisterInfo, "DeleteRegisterInfo"}, - FunctionInfoTyped{105, &IDebug::DeleteApplicationArea, "DeleteApplicationArea"}, - FunctionInfoTyped{106, &IDebug::ExistsApplicationArea, "ExistsApplicationArea"}, - FunctionInfoTyped{200, &IDebug::GetAll, "GetAll"}, - FunctionInfoTyped{201, &IDebug::SetAll, "SetAll"}, - FunctionInfoTyped{202, &IDebug::FlushDebug, "FlushDebug"}, - FunctionInfoTyped{203, &IDebug::BreakTag, "BreakTag"}, - FunctionInfoTyped{204, &IDebug::ReadBackupData, "ReadBackupData"}, - FunctionInfoTyped{205, &IDebug::WriteBackupData, "WriteBackupData"}, - FunctionInfoTyped{206, &IDebug::WriteNtf, "WriteNtf"} - }; - RegisterHandlers(functions); + explicit IDebug(Core::System& system_) : Interface(system_, "NFP:IDebug") {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMapWithClass( + FunctionInfoTyped{0, &IDebug::InitializeDebug, "InitializeDebug"}, + FunctionInfoTyped{1, &IDebug::FinalizeDebug, "FinalizeDebug"}, + FunctionInfoTyped{2, &IDebug::ListDevices, "ListDevices"}, + FunctionInfoTyped{3, &IDebug::StartDetection, "StartDetection"}, + FunctionInfoTyped{4, &IDebug::StopDetection, "StopDetection"}, + FunctionInfoTyped{5, &IDebug::Mount, "Mount"}, + FunctionInfoTyped{6, &IDebug::Unmount, "Unmount"}, + FunctionInfoTyped{7, &IDebug::OpenApplicationArea, "OpenApplicationArea"}, + FunctionInfoTyped{8, &IDebug::GetApplicationArea, "GetApplicationArea"}, + FunctionInfoTyped{9, &IDebug::SetApplicationArea, "SetApplicationArea"}, + FunctionInfoTyped{10, &IDebug::Flush, "Flush"}, + FunctionInfoTyped{11, &IDebug::Restore, "Restore"}, + FunctionInfoTyped{12, &IDebug::CreateApplicationArea, "CreateApplicationArea"}, + FunctionInfoTyped{13, &IDebug::GetTagInfo, "GetTagInfo"}, + FunctionInfoTyped{14, &IDebug::GetRegisterInfo, "GetRegisterInfo"}, + FunctionInfoTyped{15, &IDebug::GetCommonInfo, "GetCommonInfo"}, + FunctionInfoTyped{16, &IDebug::GetModelInfo, "GetModelInfo"}, + FunctionInfoTyped{17, &IDebug::AttachActivateEvent, "AttachActivateEvent"}, + FunctionInfoTyped{18, &IDebug::AttachDeactivateEvent, "AttachDeactivateEvent"}, + FunctionInfoTyped{19, &IDebug::GetState, "GetState"}, + FunctionInfoTyped{20, &IDebug::GetDeviceState, "GetDeviceState"}, + FunctionInfoTyped{21, &IDebug::GetNpadId, "GetNpadId"}, + FunctionInfoTyped{22, &IDebug::GetApplicationAreaSize, "GetApplicationAreaSize"}, + FunctionInfoTyped{23, &IDebug::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, + FunctionInfoTyped{24, &IDebug::RecreateApplicationArea, "RecreateApplicationArea"}, + FunctionInfoTyped{25, &IDebug::StartDetection, "StartDetectionWithFilter"}, + FunctionInfoTyped{100, &IDebug::Format, "Format"}, + FunctionInfoTyped{101, &IDebug::GetAdminInfo, "GetAdminInfo"}, + FunctionInfoTyped{102, &IDebug::GetRegisterInfoPrivate, "GetRegisterInfoPrivate"}, + FunctionInfoTyped{103, &IDebug::SetRegisterInfoPrivate, "SetRegisterInfoPrivate"}, + FunctionInfoTyped{104, &IDebug::DeleteRegisterInfo, "DeleteRegisterInfo"}, + FunctionInfoTyped{105, &IDebug::DeleteApplicationArea, "DeleteApplicationArea"}, + FunctionInfoTyped{106, &IDebug::ExistsApplicationArea, "ExistsApplicationArea"}, + FunctionInfoTyped{200, &IDebug::GetAll, "GetAll"}, + FunctionInfoTyped{201, &IDebug::SetAll, "SetAll"}, + FunctionInfoTyped{202, &IDebug::FlushDebug, "FlushDebug"}, + FunctionInfoTyped{203, &IDebug::BreakTag, "BreakTag"}, + FunctionInfoTyped{204, &IDebug::ReadBackupData, "ReadBackupData"}, + FunctionInfoTyped{205, &IDebug::WriteBackupData, "WriteBackupData"}, + FunctionInfoTyped{206, &IDebug::WriteNtf, "WriteNtf"} + ); }; class IUserManager final : public ServiceFramework { public: explicit IUserManager(Core::System& system_) : ServiceFramework{system_, "nfp:user"} {} - FunctionInfoBase const* FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - private: void CreateUserInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); @@ -150,6 +152,9 @@ private: rb.PushIpcInterface(ctx, system); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } static constexpr auto functions = CreateStaticMap( FunctionInfo{0, &IUserManager::CreateUserInterface, "CreateUserInterface"} ); diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 2ca298e0e8..161b718121 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -235,15 +235,6 @@ public: explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"}, svc_ctx{system_, "IScanRequest"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &IScanRequest::Submit, "Submit"}, - FunctionInfo{1, &IScanRequest::IsProcessing, "IsProcessing"}, - FunctionInfo{2, &IScanRequest::GetResult, "GetResult"}, - FunctionInfo{3, &IScanRequest::GetSystemEventReadableHandle, "GetSystemEventReadableHandle"}, - FunctionInfo{4, &IScanRequest::SetChannels, "SetChannels"} - }; - RegisterHandlers(functions); - evt_scan_complete = CreateKEvent(svc_ctx, "IScanRequest:Complete"); evt_processing = CreateKEvent(svc_ctx, "IScanRequest:Processing"); } @@ -257,8 +248,6 @@ public: } private: - std::vector scan_results; - void Submit(HLERequestContext& ctx) { if (state.load() == State::Finished) { @@ -329,6 +318,17 @@ private: evt_scan_complete->Signal(system.Kernel()); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &IScanRequest::Submit, "Submit"}, + FunctionInfo{1, &IScanRequest::IsProcessing, "IsProcessing"}, + FunctionInfo{2, &IScanRequest::GetResult, "GetResult"}, + FunctionInfo{3, &IScanRequest::GetSystemEventReadableHandle, "GetSystemEventReadableHandle"}, + FunctionInfo{4, &IScanRequest::SetChannels, "SetChannels"} + ); + std::vector scan_results; KernelHelpers::ServiceContext svc_ctx; Kernel::KEvent* evt_scan_complete{}; @@ -342,36 +342,6 @@ class IRequest final : public ServiceFramework { public: explicit IRequest(Core::System& system_) : ServiceFramework{system_, "IRequest"}, service_context{system_, "IRequest"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &IRequest::GetRequestState, "GetRequestState"}, - FunctionInfo{1, &IRequest::GetResult, "GetResult"}, - FunctionInfo{2, &IRequest::GetSystemEventReadableHandles, "GetSystemEventReadableHandles"}, - FunctionInfo{3, &IRequest::Cancel, "Cancel"}, - FunctionInfo{4, &IRequest::Submit, "Submit"}, - FunctionInfo{5, nullptr, "SetRequirement"}, - FunctionInfo{6, &IRequest::SetRequirementPreset, "SetRequirementPreset"}, - FunctionInfo{8, nullptr, "SetPriority"}, - FunctionInfo{9, &IRequest::SetNetworkProfileId, "SetNetworkProfileId"}, - FunctionInfo{10, nullptr, "SetRejectable"}, - FunctionInfo{11, &IRequest::SetConnectionConfirmationOption, "SetConnectionConfirmationOption"}, - FunctionInfo{12, nullptr, "SetPersistent"}, - FunctionInfo{13, nullptr, "SetInstant"}, - FunctionInfo{14, nullptr, "SetSustainable"}, - FunctionInfo{15, nullptr, "SetRawPriority"}, - FunctionInfo{16, nullptr, "SetGreedy"}, - FunctionInfo{17, nullptr, "SetSharable"}, - FunctionInfo{18, nullptr, "SetRequirementByRevision"}, - FunctionInfo{19, nullptr, "GetRequirement"}, - FunctionInfo{20, nullptr, "GetRevision"}, - FunctionInfo{21, &IRequest::GetAppletInfo, "GetAppletInfo"}, - FunctionInfo{22, nullptr, "GetAdditionalInfo"}, - FunctionInfo{23, nullptr, "SetKeptInSleep"}, - FunctionInfo{24, nullptr, "RegisterSocketDescriptor"}, - FunctionInfo{25, nullptr, "UnregisterSocketDescriptor"}, - FunctionInfo{26, nullptr, "GetNetworkAccessStatus"}, //21.0.0+ - }; - RegisterHandlers(functions); - event1 = CreateKEvent(service_context, "IRequest:Event1"); event2 = CreateKEvent(service_context, "IRequest:Event2"); state = RequestState::NotSubmitted; @@ -494,6 +464,37 @@ private: event1->Signal(system.Kernel()); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &IRequest::GetRequestState, "GetRequestState"}, + FunctionInfo{1, &IRequest::GetResult, "GetResult"}, + FunctionInfo{2, &IRequest::GetSystemEventReadableHandles, "GetSystemEventReadableHandles"}, + FunctionInfo{3, &IRequest::Cancel, "Cancel"}, + FunctionInfo{4, &IRequest::Submit, "Submit"}, + FunctionInfo{5, nullptr, "SetRequirement"}, + FunctionInfo{6, &IRequest::SetRequirementPreset, "SetRequirementPreset"}, + FunctionInfo{8, nullptr, "SetPriority"}, + FunctionInfo{9, &IRequest::SetNetworkProfileId, "SetNetworkProfileId"}, + FunctionInfo{10, nullptr, "SetRejectable"}, + FunctionInfo{11, &IRequest::SetConnectionConfirmationOption, "SetConnectionConfirmationOption"}, + FunctionInfo{12, nullptr, "SetPersistent"}, + FunctionInfo{13, nullptr, "SetInstant"}, + FunctionInfo{14, nullptr, "SetSustainable"}, + FunctionInfo{15, nullptr, "SetRawPriority"}, + FunctionInfo{16, nullptr, "SetGreedy"}, + FunctionInfo{17, nullptr, "SetSharable"}, + FunctionInfo{18, nullptr, "SetRequirementByRevision"}, + FunctionInfo{19, nullptr, "GetRequirement"}, + FunctionInfo{20, nullptr, "GetRevision"}, + FunctionInfo{21, &IRequest::GetAppletInfo, "GetAppletInfo"}, + FunctionInfo{22, nullptr, "GetAdditionalInfo"}, + FunctionInfo{23, nullptr, "SetKeptInSleep"}, + FunctionInfo{24, nullptr, "RegisterSocketDescriptor"}, + FunctionInfo{25, nullptr, "UnregisterSocketDescriptor"}, + FunctionInfo{26, nullptr, "GetNetworkAccessStatus"} //21.0.0+ + ); KernelHelpers::ServiceContext service_context; RequestState state; @@ -508,14 +509,16 @@ private: class INetworkProfile final : public ServiceFramework { public: - explicit INetworkProfile(Core::System& system_) : ServiceFramework{system_, "INetworkProfile"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "Update"}, - FunctionInfo{1, nullptr, "PersistOld"}, - FunctionInfo{2, nullptr, "Persist"} - }; - RegisterHandlers(functions); + explicit INetworkProfile(Core::System& system_) : ServiceFramework{system_, "INetworkProfile"} {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Update"}, + FunctionInfo{1, nullptr, "PersistOld"}, + FunctionInfo{2, nullptr, "Persist"} + ); }; void IGeneralService::GetClientId(HLERequestContext& ctx) { @@ -1113,14 +1116,7 @@ IGeneralService::~IGeneralService() = default; class NetworkInterface final : public ServiceFramework { public: - explicit NetworkInterface(const char* name, Core::System& system_) - : ServiceFramework{system_, name} { - static const FunctionInfo functions[] = { - FunctionInfo{4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - FunctionInfo{5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"} - }; - RegisterHandlers(functions); - } + explicit NetworkInterface(const char* name, Core::System& system_) : ServiceFramework{system_, name} {} private: void CreateGeneralServiceOld(HLERequestContext& ctx) { @@ -1138,6 +1134,14 @@ private: rb.Push(ResultSuccess); rb.PushIpcInterface(ctx, system); } + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, + FunctionInfo{5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"} + ); }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index 907f86caea..6e88410d1c 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -506,19 +506,7 @@ public: explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"}, service_context{system_, "IEnsureNetworkClockAvailabilityService"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, - FunctionInfo{1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, - "GetFinishNotificationEvent"}, - FunctionInfo{2, &IEnsureNetworkClockAvailabilityService::GetResult, "GetResult"}, - FunctionInfo{3, &IEnsureNetworkClockAvailabilityService::Cancel, "Cancel"}, - FunctionInfo{4, &IEnsureNetworkClockAvailabilityService::IsProcessing, "IsProcessing"}, - FunctionInfo{5, &IEnsureNetworkClockAvailabilityService::GetServerTime, "GetServerTime"} - }; - RegisterHandlers(functions); - - finished_event = - service_context.CreateEvent("IEnsureNetworkClockAvailabilityService:FinishEvent"); + finished_event = service_context.CreateEvent("IEnsureNetworkClockAvailabilityService:FinishEvent"); } ~IEnsureNetworkClockAvailabilityService() override { @@ -575,8 +563,18 @@ private: rb.PushRaw(server_time); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, + FunctionInfo{1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, "GetFinishNotificationEvent"}, + FunctionInfo{2, &IEnsureNetworkClockAvailabilityService::GetResult, "GetResult"}, + FunctionInfo{3, &IEnsureNetworkClockAvailabilityService::Cancel, "Cancel"}, + FunctionInfo{4, &IEnsureNetworkClockAvailabilityService::IsProcessing, "IsProcessing"}, + FunctionInfo{5, &IEnsureNetworkClockAvailabilityService::GetServerTime, "GetServerTime"} + ); KernelHelpers::ServiceContext service_context; - Kernel::KEvent* finished_event; }; diff --git a/src/core/hle/service/ns/read_only_application_control_data_interface.cpp b/src/core/hle/service/ns/read_only_application_control_data_interface.cpp index 44817eff91..4faf99c8b4 100644 --- a/src/core/hle/service/ns/read_only_application_control_data_interface.cpp +++ b/src/core/hle/service/ns/read_only_application_control_data_interface.cpp @@ -99,13 +99,6 @@ public: , data_offset{offset} , data_size{size} { - static const FunctionInfo functions[] = { - FunctionInfo{0, D<&IAsyncValue::GetSize>, "GetSize"}, - FunctionInfo{1, D<&IAsyncValue::Get>, "Get"}, - FunctionInfo{2, D<&IAsyncValue::Cancel>, "Cancel"}, - FunctionInfo{3, D<&IAsyncValue::GetErrorContext>, "GetErrorContext"} - }; - RegisterHandlers(functions); completion_event = service_context.CreateEvent("IAsyncValue:Completion"); completion_event->GetReadableEvent().Signal(system.Kernel()); } @@ -137,6 +130,16 @@ private: LOG_DEBUG(Service_NS, "called"); R_SUCCEED(); } + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&IAsyncValue::GetSize>, "GetSize"}, + FunctionInfo{1, D<&IAsyncValue::Get>, "Get"}, + FunctionInfo{2, D<&IAsyncValue::Cancel>, "Cancel"}, + FunctionInfo{3, D<&IAsyncValue::GetErrorContext>, "GetErrorContext"} + ); KernelHelpers::ServiceContext service_context; Kernel::KEvent* completion_event{}; s32 data_offset; diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 9eecba84d7..3dea5d7618 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -50,55 +50,61 @@ class NVGEM_C final : public ServiceFramework { public: explicit NVGEM_C(Core::System& system_) : ServiceFramework{system_, "nvgem:c"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "Initialize"}, - FunctionInfo{1, nullptr, "GetEventHandle"}, - FunctionInfo{2, nullptr, "ControlNotification"}, - FunctionInfo{3, nullptr, "SetNotificationPerm"}, - FunctionInfo{4, nullptr, "SetCoreDumpPerm"}, - FunctionInfo{5, nullptr, "GetAruid"}, - FunctionInfo{6, nullptr, "Reset"}, - FunctionInfo{7, nullptr, "GetAruid2"} - }; - RegisterHandlers(functions); + {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Initialize"}, + FunctionInfo{1, nullptr, "GetEventHandle"}, + FunctionInfo{2, nullptr, "ControlNotification"}, + FunctionInfo{3, nullptr, "SetNotificationPerm"}, + FunctionInfo{4, nullptr, "SetCoreDumpPerm"}, + FunctionInfo{5, nullptr, "GetAruid"}, + FunctionInfo{6, nullptr, "Reset"}, + FunctionInfo{7, nullptr, "GetAruid2"} + ); }; class NVGEM_CD final : public ServiceFramework { public: explicit NVGEM_CD(Core::System& system_) : ServiceFramework{system_, "nvgem:cd"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "Initialize"}, - FunctionInfo{1, nullptr, "GetAruid"}, - FunctionInfo{2, nullptr, "ReadNextBlock"}, - FunctionInfo{3, nullptr, "GetNextBlockSize"}, - FunctionInfo{4, nullptr, "ReadNextBlock2"} - }; - RegisterHandlers(functions); + {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Initialize"}, + FunctionInfo{1, nullptr, "GetAruid"}, + FunctionInfo{2, nullptr, "ReadNextBlock"}, + FunctionInfo{3, nullptr, "GetNextBlockSize"}, + FunctionInfo{4, nullptr, "ReadNextBlock2"} + ); }; class NVDBG_D final : public ServiceFramework { public: explicit NVDBG_D(Core::System& system_) : ServiceFramework{system_, "nvdbg:d"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "Open"}, - FunctionInfo{1, nullptr, "Ioctl"}, - FunctionInfo{2, nullptr, "Close"}, - FunctionInfo{4, nullptr, "QueryEvent"}, - FunctionInfo{9, nullptr, "DumpStatus"}, - FunctionInfo{10, nullptr, "InitializeDevtools"}, - FunctionInfo{11, nullptr, "Ioctl2"}, - FunctionInfo{12, nullptr, "Ioctl3"}, - FunctionInfo{13, nullptr, "SetConfiguration"} - }; - RegisterHandlers(functions); + {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Open"}, + FunctionInfo{1, nullptr, "Ioctl"}, + FunctionInfo{2, nullptr, "Close"}, + FunctionInfo{4, nullptr, "QueryEvent"}, + FunctionInfo{9, nullptr, "DumpStatus"}, + FunctionInfo{10, nullptr, "InitializeDevtools"}, + FunctionInfo{11, nullptr, "Ioctl2"}, + FunctionInfo{12, nullptr, "Ioctl3"}, + FunctionInfo{13, nullptr, "SetConfiguration"} + ); }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index be7a96aa10..f347cc7340 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -47,13 +47,7 @@ void GetApplicationPidGeneric(Kernel::KernelCore& kernel, HLERequestContext& ctx class BootMode final : public ServiceFramework { public: - explicit BootMode(Core::System& system_) : ServiceFramework{system_, "pm:bm"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &BootMode::GetBootMode, "GetBootMode"}, - FunctionInfo{1, &BootMode::SetMaintenanceBoot, "SetMaintenanceBoot"} - }; - RegisterHandlers(functions); - } + explicit BootMode(Core::System& system_) : ServiceFramework{system_, "pm:bm"} {} private: void GetBootMode(HLERequestContext& ctx) { @@ -73,6 +67,13 @@ private: rb.Push(ResultSuccess); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &BootMode::GetBootMode, "GetBootMode"}, + FunctionInfo{1, &BootMode::SetMaintenanceBoot, "SetMaintenanceBoot"} + ); SystemBootMode boot_mode = SystemBootMode::Normal; }; @@ -80,10 +81,6 @@ class DebugMonitor final : public ServiceFramework { public: explicit DebugMonitor(Core::System& system_) : ServiceFramework{system_, "pm:dmnt"} {} - FunctionInfoBase const* FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - private: void GetProcessId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; @@ -153,6 +150,9 @@ private: rb.PushRaw(override_status); } + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } static constexpr auto functions = CreateStaticMap( FunctionInfo{0, nullptr, "GetJitDebugProcessIdList"}, FunctionInfo{1, nullptr, "StartProcess"}, @@ -168,15 +168,7 @@ private: class Info final : public ServiceFramework { public: - explicit Info(Core::System& system_) : ServiceFramework{system_, "pm:info"} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &Info::GetProgramId, "GetProgramId"}, - FunctionInfo{65000, &Info::AtmosphereGetProcessId, "AtmosphereGetProcessId"}, - FunctionInfo{65001, nullptr, "AtmosphereHasLaunchedProgram"}, - FunctionInfo{65002, nullptr, "AtmosphereGetProcessInfo"} - }; - RegisterHandlers(functions); - } + explicit Info(Core::System& system_) : ServiceFramework{system_, "pm:info"} {} private: void GetProgramId(HLERequestContext& ctx) { @@ -218,6 +210,16 @@ private: rb.Push(ResultSuccess); rb.Push(process->GetProcessId()); } + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &Info::GetProgramId, "GetProgramId"}, + FunctionInfo{65000, &Info::AtmosphereGetProcessId, "AtmosphereGetProcessId"}, + FunctionInfo{65001, nullptr, "AtmosphereHasLaunchedProgram"}, + FunctionInfo{65002, nullptr, "AtmosphereGetProcessInfo"} + ); }; class Shell final : public ServiceFramework { diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 4e63aa8a50..7a34b09c24 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -109,7 +109,6 @@ private: virtual FunctionInfoBase const* FindRequestTipc(u32 key) = 0; void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); - void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n); void ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info); protected: @@ -172,6 +171,15 @@ protected: }; } + // Used exclusively by NFC + template + requires (std::same_as> && ...) + static constexpr frozen::map, sizeof...(Ts)> CreateStaticMapWithClass(Ts... args) { + return frozen::map, sizeof...(args)>{ + {args.expected_header, FunctionInfoTyped(args)}... + }; + } + template static FunctionInfoBase const* HandlerTableGenerateWithFind(u32 key, T const& map) { auto const it = map.find(key); @@ -192,49 +200,13 @@ protected: return it != handlers.end() ? std::addressof(it->second) : nullptr; } - FunctionInfoBase const* FindRequestTipc(u32 key) override { - auto it = handlers_tipc.find(key); - return it != handlers_tipc.end() ? std::addressof(it->second) : nullptr; - } - - constexpr void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { - // Usually this array is sorted by id already, so hint to insert at the end - handlers.reserve(handlers.size() + n); - for (std::size_t i = 0; i < n; ++i) - handlers.emplace_hint(handlers.cend(), functions[i].expected_header, functions[i]); - } - - constexpr void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n) { - // Usually this array is sorted by id already, so hint to insert at the end - handlers_tipc.reserve(handlers_tipc.size() + n); - for (std::size_t i = 0; i < n; ++i) - handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header, functions[i]); - } - /// Registers handlers in the service. template constexpr void RegisterHandlers(const FunctionInfoTyped (&functions)[N]) { - RegisterHandlers(functions, N); - } - - /// @brief Registers handlers in the service. Usually prefer using the other RegisterHandlers - /// overload in order to avoid needing to specify the array size. - template - constexpr void RegisterHandlers(const FunctionInfoTyped* functions, std::size_t n) { - RegisterHandlersBase(functions, n); - } - - /// @brief Registers handlers in the service. - template - constexpr void RegisterHandlersTipc(const FunctionInfoTyped (&functions)[N]) { - RegisterHandlersTipc(functions, N); - } - - /// @brief Registers handlers in the service. Usually prefer using the other RegisterHandlers - /// overload in order to avoid needing to specify the array size. - template - constexpr void RegisterHandlersTipc(const FunctionInfoTyped* functions, std::size_t n) { - RegisterHandlersBaseTipc(functions, n); + // Usually this array is sorted by id already, so hint to insert at the end + handlers.reserve(handlers.size() + N); + for (std::size_t i = 0; i < N; ++i) + handlers.emplace_hint(handlers.cend(), functions[i].expected_header, functions[i]); } protected: @@ -267,7 +239,6 @@ private: } ::Common::unordered_map handlers; - ::Common::unordered_map handlers_tipc; }; } // namespace Service diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 9d541ca418..a1a36b63a2 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -112,6 +112,51 @@ Result ServiceManager::GetServicePort(Kernel::KClientPort** out_client_port, return ResultSuccess; } +/// Interface to "sm:" service +class SM final : public ServiceFramework { +public: + explicit SM(ServiceManager& service_manager_, Core::System& system_); + ~SM() override; + +private: + void Initialize(HLERequestContext& ctx); + void GetServiceCmif(HLERequestContext& ctx); + void GetServiceTipc(HLERequestContext& ctx); + void RegisterServiceCmif(HLERequestContext& ctx); + void RegisterServiceTipc(HLERequestContext& ctx); + void UnregisterService(HLERequestContext& ctx); + void AtmosphereHasService(HLERequestContext& ctx); + + Result GetServiceImpl(Kernel::KClientSession** out_client_session, HLERequestContext& ctx); + void RegisterServiceImpl(HLERequestContext& ctx, std::string name, u32 max_session_count, bool is_light); + + // TODO: We reuse function list for both TIPC and non-TIPC + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + FunctionInfoBase const* FindRequestTipc(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &SM::Initialize, "Initialize"}, + FunctionInfo{1, &SM::GetServiceTipc, "GetService"}, + FunctionInfo{2, &SM::RegisterServiceTipc, "RegisterService"}, + FunctionInfo{3, &SM::UnregisterService, "UnregisterService"}, + FunctionInfo{4, nullptr, "DetachClient"}, + FunctionInfo{65000, nullptr, "AtmosphereInstallMitm"}, + FunctionInfo{65001, nullptr, "AtmosphereUninstallMitm"}, + FunctionInfo{65002, nullptr, "Deprecated_AtmosphereAssociatePidTidForMitm"}, + FunctionInfo{65003, nullptr, "AtmosphereAcknowledgeMitmSession"}, + FunctionInfo{65004, nullptr, "AtmosphereHasMitm"}, + FunctionInfo{65005, nullptr, "AtmosphereWaitMitm"}, + FunctionInfo{65006, nullptr, "AtmosphereDeclareFutureMitm"}, + FunctionInfo{65100, &SM::AtmosphereHasService, "AtmosphereHasService"}, + FunctionInfo{65101, nullptr, "AtmosphereWaitService"} + ); + + ServiceManager& service_manager; +}; + /** * SM::Initialize service function * Inputs: @@ -194,7 +239,7 @@ Result SM::GetServiceImpl(Kernel::KClientSession** out_client_session, HLEReques // Create a new session. Kernel::KClientSession* session{}; - if (const auto result = client_port->CreateSession(kernel, &session); result.IsError()) { + if (const auto result = client_port->CreateSession(system.Kernel(), &session); result.IsError()) { LOG_ERROR(Service_SM, "called service={} -> error {:#08x}", name, result.raw); return result; } @@ -265,42 +310,7 @@ void SM::AtmosphereHasService(HLERequestContext& ctx) { SM::SM(ServiceManager& service_manager_, Core::System& system_) : ServiceFramework{system_, "sm:", 64} , service_manager{service_manager_} - , kernel{system_.Kernel()} -{ - RegisterHandlers({ - FunctionInfo{0, &SM::Initialize, "Initialize"}, - FunctionInfo{1, &SM::GetServiceCmif, "GetService"}, - FunctionInfo{2, &SM::RegisterServiceCmif, "RegisterService"}, - FunctionInfo{3, &SM::UnregisterService, "UnregisterService"}, - FunctionInfo{4, nullptr, "DetachClient"}, - // TODO: are these non-TIPC as well? - FunctionInfo{65000, nullptr, "AtmosphereInstallMitm"}, - FunctionInfo{65001, nullptr, "AtmosphereUninstallMitm"}, - FunctionInfo{65002, nullptr, "Deprecated_AtmosphereAssociatePidTidForMitm"}, - FunctionInfo{65003, nullptr, "AtmosphereAcknowledgeMitmSession"}, - FunctionInfo{65004, nullptr, "AtmosphereHasMitm"}, - FunctionInfo{65005, nullptr, "AtmosphereWaitMitm"}, - FunctionInfo{65006, nullptr, "AtmosphereDeclareFutureMitm"}, - FunctionInfo{65100, &SM::AtmosphereHasService, "AtmosphereHasService"}, - FunctionInfo{65101, nullptr, "AtmosphereWaitService"}, - }); - RegisterHandlersTipc({ - FunctionInfo{0, &SM::Initialize, "Initialize"}, - FunctionInfo{1, &SM::GetServiceTipc, "GetService"}, - FunctionInfo{2, &SM::RegisterServiceTipc, "RegisterService"}, - FunctionInfo{3, &SM::UnregisterService, "UnregisterService"}, - FunctionInfo{4, nullptr, "DetachClient"}, - FunctionInfo{65000, nullptr, "AtmosphereInstallMitm"}, - FunctionInfo{65001, nullptr, "AtmosphereUninstallMitm"}, - FunctionInfo{65002, nullptr, "Deprecated_AtmosphereAssociatePidTidForMitm"}, - FunctionInfo{65003, nullptr, "AtmosphereAcknowledgeMitmSession"}, - FunctionInfo{65004, nullptr, "AtmosphereHasMitm"}, - FunctionInfo{65005, nullptr, "AtmosphereWaitMitm"}, - FunctionInfo{65006, nullptr, "AtmosphereDeclareFutureMitm"}, - FunctionInfo{65100, &SM::AtmosphereHasService, "AtmosphereHasService"}, - FunctionInfo{65101, nullptr, "AtmosphereWaitService"}, - }); -} +{} SM::~SM() = default; diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index c520a46fb2..f17fc60080 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -33,29 +33,7 @@ class SessionRequestHandler; namespace Service::SM { class Controller; - -/// Interface to "sm:" service -class SM final : public ServiceFramework { -public: - explicit SM(ServiceManager& service_manager_, Core::System& system_); - ~SM() override; - -private: - void Initialize(HLERequestContext& ctx); - void GetServiceCmif(HLERequestContext& ctx); - void GetServiceTipc(HLERequestContext& ctx); - void RegisterServiceCmif(HLERequestContext& ctx); - void RegisterServiceTipc(HLERequestContext& ctx); - void UnregisterService(HLERequestContext& ctx); - void AtmosphereHasService(HLERequestContext& ctx); - - Result GetServiceImpl(Kernel::KClientSession** out_client_session, HLERequestContext& ctx); - void RegisterServiceImpl(HLERequestContext& ctx, std::string name, u32 max_session_count, - bool is_light); - - ServiceManager& service_manager; - Kernel::KernelCore& kernel; -}; +class SM; class ServiceManager { public: diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp index c348a65bb1..9a970d81d1 100644 --- a/src/core/hle/service/spl/spl_module.cpp +++ b/src/core/hle/service/spl/spl_module.cpp @@ -204,14 +204,15 @@ Result Module::Interface::GetConfigImpl(u64* out_config, ConfigItem config_item) class CSRNG final : public Module::Interface { public: - explicit CSRNG(Core::System& system_, std::shared_ptr module_) - : Interface(system_, std::move(module_), "csrng") { - static const FunctionInfo functions[] = { - FunctionInfo{0, &CSRNG::GenerateRandomBytes, "GenerateRandomBytes"} - }; - RegisterHandlers(functions); - } + explicit CSRNG(Core::System& system_, std::shared_ptr module_) : Interface(system_, std::move(module_), "csrng") {} ~CSRNG() override = default; + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &CSRNG::GenerateRandomBytes, "GenerateRandomBytes"} + ); }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index f49156b046..8f0202cfb4 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -450,29 +450,9 @@ public: explicit ISslContext(Core::System& system_, SslVersion version) : ServiceFramework{system_, "ISslContext"}, ssl_version{version}, shared_data{std::make_shared()} { - static const FunctionInfo functions[] = { - FunctionInfo{0, &ISslContext::SetOption, "SetOption"}, - FunctionInfo{1, &ISslContext::GetOption, "GetOption"}, - FunctionInfo{2, &ISslContext::CreateConnection, "CreateConnection"}, - FunctionInfo{3, &ISslContext::GetConnectionCount, "GetConnectionCount"}, - FunctionInfo{4, &ISslContext::ImportServerPki, "ImportServerPki"}, - FunctionInfo{5, &ISslContext::ImportClientPki, "ImportClientPki"}, - FunctionInfo{6, nullptr, "RemoveServerPki"}, - FunctionInfo{7, nullptr, "RemoveClientPki"}, - FunctionInfo{8, D<&ISslContext::RegisterInternalPki>, "RegisterInternalPki"}, - FunctionInfo{9, nullptr, "AddPolicyOid"}, - FunctionInfo{10, nullptr, "ImportCrl"}, - FunctionInfo{11, nullptr, "RemoveCrl"}, - FunctionInfo{12, nullptr, "ImportClientCertKeyPki"}, - FunctionInfo{13, nullptr, "GeneratePrivateKeyAndCert"} - }; - RegisterHandlers(functions); } private: - SslVersion ssl_version; - std::shared_ptr shared_data; - void SetOption(HLERequestContext& ctx) { struct Parameters { ContextOption option; @@ -559,6 +539,28 @@ private: LOG_WARNING(Service_SSL, "(STUBBED) called"); R_SUCCEED(); } + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &ISslContext::SetOption, "SetOption"}, + FunctionInfo{1, &ISslContext::GetOption, "GetOption"}, + FunctionInfo{2, &ISslContext::CreateConnection, "CreateConnection"}, + FunctionInfo{3, &ISslContext::GetConnectionCount, "GetConnectionCount"}, + FunctionInfo{4, &ISslContext::ImportServerPki, "ImportServerPki"}, + FunctionInfo{5, &ISslContext::ImportClientPki, "ImportClientPki"}, + FunctionInfo{6, nullptr, "RemoveServerPki"}, + FunctionInfo{7, nullptr, "RemoveClientPki"}, + FunctionInfo{8, D<&ISslContext::RegisterInternalPki>, "RegisterInternalPki"}, + FunctionInfo{9, nullptr, "AddPolicyOid"}, + FunctionInfo{10, nullptr, "ImportCrl"}, + FunctionInfo{11, nullptr, "RemoveCrl"}, + FunctionInfo{12, nullptr, "ImportClientCertKeyPki"}, + FunctionInfo{13, nullptr, "GeneratePrivateKeyAndCert"} + ); + SslVersion ssl_version; + std::shared_ptr shared_data; }; class ISslService final : public ServiceFramework { diff --git a/src/core/hle/service/tma/tma.cpp b/src/core/hle/service/tma/tma.cpp index c456b36a66..13df6e098f 100644 --- a/src/core/hle/service/tma/tma.cpp +++ b/src/core/hle/service/tma/tma.cpp @@ -19,12 +19,14 @@ class HTC_TENV final : public ServiceFramework { public: explicit HTC_TENV(Core::System& system_) : ServiceFramework{system_, "htc:tenv"} - { - static const FunctionInfo functions[] = { - FunctionInfo{0, nullptr, "GetServiceInterface"} - }; - RegisterHandlers(functions); + {} + + FunctionInfoBase const* FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "GetServiceInterface"} + ); }; void LoopProcess(Core::System& system) {