From 95df4e674a2300b6a29d0e0d765211cd0e5c7294 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 4 Oct 2017 16:22:14 -0500 Subject: [PATCH] Services/AC: Converted the ac:i and ac:u services to the new service framework. --- src/core/hle/service/ac/ac.cpp | 212 +++++++++++++------------- src/core/hle/service/ac/ac.h | 245 +++++++++++++++++-------------- src/core/hle/service/ac/ac_i.cpp | 51 ++++--- src/core/hle/service/ac/ac_i.h | 11 +- src/core/hle/service/ac/ac_u.cpp | 51 ++++--- src/core/hle/service/ac/ac_u.h | 11 +- src/core/hle/service/service.cpp | 3 +- 7 files changed, 300 insertions(+), 284 deletions(-) diff --git a/src/core/hle/service/ac/ac.cpp b/src/core/hle/service/ac/ac.cpp index e3dd23949..bf9cad3d4 100644 --- a/src/core/hle/service/ac/ac.cpp +++ b/src/core/hle/service/ac/ac.cpp @@ -2,11 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include - #include "common/common_types.h" #include "common/logging/log.h" #include "core/hle/ipc.h" +#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/result.h" @@ -17,169 +16,170 @@ namespace Service { namespace AC { +void Module::Interface::CreateDefaultConfig(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x1, 0, 0); -struct ACConfig { - std::array data; -}; + std::size_t desc_size; + VAddr ac_config_addr = rp.PeekStaticBuffer(0, &desc_size); -static ACConfig default_config{}; + ASSERT_MSG(desc_size >= sizeof(Module::ACConfig), + "Output buffer size can't fit ACConfig structure"); -static bool ac_connected = false; + Memory::WriteBlock(ac_config_addr, &ac->default_config, sizeof(ACConfig)); -static Kernel::SharedPtr close_event; -static Kernel::SharedPtr connect_event; -static Kernel::SharedPtr disconnect_event; - -void CreateDefaultConfig(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - u32 ac_config_addr = cmd_buff[65]; - - ASSERT_MSG(cmd_buff[64] == (sizeof(ACConfig) << 14 | 2), - "Output buffer size not equal ACConfig size"); - - Memory::WriteBlock(ac_config_addr, &default_config, sizeof(ACConfig)); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); + rb.Push(RESULT_SUCCESS); + rb.PushStaticBuffer(ac_config_addr, sizeof(ACConfig), 0); LOG_WARNING(Service_AC, "(STUBBED) called"); } -void ConnectAsync(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::ConnectAsync(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x4, 0, 6); - connect_event = Kernel::g_handle_table.Get(cmd_buff[4]); - if (connect_event) { - connect_event->name = "AC:connect_event"; - connect_event->Signal(); - ac_connected = true; - } - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + rp.Skip(2, false); // ProcessId descriptor + ac->connect_event = rp.PopObject(); - LOG_WARNING(Service_AC, "(STUBBED) called"); -} - -void GetConnectResult(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - - LOG_WARNING(Service_AC, "(STUBBED) called"); -} - -void CloseAsync(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - if (ac_connected && disconnect_event) { - disconnect_event->Signal(); + if (ac->connect_event) { + ac->connect_event->name = "AC:connect_event"; + ac->connect_event->Signal(); + ac->ac_connected = true; } - close_event = Kernel::g_handle_table.Get(cmd_buff[4]); - if (close_event) { - close_event->name = "AC:close_event"; - close_event->Signal(); + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service_AC, "(STUBBED) called"); +} + +void Module::Interface::GetConnectResult(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x5, 0, 2); + rp.Skip(2, false); // ProcessId descriptor + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); +} + +void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x8, 0, 4); + rp.Skip(2, false); // ProcessId descriptor + + ac->close_event = rp.PopObject(); + + if (ac->ac_connected && ac->disconnect_event) { + ac->disconnect_event->Signal(); } - ac_connected = false; + if (ac->close_event) { + ac->close_event->name = "AC:close_event"; + ac->close_event->Signal(); + } - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - LOG_WARNING(Service_AC, "(STUBBED) called"); + ac->ac_connected = false; + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); } -void GetCloseResult(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x9, 0, 2); + rp.Skip(2, false); // ProcessId descriptor - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_AC, "(STUBBED) called"); } -void GetWifiStatus(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::GetWifiStatus(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0xD, 0, 0); // TODO(purpasmart96): This function is only a stub, // it returns a valid result without implementing full functionality. - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = 0; // Connection type set to none + IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); + rb.Push(RESULT_SUCCESS); + rb.Push(0); // Connection type set to none LOG_WARNING(Service_AC, "(STUBBED) called"); } -void GetInfraPriority(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::GetInfraPriority(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x27, 0, 2); + VAddr ac_config = rp.PopStaticBuffer(); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = 0; // Infra Priority, default 0 + IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); + rb.Push(RESULT_SUCCESS); + rb.Push(0); // Infra Priority, default 0 LOG_WARNING(Service_AC, "(STUBBED) called"); } -void SetRequestEulaVersion(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::SetRequestEulaVersion(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x2D, 2, 2); - u32 major = cmd_buff[1] & 0xFF; - u32 minor = cmd_buff[2] & 0xFF; + u32 major = rp.Pop(); + u32 minor = rp.Pop(); - ASSERT_MSG(cmd_buff[3] == (sizeof(ACConfig) << 14 | 2), - "Input buffer size not equal ACConfig size"); - ASSERT_MSG(cmd_buff[64] == (sizeof(ACConfig) << 14 | 2), - "Output buffer size not equal ACConfig size"); + VAddr ac_config = rp.PopStaticBuffer(); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = 0; // Infra Priority + // TODO(Subv): Copy over the input ACConfig to the stored ACConfig. + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); + rb.Push(RESULT_SUCCESS); + rb.PushStaticBuffer(ac_config, sizeof(ACConfig), 0); LOG_WARNING(Service_AC, "(STUBBED) called, major=%u, minor=%u", major, minor); } -void RegisterDisconnectEvent(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::RegisterDisconnectEvent(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x30, 0, 4); + rp.Skip(2, false); // ProcessId descriptor - disconnect_event = Kernel::g_handle_table.Get(cmd_buff[4]); - if (disconnect_event) { - disconnect_event->name = "AC:disconnect_event"; + ac->disconnect_event = rp.PopObject(); + if (ac->disconnect_event) { + ac->disconnect_event->name = "AC:disconnect_event"; } - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_AC, "(STUBBED) called"); } -void IsConnected(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::IsConnected(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x3E, 1, 2); + u32 unk = rp.Pop(); + u32 unk_descriptor = rp.Pop(); + u32 unk_param = rp.Pop(); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = ac_connected; + IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); + rb.Push(RESULT_SUCCESS); + rb.Push(ac->ac_connected); - LOG_WARNING(Service_AC, "(STUBBED) called"); + LOG_WARNING(Service_AC, "(STUBBED) called unk=%08X descriptor=%08X param=%08X", unk, + unk_descriptor, unk_param); } -void SetClientVersion(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); +void Module::Interface::SetClientVersion(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x40, 1, 2); - const u32 version = cmd_buff[1]; - self->SetVersion(version); + u32 version = rp.Pop(); + rp.Skip(2, false); // ProcessId descriptor LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x%08X", version); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); } -void Init() { - AddService(new AC_I); - AddService(new AC_U); +Module::Interface::Interface(std::shared_ptr ac, const char* name, u32 max_session) + : ac(std::move(ac)), ServiceFramework(name, max_session) {} - ac_connected = false; - - close_event = nullptr; - connect_event = nullptr; - disconnect_event = nullptr; -} - -void Shutdown() { - ac_connected = false; - - close_event = nullptr; - connect_event = nullptr; - disconnect_event = nullptr; +void InstallInterfaces(SM::ServiceManager& service_manager) { + auto ac = std::make_shared(); + std::make_shared(ac)->InstallAsService(service_manager); + std::make_shared(ac)->InstallAsService(service_manager); } } // namespace AC diff --git a/src/core/hle/service/ac/ac.h b/src/core/hle/service/ac/ac.h index 6185faf9b..1990a67ae 100644 --- a/src/core/hle/service/ac/ac.h +++ b/src/core/hle/service/ac/ac.h @@ -4,131 +4,156 @@ #pragma once +#include +#include +#include "core/hle/kernel/kernel.h" +#include "core/hle/service/service.h" + +namespace Kernel { +class Event; +} + namespace Service { - -class Interface; - namespace AC { +class Module final { +public: + class Interface : public ServiceFramework { + public: + Interface(std::shared_ptr ac, const char* name, u32 max_session); -/** - * AC::CreateDefaultConfig service function - * Inputs: - * 64 : ACConfig size << 14 | 2 - * 65 : pointer to ACConfig struct - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void CreateDefaultConfig(Interface* self); + /** + * AC::CreateDefaultConfig service function + * Inputs: + * 64 : ACConfig size << 14 | 2 + * 65 : pointer to ACConfig struct + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void CreateDefaultConfig(Kernel::HLERequestContext& ctx); -/** - * AC::ConnectAsync service function - * Inputs: - * 1 : ProcessId Header - * 3 : Copy Handle Header - * 4 : Connection Event handle - * 5 : ACConfig size << 14 | 2 - * 6 : pointer to ACConfig struct - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void ConnectAsync(Interface* self); + /** + * AC::ConnectAsync service function + * Inputs: + * 1 : ProcessId Header + * 3 : Copy Handle Header + * 4 : Connection Event handle + * 5 : ACConfig size << 14 | 2 + * 6 : pointer to ACConfig struct + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void ConnectAsync(Kernel::HLERequestContext& ctx); -/** - * AC::GetConnectResult service function - * Inputs: - * 1 : ProcessId Header - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void GetConnectResult(Interface* self); + /** + * AC::GetConnectResult service function + * Inputs: + * 1 : ProcessId Header + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void GetConnectResult(Kernel::HLERequestContext& ctx); -/** - * AC::CloseAsync service function - * Inputs: - * 1 : ProcessId Header - * 3 : Copy Handle Header - * 4 : Event handle, should be signaled when AC connection is closed - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void CloseAsync(Interface* self); + /** + * AC::CloseAsync service function + * Inputs: + * 1 : ProcessId Header + * 3 : Copy Handle Header + * 4 : Event handle, should be signaled when AC connection is closed + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void CloseAsync(Kernel::HLERequestContext& ctx); -/** - * AC::GetCloseResult service function - * Inputs: - * 1 : ProcessId Header - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void GetCloseResult(Interface* self); + /** + * AC::GetCloseResult service function + * Inputs: + * 1 : ProcessId Header + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void GetCloseResult(Kernel::HLERequestContext& ctx); -/** - * AC::GetWifiStatus service function - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - * 2 : Output connection type, 0 = none, 1 = Old3DS Internet, 2 = New3DS Internet. - */ -void GetWifiStatus(Interface* self); + /** + * AC::GetWifiStatus service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Output connection type, 0 = none, 1 = Old3DS Internet, 2 = New3DS Internet. + */ + void GetWifiStatus(Kernel::HLERequestContext& ctx); -/** - * AC::GetInfraPriority service function - * Inputs: - * 1 : ACConfig size << 14 | 2 - * 2 : pointer to ACConfig struct - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - * 2 : Infra Priority - */ -void GetInfraPriority(Interface* self); + /** + * AC::GetInfraPriority service function + * Inputs: + * 1 : ACConfig size << 14 | 2 + * 2 : pointer to ACConfig struct + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Infra Priority + */ + void GetInfraPriority(Kernel::HLERequestContext& ctx); -/** - * AC::SetRequestEulaVersion service function - * Inputs: - * 1 : Eula Version major - * 2 : Eula Version minor - * 3 : ACConfig size << 14 | 2 - * 4 : Input pointer to ACConfig struct - * 64 : ACConfig size << 14 | 2 - * 65 : Output pointer to ACConfig struct - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - * 2 : Infra Priority - */ -void SetRequestEulaVersion(Interface* self); + /** + * AC::SetRequestEulaVersion service function + * Inputs: + * 1 : Eula Version major + * 2 : Eula Version minor + * 3 : ACConfig size << 14 | 2 + * 4 : Input pointer to ACConfig struct + * 64 : ACConfig size << 14 | 2 + * 65 : Output pointer to ACConfig struct + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Infra Priority + */ + void SetRequestEulaVersion(Kernel::HLERequestContext& ctx); -/** - * AC::RegisterDisconnectEvent service function - * Inputs: - * 1 : ProcessId Header - * 3 : Copy Handle Header - * 4 : Event handle, should be signaled when AC connection is closed - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void RegisterDisconnectEvent(Interface* self); + /** + * AC::RegisterDisconnectEvent service function + * Inputs: + * 1 : ProcessId Header + * 3 : Copy Handle Header + * 4 : Event handle, should be signaled when AC connection is closed + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void RegisterDisconnectEvent(Kernel::HLERequestContext& ctx); -/** - * AC::IsConnected service function - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - * 2 : bool, is connected - */ -void IsConnected(Interface* self); + /** + * AC::IsConnected service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : bool, is connected + */ + void IsConnected(Kernel::HLERequestContext& ctx); -/** - * AC::SetClientVersion service function - * Inputs: - * 1 : Used SDK Version - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void SetClientVersion(Interface* self); + /** + * AC::SetClientVersion service function + * Inputs: + * 1 : Used SDK Version + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void SetClientVersion(Kernel::HLERequestContext& ctx); -/// Initialize AC service -void Init(); + protected: + std::shared_ptr ac; + }; -/// Shutdown AC service -void Shutdown(); +protected: + struct ACConfig { + std::array data; + }; + + ACConfig default_config{}; + + bool ac_connected = false; + + Kernel::SharedPtr close_event; + Kernel::SharedPtr connect_event; + Kernel::SharedPtr disconnect_event; +}; + +void InstallInterfaces(SM::ServiceManager& service_manager); } // namespace AC } // namespace Service diff --git a/src/core/hle/service/ac/ac_i.cpp b/src/core/hle/service/ac/ac_i.cpp index b22fe3698..c715bcdd0 100644 --- a/src/core/hle/service/ac/ac_i.cpp +++ b/src/core/hle/service/ac/ac_i.cpp @@ -2,37 +2,36 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/service/ac/ac.h" #include "core/hle/service/ac/ac_i.h" namespace Service { namespace AC { -const Interface::FunctionInfo FunctionTable[] = { - {0x00010000, CreateDefaultConfig, "CreateDefaultConfig"}, - {0x00040006, ConnectAsync, "ConnectAsync"}, - {0x00050002, GetConnectResult, "GetConnectResult"}, - {0x00070002, nullptr, "CancelConnectAsync"}, - {0x00080004, CloseAsync, "CloseAsync"}, - {0x00090002, GetCloseResult, "GetCloseResult"}, - {0x000A0000, nullptr, "GetLastErrorCode"}, - {0x000C0000, nullptr, "GetStatus"}, - {0x000D0000, GetWifiStatus, "GetWifiStatus"}, - {0x000E0042, nullptr, "GetCurrentAPInfo"}, - {0x00100042, nullptr, "GetCurrentNZoneInfo"}, - {0x00110042, nullptr, "GetNZoneApNumService"}, - {0x001D0042, nullptr, "ScanAPs"}, - {0x00240042, nullptr, "AddDenyApType"}, - {0x00270002, GetInfraPriority, "GetInfraPriority"}, - {0x002D0082, SetRequestEulaVersion, "SetRequestEulaVersion"}, - {0x00300004, RegisterDisconnectEvent, "RegisterDisconnectEvent"}, - {0x003C0042, nullptr, "GetAPSSIDList"}, - {0x003E0042, IsConnected, "IsConnected"}, - {0x00400042, SetClientVersion, "SetClientVersion"}, -}; - -AC_I::AC_I() { - Register(FunctionTable); +// TODO(Subv): Find out the correct number of concurrent sessions allowed +AC_I::AC_I(std::shared_ptr ac) : Module::Interface(std::move(ac), "ac:i", 1) { + static const FunctionInfo functions[] = { + {0x00010000, &AC_I::CreateDefaultConfig, "CreateDefaultConfig"}, + {0x00040006, &AC_I::ConnectAsync, "ConnectAsync"}, + {0x00050002, &AC_I::GetConnectResult, "GetConnectResult"}, + {0x00070002, nullptr, "CancelConnectAsync"}, + {0x00080004, &AC_I::CloseAsync, "CloseAsync"}, + {0x00090002, &AC_I::GetCloseResult, "GetCloseResult"}, + {0x000A0000, nullptr, "GetLastErrorCode"}, + {0x000C0000, nullptr, "GetStatus"}, + {0x000D0000, &AC_I::GetWifiStatus, "GetWifiStatus"}, + {0x000E0042, nullptr, "GetCurrentAPInfo"}, + {0x00100042, nullptr, "GetCurrentNZoneInfo"}, + {0x00110042, nullptr, "GetNZoneApNumService"}, + {0x001D0042, nullptr, "ScanAPs"}, + {0x00240042, nullptr, "AddDenyApType"}, + {0x00270002, &AC_I::GetInfraPriority, "GetInfraPriority"}, + {0x002D0082, &AC_I::SetRequestEulaVersion, "SetRequestEulaVersion"}, + {0x00300004, &AC_I::RegisterDisconnectEvent, "RegisterDisconnectEvent"}, + {0x003C0042, nullptr, "GetAPSSIDList"}, + {0x003E0042, &AC_I::IsConnected, "IsConnected"}, + {0x00400042, &AC_I::SetClientVersion, "SetClientVersion"}, + }; + RegisterHandlers(functions); } } // namespace AC diff --git a/src/core/hle/service/ac/ac_i.h b/src/core/hle/service/ac/ac_i.h index 465bba59c..c6f9d6d49 100644 --- a/src/core/hle/service/ac/ac_i.h +++ b/src/core/hle/service/ac/ac_i.h @@ -4,18 +4,15 @@ #pragma once -#include "core/hle/service/service.h" +#include +#include "core/hle/service/ac/ac.h" namespace Service { namespace AC { -class AC_I final : public Interface { +class AC_I final : public Module::Interface { public: - AC_I(); - - std::string GetPortName() const override { - return "ac:i"; - } + explicit AC_I(std::shared_ptr ac); }; } // namespace AC diff --git a/src/core/hle/service/ac/ac_u.cpp b/src/core/hle/service/ac/ac_u.cpp index 346671b4a..988f27b9d 100644 --- a/src/core/hle/service/ac/ac_u.cpp +++ b/src/core/hle/service/ac/ac_u.cpp @@ -2,37 +2,36 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/service/ac/ac.h" #include "core/hle/service/ac/ac_u.h" namespace Service { namespace AC { -const Interface::FunctionInfo FunctionTable[] = { - {0x00010000, CreateDefaultConfig, "CreateDefaultConfig"}, - {0x00040006, ConnectAsync, "ConnectAsync"}, - {0x00050002, GetConnectResult, "GetConnectResult"}, - {0x00070002, nullptr, "CancelConnectAsync"}, - {0x00080004, CloseAsync, "CloseAsync"}, - {0x00090002, GetCloseResult, "GetCloseResult"}, - {0x000A0000, nullptr, "GetLastErrorCode"}, - {0x000C0000, nullptr, "GetStatus"}, - {0x000D0000, GetWifiStatus, "GetWifiStatus"}, - {0x000E0042, nullptr, "GetCurrentAPInfo"}, - {0x00100042, nullptr, "GetCurrentNZoneInfo"}, - {0x00110042, nullptr, "GetNZoneApNumService"}, - {0x001D0042, nullptr, "ScanAPs"}, - {0x00240042, nullptr, "AddDenyApType"}, - {0x00270002, GetInfraPriority, "GetInfraPriority"}, - {0x002D0082, SetRequestEulaVersion, "SetRequestEulaVersion"}, - {0x00300004, RegisterDisconnectEvent, "RegisterDisconnectEvent"}, - {0x003C0042, nullptr, "GetAPSSIDList"}, - {0x003E0042, IsConnected, "IsConnected"}, - {0x00400042, SetClientVersion, "SetClientVersion"}, -}; - -AC_U::AC_U() { - Register(FunctionTable); +// TODO(Subv): Find out the correct number of concurrent sessions allowed +AC_U::AC_U(std::shared_ptr ac) : Module::Interface(std::move(ac), "ac:u", 1) { + static const FunctionInfo functions[] = { + {0x00010000, &AC_U::CreateDefaultConfig, "CreateDefaultConfig"}, + {0x00040006, &AC_U::ConnectAsync, "ConnectAsync"}, + {0x00050002, &AC_U::GetConnectResult, "GetConnectResult"}, + {0x00070002, nullptr, "CancelConnectAsync"}, + {0x00080004, &AC_U::CloseAsync, "CloseAsync"}, + {0x00090002, &AC_U::GetCloseResult, "GetCloseResult"}, + {0x000A0000, nullptr, "GetLastErrorCode"}, + {0x000C0000, nullptr, "GetStatus"}, + {0x000D0000, &AC_U::GetWifiStatus, "GetWifiStatus"}, + {0x000E0042, nullptr, "GetCurrentAPInfo"}, + {0x00100042, nullptr, "GetCurrentNZoneInfo"}, + {0x00110042, nullptr, "GetNZoneApNumService"}, + {0x001D0042, nullptr, "ScanAPs"}, + {0x00240042, nullptr, "AddDenyApType"}, + {0x00270002, &AC_U::GetInfraPriority, "GetInfraPriority"}, + {0x002D0082, &AC_U::SetRequestEulaVersion, "SetRequestEulaVersion"}, + {0x00300004, &AC_U::RegisterDisconnectEvent, "RegisterDisconnectEvent"}, + {0x003C0042, nullptr, "GetAPSSIDList"}, + {0x003E0042, &AC_U::IsConnected, "IsConnected"}, + {0x00400042, &AC_U::SetClientVersion, "SetClientVersion"}, + }; + RegisterHandlers(functions); } } // namespace AC diff --git a/src/core/hle/service/ac/ac_u.h b/src/core/hle/service/ac/ac_u.h index f9d21e112..6643f3ce5 100644 --- a/src/core/hle/service/ac/ac_u.h +++ b/src/core/hle/service/ac/ac_u.h @@ -4,18 +4,15 @@ #pragma once -#include "core/hle/service/service.h" +#include +#include "core/hle/service/ac/ac.h" namespace Service { namespace AC { -class AC_U final : public Interface { +class AC_U final : public Module::Interface { public: - AC_U(); - - std::string GetPortName() const override { - return "ac:u"; - } + explicit AC_U(std::shared_ptr ac); }; } // namespace AC diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index f267aad74..8fc801b77 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -216,11 +216,11 @@ void Init() { SM::ServiceManager::InstallInterfaces(SM::g_service_manager); NS::InstallInterfaces(*SM::g_service_manager); + AC::InstallInterfaces(*SM::g_service_manager); AddNamedPort(new ERR::ERR_F); FS::ArchiveInit(); - AC::Init(); ACT::Init(); AM::Init(); APT::Init(); @@ -273,7 +273,6 @@ void Shutdown() { BOSS::Shutdown(); APT::Shutdown(); AM::Shutdown(); - AC::Shutdown(); FS::ArchiveShutdown(); SM::g_service_manager = nullptr;