From bc3fc279670c3ebb448c0933324f6f1b146b6dbb Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 27 Sep 2026 03:54:09 +0000 Subject: [PATCH] 2026-09-27 03:54:09 Signed-off-by: lizzie --- src/core/CMakeLists.txt | 26 -- src/core/hle/service/am/am.cpp | 119 ++++++- .../am/service/applet_common_functions.cpp | 98 ------ .../am/service/applet_common_functions.h | 34 -- .../service/am/service/debug_functions.cpp | 17 - .../hle/service/am/service/debug_functions.h | 48 --- src/core/hle/service/am/service/storage.cpp | 64 +++- .../service/am/service/storage_accessor.cpp | 75 ---- .../hle/service/am/service/storage_accessor.h | 43 --- src/core/hle/service/caps/caps.cpp | 200 ++++++++++- src/core/hle/service/caps/caps_a.cpp | 211 ------------ src/core/hle/service/caps/caps_a.h | 64 ---- src/core/hle/service/friend/friend.cpp | 16 +- .../hle/service/friend/friend_interface.cpp | 17 - .../hle/service/friend/friend_interface.h | 28 -- src/core/hle/service/ldn/ldn.cpp | 31 +- src/core/hle/service/ldn/sf_service.cpp | 16 - src/core/hle/service/ldn/sf_service.h | 48 --- src/core/hle/service/psc/ovln/receiver.cpp | 117 ------- src/core/hle/service/psc/ovln/receiver.h | 47 --- .../hle/service/psc/ovln/receiver_service.cpp | 117 ++++++- src/core/hle/service/psc/ovln/sender.cpp | 35 -- src/core/hle/service/psc/ovln/sender.h | 26 -- .../hle/service/psc/ovln/sender_service.cpp | 34 +- src/core/hle/service/psc/pm_control.cpp | 16 - src/core/hle/service/psc/pm_control.h | 34 -- src/core/hle/service/psc/pm_module.cpp | 27 -- src/core/hle/service/psc/pm_module.h | 20 -- src/core/hle/service/psc/psc.cpp | 40 ++- src/core/hle/service/ro/ro.cpp | 323 +++++++++++++++++- src/core/hle/service/ro/ro_nro_utils.cpp | 185 ---------- src/core/hle/service/ro/ro_nro_utils.h | 26 -- src/core/hle/service/ro/ro_results.h | 29 -- src/core/hle/service/ro/ro_types.h | 142 -------- src/core/hle/service/sm/sm.cpp | 121 ++++++- src/core/hle/service/sm/sm_controller.cpp | 119 ------- src/core/hle/service/sm/sm_controller.h | 42 --- src/core/hle/service/usb/usb.cpp | 160 ++++----- src/core/hle/service/wlan/wlan.cpp | 280 +++++++-------- 39 files changed, 1260 insertions(+), 1835 deletions(-) delete mode 100644 src/core/hle/service/am/service/applet_common_functions.cpp delete mode 100644 src/core/hle/service/am/service/applet_common_functions.h delete mode 100644 src/core/hle/service/am/service/debug_functions.cpp delete mode 100644 src/core/hle/service/am/service/debug_functions.h delete mode 100644 src/core/hle/service/am/service/storage_accessor.cpp delete mode 100644 src/core/hle/service/am/service/storage_accessor.h delete mode 100644 src/core/hle/service/caps/caps_a.cpp delete mode 100644 src/core/hle/service/caps/caps_a.h delete mode 100644 src/core/hle/service/friend/friend_interface.cpp delete mode 100644 src/core/hle/service/friend/friend_interface.h delete mode 100644 src/core/hle/service/ldn/sf_service.cpp delete mode 100644 src/core/hle/service/ldn/sf_service.h delete mode 100644 src/core/hle/service/psc/ovln/receiver.cpp delete mode 100644 src/core/hle/service/psc/ovln/receiver.h delete mode 100644 src/core/hle/service/psc/ovln/sender.cpp delete mode 100644 src/core/hle/service/psc/ovln/sender.h delete mode 100644 src/core/hle/service/psc/pm_control.cpp delete mode 100644 src/core/hle/service/psc/pm_control.h delete mode 100644 src/core/hle/service/psc/pm_module.cpp delete mode 100644 src/core/hle/service/psc/pm_module.h delete mode 100644 src/core/hle/service/ro/ro_nro_utils.cpp delete mode 100644 src/core/hle/service/ro/ro_nro_utils.h delete mode 100644 src/core/hle/service/ro/ro_results.h delete mode 100644 src/core/hle/service/ro/ro_types.h delete mode 100644 src/core/hle/service/sm/sm_controller.cpp delete mode 100644 src/core/hle/service/sm/sm_controller.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index fd3e15ca23..f1d4bdae42 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -444,8 +444,6 @@ add_library(core STATIC hle/service/am/process_creation.h hle/service/am/process_holder.cpp hle/service/am/process_holder.h - hle/service/am/service/applet_common_functions.cpp - hle/service/am/service/applet_common_functions.h hle/service/am/service/application_accessor.cpp hle/service/am/service/application_accessor.h hle/service/am/service/application_creator.cpp @@ -458,8 +456,6 @@ add_library(core STATIC hle/service/am/service/common_state_getter.h hle/service/am/service/cradle_firmware_updater.cpp hle/service/am/service/cradle_firmware_updater.h - hle/service/am/service/debug_functions.cpp - hle/service/am/service/debug_functions.h hle/service/am/service/display_controller.cpp hle/service/am/service/display_controller.h hle/service/am/service/global_state_controller.cpp @@ -476,8 +472,6 @@ add_library(core STATIC hle/service/am/service/self_controller.h hle/service/am/service/storage.cpp hle/service/am/service/storage.h - hle/service/am/service/storage_accessor.cpp - hle/service/am/service/storage_accessor.h hle/service/am/service/window_controller.cpp hle/service/am/service/window_controller.h hle/service/am/window_system.cpp @@ -564,8 +558,6 @@ add_library(core STATIC hle/service/btm/btm.h hle/service/caps/caps.cpp hle/service/caps/caps.h - hle/service/caps/caps_a.cpp - hle/service/caps/caps_a.h hle/service/caps/caps_c.cpp hle/service/caps/caps_c.h hle/service/caps/caps_manager.cpp @@ -621,8 +613,6 @@ add_library(core STATIC hle/service/filesystem/save_data_controller.h hle/service/friend/friend.cpp hle/service/friend/friend.h - hle/service/friend/friend_interface.cpp - hle/service/friend/friend_interface.h hle/service/glue/arp.cpp hle/service/glue/arp.h hle/service/glue/bgtc.cpp @@ -691,8 +681,6 @@ add_library(core STATIC hle/service/ldn/monitor_service.h hle/service/ldn/sf_monitor_service.cpp hle/service/ldn/sf_monitor_service.h - hle/service/ldn/sf_service.cpp - hle/service/ldn/sf_service.h hle/service/ldn/sf_service_monitor.cpp hle/service/ldn/sf_service_monitor.h hle/service/ldn/system_local_communication_service.cpp @@ -921,16 +909,8 @@ add_library(core STATIC hle/service/psc/ovln/ovln_types.h hle/service/psc/ovln/receiver_service.cpp hle/service/psc/ovln/receiver_service.h - hle/service/psc/ovln/receiver.cpp - hle/service/psc/ovln/receiver.h hle/service/psc/ovln/sender_service.cpp hle/service/psc/ovln/sender_service.h - hle/service/psc/ovln/sender.cpp - hle/service/psc/ovln/sender.h - hle/service/psc/pm_control.cpp - hle/service/psc/pm_control.h - hle/service/psc/pm_module.cpp - hle/service/psc/pm_module.h hle/service/psc/psc.cpp hle/service/psc/psc.h hle/service/psc/time/alarms.cpp @@ -981,10 +961,6 @@ add_library(core STATIC hle/service/ptm/ts.h hle/service/ro/ro.cpp hle/service/ro/ro.h - hle/service/ro/ro_nro_utils.cpp - hle/service/ro/ro_nro_utils.h - hle/service/ro/ro_results.h - hle/service/ro/ro_types.h hle/service/server_manager.cpp hle/service/server_manager.h hle/service/service.cpp @@ -1013,8 +989,6 @@ add_library(core STATIC hle/service/set/system_settings_server.h hle/service/sm/sm.cpp hle/service/sm/sm.h - hle/service/sm/sm_controller.cpp - hle/service/sm/sm_controller.h hle/service/sockets/bsd.cpp hle/service/sockets/bsd.h hle/service/sockets/nsd.cpp diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index e4dc8de269..d0b12bb316 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -6,6 +6,7 @@ #include "common/settings.h" #include "core/core.h" +#include "core/file_sys/common_funcs.h" #include "core/file_sys/patch_manager.h" #include "core/file_sys/romfs_factory.h" #include "core/file_sys/control_metadata.h" @@ -17,11 +18,9 @@ #include "core/hle/service/am/am.h" #include "core/hle/service/am/button_poller.h" #include "core/hle/service/am/event_observer.h" -#include "core/hle/service/am/service/applet_common_functions.h" #include "core/hle/service/am/service/application_creator.h" #include "core/hle/service/am/service/audio_controller.h" #include "core/hle/service/am/service/common_state_getter.h" -#include "core/hle/service/am/service/debug_functions.h" #include "core/hle/service/am/service/display_controller.h" #include "core/hle/service/am/service/global_state_controller.h" #include "core/hle/service/am/service/home_menu_functions.h" @@ -62,6 +61,41 @@ class ISelfController; class IWindowController; class WindowSystem; +class IDebugFunctions final : public ServiceFramework { +public: + explicit IDebugFunctions(Core::System& system_) : ServiceFramework{system_, "IDebugFunctions"} {} + ~IDebugFunctions() override = default; + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "NotifyMessageToHomeMenuForDebug"}, + FunctionInfo{1, nullptr, "OpenMainApplication"}, + FunctionInfo{10, nullptr, "PerformSystemButtonPressing"}, + FunctionInfo{20, nullptr, "InvalidateTransitionLayer"}, + FunctionInfo{30, nullptr, "RequestLaunchApplicationWithUserAndArgumentForDebug"}, + FunctionInfo{31, nullptr, "RequestLaunchApplicationByApplicationLaunchInfoForDebug"}, + FunctionInfo{40, nullptr, "GetAppletResourceUsageInfo"}, + FunctionInfo{50, nullptr, "AddSystemProgramIdAndAppletIdForDebug"}, + FunctionInfo{51, nullptr, "AddOperationConfirmedLibraryAppletIdForDebug"}, + FunctionInfo{100, nullptr, "SetCpuBoostModeForApplet"}, + FunctionInfo{101, nullptr, "CancelCpuBoostModeForApplet"}, + FunctionInfo{110, nullptr, "PushToAppletBoundChannelForDebug"}, + FunctionInfo{111, nullptr, "TryPopFromAppletBoundChannelForDebug"}, + FunctionInfo{120, nullptr, "AlarmSettingNotificationEnableAppEventReserve"}, + FunctionInfo{121, nullptr, "AlarmSettingNotificationDisableAppEventReserve"}, + FunctionInfo{122, nullptr, "AlarmSettingNotificationPushAppEventNotify"}, + FunctionInfo{130, nullptr, "FriendInvitationSetApplicationParameter"}, + FunctionInfo{131, nullptr, "FriendInvitationClearApplicationParameter"}, + FunctionInfo{132, nullptr, "FriendInvitationPushApplicationParameter"}, + FunctionInfo{140, nullptr, "RestrictPowerOperationForSecureLaunchModeForDebug"}, + FunctionInfo{200, nullptr, "CreateFloatingLibraryAppletAccepterForDebug"}, + FunctionInfo{300, nullptr, "TerminateAllRunningApplicationsForDebug"}, + FunctionInfo{900, nullptr, "GetGrcProcessLaunchedSystemEvent"} + ); +}; + class IApplicationProxy final : public ServiceFramework { public: explicit IApplicationProxy(Core::System& system_, std::shared_ptr applet, @@ -193,6 +227,87 @@ public: WindowSystem& m_window_system; }; +class IAppletCommonFunctions final : public ServiceFramework { +public: + explicit IAppletCommonFunctions(Core::System& system_, std::shared_ptr applet_) : ServiceFramework{system_, "IAppletCommonFunctions"}, applet{std::move(applet_)} {} + ~IAppletCommonFunctions() override = default; + + Result SetHomeButtonDoubleClickEnabled( + bool home_button_double_click_enabled) { + LOG_WARNING(Service_AM, "(STUBBED) called, home_button_double_click_enabled={}", home_button_double_click_enabled); + R_SUCCEED(); + } + + Result GetHomeButtonDoubleClickEnabled( + Out out_home_button_double_click_enabled) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + *out_home_button_double_click_enabled = false; + R_SUCCEED(); + } + + Result SetDisplayMagnification(f32 x, f32 y, f32 width, f32 height) { + LOG_DEBUG(Service_AM, "(STUBBED) called, x={}, y={}, width={}, height={}", x, y, width, height); + std::scoped_lock lk{applet->lock}; + applet->display_magnification = Common::Rectangle{x, y, x + width, y + height}; + R_SUCCEED(); + } + + Result SetCpuBoostRequestPriority(s32 priority) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + std::scoped_lock lk{applet->lock}; + applet->cpu_boost_request_priority = priority; + R_SUCCEED(); + } + + Result GetCurrentApplicationId(Out out_application_id) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + *out_application_id = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID()); + R_SUCCEED(); + } + + Result SetGpuTimeSliceBoost(s64 time_span) { + LOG_WARNING(Service_AM, "(STUBBED) called, time_span={}", time_span); + R_SUCCEED(); + } + + Result Unknown350(Out out_unknown) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + *out_unknown = 0; + R_SUCCEED(); + } + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "SetTerminateResult"}, + FunctionInfo{10, nullptr, "ReadThemeStorage"}, + FunctionInfo{11, nullptr, "WriteThemeStorage"}, + FunctionInfo{20, nullptr, "PushToAppletBoundChannel"}, + FunctionInfo{21, nullptr, "TryPopFromAppletBoundChannel"}, + FunctionInfo{40, nullptr, "GetDisplayLogicalResolution"}, + FunctionInfo{42, D<&IAppletCommonFunctions::SetDisplayMagnification>, "SetDisplayMagnification"}, + FunctionInfo{50, D<&IAppletCommonFunctions::SetHomeButtonDoubleClickEnabled>, "SetHomeButtonDoubleClickEnabled"}, + FunctionInfo{51, D<&IAppletCommonFunctions::GetHomeButtonDoubleClickEnabled>, "GetHomeButtonDoubleClickEnabled"}, + FunctionInfo{52, nullptr, "IsHomeButtonShortPressedBlocked"}, + FunctionInfo{60, nullptr, "IsVrModeCurtainRequired"}, + FunctionInfo{61, nullptr, "IsSleepRequiredByHighTemperature"}, + FunctionInfo{62, nullptr, "IsSleepRequiredByLowBattery"}, + FunctionInfo{70, D<&IAppletCommonFunctions::SetCpuBoostRequestPriority>, "SetCpuBoostRequestPriority"}, + FunctionInfo{80, nullptr, "SetHandlingCaptureButtonShortPressedMessageEnabledForApplet"}, + FunctionInfo{81, nullptr, "SetHandlingCaptureButtonLongPressedMessageEnabledForApplet"}, + FunctionInfo{90, nullptr, "OpenNamedChannelAsParent"}, + FunctionInfo{91, nullptr, "OpenNamedChannelAsChild"}, + FunctionInfo{100, nullptr, "SetApplicationCoreUsageMode"}, + FunctionInfo{300, D<&IAppletCommonFunctions::GetCurrentApplicationId>, "GetCurrentApplicationId"}, + FunctionInfo{310, nullptr, "IsSystemAppletHomeMenu"}, //19.0.0+ + FunctionInfo{320, D<&IAppletCommonFunctions::SetGpuTimeSliceBoost>, "SetGpuTimeSliceBoost"}, //19.0.0+ + FunctionInfo{321, nullptr, "SetGpuTimeSliceBoostDueToApplication"}, //19.0.0+ + FunctionInfo{350, D<&IAppletCommonFunctions::Unknown350>, "Unknown350"} //20.0.0+ + ); + const std::shared_ptr applet; +}; + class ISystemAppletProxy final : public ServiceFramework { public: explicit ISystemAppletProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) diff --git a/src/core/hle/service/am/service/applet_common_functions.cpp b/src/core/hle/service/am/service/applet_common_functions.cpp deleted file mode 100644 index e7bd7cb383..0000000000 --- a/src/core/hle/service/am/service/applet_common_functions.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/core.h" -#include "core/file_sys/common_funcs.h" -#include "core/hle/service/am/applet.h" -#include "core/hle/service/am/service/applet_common_functions.h" -#include "core/hle/service/cmif_serialization.h" - -namespace Service::AM { - -std::optional IAppletCommonFunctions::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "SetTerminateResult"}, - FunctionInfo{10, nullptr, "ReadThemeStorage"}, - FunctionInfo{11, nullptr, "WriteThemeStorage"}, - FunctionInfo{20, nullptr, "PushToAppletBoundChannel"}, - FunctionInfo{21, nullptr, "TryPopFromAppletBoundChannel"}, - FunctionInfo{40, nullptr, "GetDisplayLogicalResolution"}, - FunctionInfo{42, D<&IAppletCommonFunctions::SetDisplayMagnification>, "SetDisplayMagnification"}, - FunctionInfo{50, D<&IAppletCommonFunctions::SetHomeButtonDoubleClickEnabled>, "SetHomeButtonDoubleClickEnabled"}, - FunctionInfo{51, D<&IAppletCommonFunctions::GetHomeButtonDoubleClickEnabled>, "GetHomeButtonDoubleClickEnabled"}, - FunctionInfo{52, nullptr, "IsHomeButtonShortPressedBlocked"}, - FunctionInfo{60, nullptr, "IsVrModeCurtainRequired"}, - FunctionInfo{61, nullptr, "IsSleepRequiredByHighTemperature"}, - FunctionInfo{62, nullptr, "IsSleepRequiredByLowBattery"}, - FunctionInfo{70, D<&IAppletCommonFunctions::SetCpuBoostRequestPriority>, "SetCpuBoostRequestPriority"}, - FunctionInfo{80, nullptr, "SetHandlingCaptureButtonShortPressedMessageEnabledForApplet"}, - FunctionInfo{81, nullptr, "SetHandlingCaptureButtonLongPressedMessageEnabledForApplet"}, - FunctionInfo{90, nullptr, "OpenNamedChannelAsParent"}, - FunctionInfo{91, nullptr, "OpenNamedChannelAsChild"}, - FunctionInfo{100, nullptr, "SetApplicationCoreUsageMode"}, - FunctionInfo{300, D<&IAppletCommonFunctions::GetCurrentApplicationId>, "GetCurrentApplicationId"}, - FunctionInfo{310, nullptr, "IsSystemAppletHomeMenu"}, //19.0.0+ - FunctionInfo{320, D<&IAppletCommonFunctions::SetGpuTimeSliceBoost>, "SetGpuTimeSliceBoost"}, //19.0.0+ - FunctionInfo{321, nullptr, "SetGpuTimeSliceBoostDueToApplication"}, //19.0.0+ - FunctionInfo{350, D<&IAppletCommonFunctions::Unknown350>, "Unknown350"} //20.0.0+ - ); - return HandlerTableGenerateWithFind(key, functions); -} - -IAppletCommonFunctions::IAppletCommonFunctions(Core::System& system_, - std::shared_ptr applet_) - : ServiceFramework{system_, "IAppletCommonFunctions"}, applet{std::move(applet_)} { -} - -IAppletCommonFunctions::~IAppletCommonFunctions() = default; - -Result IAppletCommonFunctions::SetHomeButtonDoubleClickEnabled( - bool home_button_double_click_enabled) { - LOG_WARNING(Service_AM, "(STUBBED) called, home_button_double_click_enabled={}", - home_button_double_click_enabled); - R_SUCCEED(); -} - -Result IAppletCommonFunctions::GetHomeButtonDoubleClickEnabled( - Out out_home_button_double_click_enabled) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - *out_home_button_double_click_enabled = false; - R_SUCCEED(); -} - -Result IAppletCommonFunctions::SetDisplayMagnification(f32 x, f32 y, f32 width, f32 height) { - LOG_DEBUG(Service_AM, "(STUBBED) called, x={}, y={}, width={}, height={}", x, y, width, - height); - std::scoped_lock lk{applet->lock}; - applet->display_magnification = Common::Rectangle{x, y, x + width, y + height}; - R_SUCCEED(); -} - -Result IAppletCommonFunctions::SetCpuBoostRequestPriority(s32 priority) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - std::scoped_lock lk{applet->lock}; - applet->cpu_boost_request_priority = priority; - R_SUCCEED(); -} - -Result IAppletCommonFunctions::GetCurrentApplicationId(Out out_application_id) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - *out_application_id = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID()); - R_SUCCEED(); -} - -Result IAppletCommonFunctions::SetGpuTimeSliceBoost(s64 time_span) { - LOG_WARNING(Service_AM, "(STUBBED) called, time_span={}", time_span); - R_SUCCEED(); -} - -Result IAppletCommonFunctions::Unknown350(Out out_unknown) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - *out_unknown = 0; - R_SUCCEED(); -} - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/applet_common_functions.h b/src/core/hle/service/am/service/applet_common_functions.h deleted file mode 100644 index 9d2f24fe22..0000000000 --- a/src/core/hle/service/am/service/applet_common_functions.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/cmif_types.h" -#include "core/hle/service/service.h" - -namespace Service::AM { - -struct Applet; - -class IAppletCommonFunctions final : public ServiceFramework { -public: - explicit IAppletCommonFunctions(Core::System& system_, std::shared_ptr applet_); - ~IAppletCommonFunctions() override; - -private: - Result SetHomeButtonDoubleClickEnabled(bool home_button_double_click_enabled); - Result GetHomeButtonDoubleClickEnabled(Out out_home_button_double_click_enabled); - Result SetDisplayMagnification(f32 x, f32 y, f32 width, f32 height); - Result SetCpuBoostRequestPriority(s32 priority); - Result GetCurrentApplicationId(Out out_application_id); - Result SetGpuTimeSliceBoost(s64 time_span); - Result Unknown350(Out out_unknown); - - std::optional FindRequest(u32 key) override; - const std::shared_ptr applet; -}; - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/debug_functions.cpp b/src/core/hle/service/am/service/debug_functions.cpp deleted file mode 100644 index 8d6892c24c..0000000000 --- a/src/core/hle/service/am/service/debug_functions.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/am/service/debug_functions.h" - -namespace Service::AM { - -IDebugFunctions::IDebugFunctions(Core::System& system_) - : ServiceFramework{system_, "IDebugFunctions"} { -} - -IDebugFunctions::~IDebugFunctions() = default; - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/debug_functions.h b/src/core/hle/service/am/service/debug_functions.h deleted file mode 100644 index 19cb3a5241..0000000000 --- a/src/core/hle/service/am/service/debug_functions.h +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/service.h" - -namespace Service::AM { - -class IDebugFunctions final : public ServiceFramework { -public: - explicit IDebugFunctions(Core::System& system_); - ~IDebugFunctions() override; - - std::optional FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "NotifyMessageToHomeMenuForDebug"}, - FunctionInfo{1, nullptr, "OpenMainApplication"}, - FunctionInfo{10, nullptr, "PerformSystemButtonPressing"}, - FunctionInfo{20, nullptr, "InvalidateTransitionLayer"}, - FunctionInfo{30, nullptr, "RequestLaunchApplicationWithUserAndArgumentForDebug"}, - FunctionInfo{31, nullptr, "RequestLaunchApplicationByApplicationLaunchInfoForDebug"}, - FunctionInfo{40, nullptr, "GetAppletResourceUsageInfo"}, - FunctionInfo{50, nullptr, "AddSystemProgramIdAndAppletIdForDebug"}, - FunctionInfo{51, nullptr, "AddOperationConfirmedLibraryAppletIdForDebug"}, - FunctionInfo{100, nullptr, "SetCpuBoostModeForApplet"}, - FunctionInfo{101, nullptr, "CancelCpuBoostModeForApplet"}, - FunctionInfo{110, nullptr, "PushToAppletBoundChannelForDebug"}, - FunctionInfo{111, nullptr, "TryPopFromAppletBoundChannelForDebug"}, - FunctionInfo{120, nullptr, "AlarmSettingNotificationEnableAppEventReserve"}, - FunctionInfo{121, nullptr, "AlarmSettingNotificationDisableAppEventReserve"}, - FunctionInfo{122, nullptr, "AlarmSettingNotificationPushAppEventNotify"}, - FunctionInfo{130, nullptr, "FriendInvitationSetApplicationParameter"}, - FunctionInfo{131, nullptr, "FriendInvitationClearApplicationParameter"}, - FunctionInfo{132, nullptr, "FriendInvitationPushApplicationParameter"}, - FunctionInfo{140, nullptr, "RestrictPowerOperationForSecureLaunchModeForDebug"}, - FunctionInfo{200, nullptr, "CreateFloatingLibraryAppletAccepterForDebug"}, - FunctionInfo{300, nullptr, "TerminateAllRunningApplicationsForDebug"}, - FunctionInfo{900, nullptr, "GetGrcProcessLaunchedSystemEvent"} - ); -}; - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/storage.cpp b/src/core/hle/service/am/service/storage.cpp index a867cda6e2..110a9f5a42 100644 --- a/src/core/hle/service/am/service/storage.cpp +++ b/src/core/hle/service/am/service/storage.cpp @@ -4,14 +4,76 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/kernel/k_transfer_memory.h" #include "core/hle/service/am/am_results.h" #include "core/hle/service/am/library_applet_storage.h" #include "core/hle/service/am/service/storage.h" -#include "core/hle/service/am/service/storage_accessor.h" #include "core/hle/service/cmif_serialization.h" namespace Service::AM { +class IStorageAccessor final : public ServiceFramework { +public: + explicit IStorageAccessor(Core::System& system_, std::shared_ptr impl) : ServiceFramework{system_, "IStorageAccessor"}, m_impl{std::move(impl)} {} + ~IStorageAccessor() override = default; + + Result GetSize(Out out_size) { + LOG_DEBUG(Service_AM, "called"); + *out_size = m_impl->GetSize(); + R_SUCCEED(); + } + + Result Write(InBuffer buffer, s64 offset) { + LOG_DEBUG(Service_AM, "called, offset={} size={}", offset, buffer.size()); + R_RETURN(m_impl->Write(offset, buffer.data(), buffer.size())); + } + + Result Read(OutBuffer out_buffer, s64 offset) { + LOG_DEBUG(Service_AM, "called, offset={} size={}", offset, out_buffer.size()); + R_RETURN(m_impl->Read(offset, out_buffer.data(), out_buffer.size())); + } + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&IStorageAccessor::GetSize>, "GetSize"}, + FunctionInfo{10, D<&IStorageAccessor::Write>, "Write"}, + FunctionInfo{11, D<&IStorageAccessor::Read>, "Read"} + ); + + const std::shared_ptr m_impl; +}; + +class ITransferStorageAccessor final : public ServiceFramework { +public: + explicit ITransferStorageAccessor(Core::System& system_, std::shared_ptr impl) : ServiceFramework{system_, "ITransferStorageAccessor"}, m_impl{std::move(impl)} {} + ~ITransferStorageAccessor() override = default; + + Result GetSize(Out out_size) { + LOG_DEBUG(Service_AM, "called"); + *out_size = m_impl->GetSize(); + R_SUCCEED(); + } + + Result GetHandle(Out out_size, OutCopyHandle out_handle) { + LOG_INFO(Service_AM, "called"); + *out_size = m_impl->GetSize(); + *out_handle = m_impl->GetHandle(); + R_SUCCEED(); + } + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&ITransferStorageAccessor::GetSize>, "GetSize"}, + FunctionInfo{1, D<&ITransferStorageAccessor::GetHandle>, "GetHandle"} + ); + + const std::shared_ptr m_impl; +}; + std::optional IStorage::FindRequest(u32 key) { static constexpr auto functions = CreateStaticMap( FunctionInfo{0, D<&IStorage::Open>, "Open"}, diff --git a/src/core/hle/service/am/service/storage_accessor.cpp b/src/core/hle/service/am/service/storage_accessor.cpp deleted file mode 100644 index 0d29222bd9..0000000000 --- a/src/core/hle/service/am/service/storage_accessor.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/kernel/k_transfer_memory.h" -#include "core/hle/service/am/library_applet_storage.h" -#include "core/hle/service/am/service/storage_accessor.h" -#include "core/hle/service/cmif_serialization.h" - -namespace Service::AM { - -std::optional IStorageAccessor::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, D<&IStorageAccessor::GetSize>, "GetSize"}, - FunctionInfo{10, D<&IStorageAccessor::Write>, "Write"}, - FunctionInfo{11, D<&IStorageAccessor::Read>, "Read"} - ); - return HandlerTableGenerateWithFind(key, functions); -} - -IStorageAccessor::IStorageAccessor(Core::System& system_, - std::shared_ptr impl) - : ServiceFramework{system_, "IStorageAccessor"}, m_impl{std::move(impl)} { -} - -IStorageAccessor::~IStorageAccessor() = default; - -Result IStorageAccessor::GetSize(Out out_size) { - LOG_DEBUG(Service_AM, "called"); - *out_size = m_impl->GetSize(); - R_SUCCEED(); -} - -Result IStorageAccessor::Write(InBuffer buffer, s64 offset) { - LOG_DEBUG(Service_AM, "called, offset={} size={}", offset, buffer.size()); - R_RETURN(m_impl->Write(offset, buffer.data(), buffer.size())); -} - -Result IStorageAccessor::Read(OutBuffer out_buffer, s64 offset) { - LOG_DEBUG(Service_AM, "called, offset={} size={}", offset, out_buffer.size()); - R_RETURN(m_impl->Read(offset, out_buffer.data(), out_buffer.size())); -} - -std::optional ITransferStorageAccessor::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, D<&ITransferStorageAccessor::GetSize>, "GetSize"}, - FunctionInfo{1, D<&ITransferStorageAccessor::GetHandle>, "GetHandle"} - ); - return HandlerTableGenerateWithFind(key, functions); -} - -ITransferStorageAccessor::ITransferStorageAccessor(Core::System& system_, - std::shared_ptr impl) - : ServiceFramework{system_, "ITransferStorageAccessor"}, m_impl{std::move(impl)} { -} - -ITransferStorageAccessor::~ITransferStorageAccessor() = default; - -Result ITransferStorageAccessor::GetSize(Out out_size) { - LOG_DEBUG(Service_AM, "called"); - *out_size = m_impl->GetSize(); - R_SUCCEED(); -} - -Result ITransferStorageAccessor::GetHandle(Out out_size, - OutCopyHandle out_handle) { - LOG_INFO(Service_AM, "called"); - *out_size = m_impl->GetSize(); - *out_handle = m_impl->GetHandle(); - R_SUCCEED(); -} - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/storage_accessor.h b/src/core/hle/service/am/service/storage_accessor.h deleted file mode 100644 index ee64e7a3ec..0000000000 --- a/src/core/hle/service/am/service/storage_accessor.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/am/library_applet_storage.h" -#include "core/hle/service/cmif_types.h" -#include "core/hle/service/service.h" - -namespace Service::AM { - -class IStorageAccessor final : public ServiceFramework { -public: - explicit IStorageAccessor(Core::System& system_, std::shared_ptr impl); - ~IStorageAccessor() override; - -private: - Result GetSize(Out out_size); - Result Write(InBuffer buffer, s64 offset); - Result Read(OutBuffer out_buffer, s64 offset); - - std::optional FindRequest(u32 key) override; - const std::shared_ptr m_impl; -}; - -class ITransferStorageAccessor final : public ServiceFramework { -public: - explicit ITransferStorageAccessor(Core::System& system_, - std::shared_ptr impl); - ~ITransferStorageAccessor() override; - -private: - Result GetSize(Out out_size); - Result GetHandle(Out out_size, OutCopyHandle out_handle); - - std::optional FindRequest(u32 key) override; - const std::shared_ptr m_impl; -}; - -} // namespace Service::AM diff --git a/src/core/hle/service/caps/caps.cpp b/src/core/hle/service/caps/caps.cpp index 505d1a7fee..6cc37999f3 100644 --- a/src/core/hle/service/caps/caps.cpp +++ b/src/core/hle/service/caps/caps.cpp @@ -5,7 +5,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/caps/caps.h" -#include "core/hle/service/caps/caps_a.h" #include "core/hle/service/caps/caps_c.h" #include "core/hle/service/caps/caps_manager.h" #include "core/hle/service/caps/caps_sc.h" @@ -14,7 +13,11 @@ #include "core/hle/service/caps/caps_u.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" +#include "common/logging.h" #include "frontend_common/firmware_manager.h" +#include "core/hle/service/caps/caps_result.h" +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Capture { @@ -32,6 +35,201 @@ public: } }; +class IAlbumAccessorService final : public ServiceFramework { +public: + explicit IAlbumAccessorService(Core::System& system_, std::shared_ptr album_manager) : ServiceFramework{system_, "caps:a"}, manager{album_manager} {} + ~IAlbumAccessorService() override = default; + + Result GetAlbumFileList( + Out out_count, AlbumStorage storage, + OutArray out_entries) { + LOG_INFO(Service_Capture, "called, storage={}", storage); + + const Result result = manager->GetAlbumFileList(out_entries, *out_count, storage, 0); + R_RETURN(TranslateResult(result)); + } + + Result DeleteAlbumFile(AlbumFileId file_id) { + LOG_INFO(Service_Capture, "called, application_id={:#0x}, storage={}, type={}", + file_id.application_id, file_id.storage, file_id.type); + + const Result result = manager->DeleteAlbumFile(file_id); + R_RETURN(TranslateResult(result)); + } + + Result IsAlbumMounted(Out out_is_mounted, AlbumStorage storage) { + LOG_INFO(Service_Capture, "called, storage={}", storage); + + const Result result = manager->IsAlbumMounted(storage); + *out_is_mounted = result.IsSuccess(); + R_RETURN(TranslateResult(result)); + } + + Result Unknown18( + Out out_buffer_size, + OutArray out_buffer) { + LOG_WARNING(Service_Capture, "(STUBBED) called"); + *out_buffer_size = 0; + R_SUCCEED(); + } + + Result GetAlbumFileListEx0( + Out out_entries_size, AlbumStorage storage, u8 flags, + OutArray out_entries) { + LOG_INFO(Service_Capture, "called, storage={}, flags={}", storage, flags); + + const Result result = manager->GetAlbumFileList(out_entries, *out_entries_size, storage, flags); + R_RETURN(TranslateResult(result)); + } + + Result GetAutoSavingStorage(Out out_is_autosaving) { + LOG_WARNING(Service_Capture, "(STUBBED) called"); + + const Result result = manager->GetAutoSavingStorage(*out_is_autosaving); + R_RETURN(TranslateResult(result)); + } + + Result LoadAlbumScreenShotImageEx1( + const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options, + OutLargeData out_image_output, + OutArray out_image, + OutArray out_buffer) { + LOG_INFO(Service_Capture, "called, application_id={:#0x}, storage={}, type={}, flags={}", + file_id.application_id, file_id.storage, file_id.type, decoder_options.flags); + + const Result result = + manager->LoadAlbumScreenShotImage(*out_image_output, out_image, file_id, decoder_options); + R_RETURN(TranslateResult(result)); + } + + Result LoadAlbumScreenShotThumbnailImageEx1( + const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options, + OutLargeData out_image_output, + OutArray out_image, + OutArray out_buffer) { + LOG_INFO(Service_Capture, "called, application_id={:#0x}, storage={}, type={}, flags={}", + file_id.application_id, file_id.storage, file_id.type, decoder_options.flags); + + const Result result = manager->LoadAlbumScreenShotThumbnail(*out_image_output, out_image, + file_id, decoder_options); + R_RETURN(TranslateResult(result)); + } + + Result TranslateResult(Result in_result) { + if (in_result.IsSuccess()) { + return in_result; + } + + if ((in_result.raw & 0x3801ff) == ResultUnknown1024.raw) { + if (in_result.GetDescription() - 0x514 < 100) { + return ResultInvalidFileData; + } + if (in_result.GetDescription() - 0x5dc < 100) { + return ResultInvalidFileData; + } + + if (in_result.GetDescription() - 0x578 < 100) { + if (in_result == ResultFileCountLimit) { + return ResultUnknown22; + } + return ResultUnknown25; + } + + if (in_result.raw < ResultUnknown1801.raw) { + if (in_result == ResultUnknown1202) { + return ResultUnknown810; + } + if (in_result == ResultUnknown1203) { + return ResultUnknown810; + } + if (in_result == ResultUnknown1701) { + return ResultUnknown5; + } + } else if (in_result.raw < ResultUnknown1803.raw) { + if (in_result == ResultUnknown1801) { + return ResultUnknown5; + } + if (in_result == ResultUnknown1802) { + return ResultUnknown6; + } + } else { + if (in_result == ResultUnknown1803) { + return ResultUnknown7; + } + if (in_result == ResultUnknown1804) { + return ResultOutOfRange; + } + } + return ResultUnknown1024; + } + + if (in_result.GetModule() == ErrorModule::FS) { + if ((in_result.GetDescription() >> 0xc < 0x7d) || + (in_result.GetDescription() - 1000 < 2000) || + (((in_result.GetDescription() - 3000) >> 3) < 0x271)) { + // TODO: Translate FS error + return in_result; + } + } + + return in_result; + } + + Result GetAlbumAccessResultForDebug(Out out_result) { + LOG_WARNING(Service_Capture, "(STUBBED) called"); + *out_result = ResultSuccess; + R_SUCCEED(); + } + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "GetAlbumFileCount"}, + FunctionInfo{1, C<&IAlbumAccessorService::GetAlbumFileList>, "GetAlbumFileList"}, + FunctionInfo{2, nullptr, "LoadAlbumFile"}, + FunctionInfo{3, C<&IAlbumAccessorService::DeleteAlbumFile>, "DeleteAlbumFile"}, + FunctionInfo{4, nullptr, "StorageCopyAlbumFile"}, + FunctionInfo{5, C<&IAlbumAccessorService::IsAlbumMounted>, "IsAlbumMounted"}, + FunctionInfo{6, nullptr, "GetAlbumUsage"}, + FunctionInfo{7, nullptr, "GetAlbumFileSize"}, + FunctionInfo{8, nullptr, "LoadAlbumFileThumbnail"}, + FunctionInfo{9, nullptr, "LoadAlbumScreenShotImage"}, + FunctionInfo{10, nullptr, "LoadAlbumScreenShotThumbnailImage"}, + FunctionInfo{11, nullptr, "GetAlbumEntryFromApplicationAlbumEntry"}, + FunctionInfo{12, nullptr, "LoadAlbumScreenShotImageEx"}, + FunctionInfo{13, nullptr, "LoadAlbumScreenShotThumbnailImageEx"}, + FunctionInfo{14, nullptr, "LoadAlbumScreenShotImageEx0"}, + FunctionInfo{15, nullptr, "GetAlbumUsage3"}, + FunctionInfo{16, nullptr, "GetAlbumMountResult"}, + FunctionInfo{17, nullptr, "GetAlbumUsage16"}, + FunctionInfo{18, C<&IAlbumAccessorService::Unknown18>, "Unknown18"}, + FunctionInfo{19, nullptr, "Unknown19"}, + FunctionInfo{100, nullptr, "GetAlbumFileCountEx0"}, + FunctionInfo{101, C<&IAlbumAccessorService::GetAlbumFileListEx0>, "GetAlbumFileListEx0"}, + FunctionInfo{202, nullptr, "SaveEditedScreenShot"}, + FunctionInfo{301, nullptr, "GetLastThumbnail"}, + FunctionInfo{302, nullptr, "GetLastOverlayMovieThumbnail"}, + FunctionInfo{401, C<&IAlbumAccessorService::GetAutoSavingStorage>, "GetAutoSavingStorage"}, + FunctionInfo{501, nullptr, "GetRequiredStorageSpaceSizeToCopyAll"}, + FunctionInfo{1001, nullptr, "LoadAlbumScreenShotThumbnailImageEx0"}, + FunctionInfo{1002, C<&IAlbumAccessorService::LoadAlbumScreenShotImageEx1>, "LoadAlbumScreenShotImageEx1"}, + FunctionInfo{1003, C<&IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1>, "LoadAlbumScreenShotThumbnailImageEx1"}, + FunctionInfo{8001, nullptr, "ForceAlbumUnmounted"}, + FunctionInfo{8002, nullptr, "ResetAlbumMountStatus"}, + FunctionInfo{8011, nullptr, "RefreshAlbumCache"}, + FunctionInfo{8012, nullptr, "GetAlbumCache"}, + FunctionInfo{8013, nullptr, "GetAlbumCacheEx"}, + FunctionInfo{8021, nullptr, "GetAlbumEntryFromApplicationAlbumEntryAruid"}, + FunctionInfo{10011, nullptr, "SetInternalErrorConversionEnabled"}, + FunctionInfo{50000, nullptr, "LoadMakerNoteInfoForDebug"}, + FunctionInfo{50011, C<&IAlbumAccessorService::GetAlbumAccessResultForDebug>, "GetAlbumAccessResultForDebug"}, + FunctionInfo{60002, nullptr, "OpenAccessorSession"} + ); + + std::shared_ptr manager = nullptr; +}; + void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); auto album_manager = std::make_shared(system); diff --git a/src/core/hle/service/caps/caps_a.cpp b/src/core/hle/service/caps/caps_a.cpp deleted file mode 100644 index 5b7f6b7996..0000000000 --- a/src/core/hle/service/caps/caps_a.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/logging.h" -#include "core/hle/service/caps/caps_a.h" -#include "core/hle/service/caps/caps_manager.h" -#include "core/hle/service/caps/caps_result.h" -#include "core/hle/service/cmif_serialization.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::Capture { - -std::optional IAlbumAccessorService::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "GetAlbumFileCount"}, - FunctionInfo{1, C<&IAlbumAccessorService::GetAlbumFileList>, "GetAlbumFileList"}, - FunctionInfo{2, nullptr, "LoadAlbumFile"}, - FunctionInfo{3, C<&IAlbumAccessorService::DeleteAlbumFile>, "DeleteAlbumFile"}, - FunctionInfo{4, nullptr, "StorageCopyAlbumFile"}, - FunctionInfo{5, C<&IAlbumAccessorService::IsAlbumMounted>, "IsAlbumMounted"}, - FunctionInfo{6, nullptr, "GetAlbumUsage"}, - FunctionInfo{7, nullptr, "GetAlbumFileSize"}, - FunctionInfo{8, nullptr, "LoadAlbumFileThumbnail"}, - FunctionInfo{9, nullptr, "LoadAlbumScreenShotImage"}, - FunctionInfo{10, nullptr, "LoadAlbumScreenShotThumbnailImage"}, - FunctionInfo{11, nullptr, "GetAlbumEntryFromApplicationAlbumEntry"}, - FunctionInfo{12, nullptr, "LoadAlbumScreenShotImageEx"}, - FunctionInfo{13, nullptr, "LoadAlbumScreenShotThumbnailImageEx"}, - FunctionInfo{14, nullptr, "LoadAlbumScreenShotImageEx0"}, - FunctionInfo{15, nullptr, "GetAlbumUsage3"}, - FunctionInfo{16, nullptr, "GetAlbumMountResult"}, - FunctionInfo{17, nullptr, "GetAlbumUsage16"}, - FunctionInfo{18, C<&IAlbumAccessorService::Unknown18>, "Unknown18"}, - FunctionInfo{19, nullptr, "Unknown19"}, - FunctionInfo{100, nullptr, "GetAlbumFileCountEx0"}, - FunctionInfo{101, C<&IAlbumAccessorService::GetAlbumFileListEx0>, "GetAlbumFileListEx0"}, - FunctionInfo{202, nullptr, "SaveEditedScreenShot"}, - FunctionInfo{301, nullptr, "GetLastThumbnail"}, - FunctionInfo{302, nullptr, "GetLastOverlayMovieThumbnail"}, - FunctionInfo{401, C<&IAlbumAccessorService::GetAutoSavingStorage>, "GetAutoSavingStorage"}, - FunctionInfo{501, nullptr, "GetRequiredStorageSpaceSizeToCopyAll"}, - FunctionInfo{1001, nullptr, "LoadAlbumScreenShotThumbnailImageEx0"}, - FunctionInfo{1002, C<&IAlbumAccessorService::LoadAlbumScreenShotImageEx1>, "LoadAlbumScreenShotImageEx1"}, - FunctionInfo{1003, C<&IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1>, "LoadAlbumScreenShotThumbnailImageEx1"}, - FunctionInfo{8001, nullptr, "ForceAlbumUnmounted"}, - FunctionInfo{8002, nullptr, "ResetAlbumMountStatus"}, - FunctionInfo{8011, nullptr, "RefreshAlbumCache"}, - FunctionInfo{8012, nullptr, "GetAlbumCache"}, - FunctionInfo{8013, nullptr, "GetAlbumCacheEx"}, - FunctionInfo{8021, nullptr, "GetAlbumEntryFromApplicationAlbumEntryAruid"}, - FunctionInfo{10011, nullptr, "SetInternalErrorConversionEnabled"}, - FunctionInfo{50000, nullptr, "LoadMakerNoteInfoForDebug"}, - FunctionInfo{50011, C<&IAlbumAccessorService::GetAlbumAccessResultForDebug>, "GetAlbumAccessResultForDebug"}, - FunctionInfo{60002, nullptr, "OpenAccessorSession"} - ); - return HandlerTableGenerateWithFind(key, functions); -} - -IAlbumAccessorService::IAlbumAccessorService(Core::System& system_, - std::shared_ptr album_manager) - : ServiceFramework{system_, "caps:a"}, manager{album_manager} { -} - -IAlbumAccessorService::~IAlbumAccessorService() = default; - -Result IAlbumAccessorService::GetAlbumFileList( - Out out_count, AlbumStorage storage, - OutArray out_entries) { - LOG_INFO(Service_Capture, "called, storage={}", storage); - - const Result result = manager->GetAlbumFileList(out_entries, *out_count, storage, 0); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::DeleteAlbumFile(AlbumFileId file_id) { - LOG_INFO(Service_Capture, "called, application_id={:#0x}, storage={}, type={}", - file_id.application_id, file_id.storage, file_id.type); - - const Result result = manager->DeleteAlbumFile(file_id); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::IsAlbumMounted(Out out_is_mounted, AlbumStorage storage) { - LOG_INFO(Service_Capture, "called, storage={}", storage); - - const Result result = manager->IsAlbumMounted(storage); - *out_is_mounted = result.IsSuccess(); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::Unknown18( - Out out_buffer_size, - OutArray out_buffer) { - LOG_WARNING(Service_Capture, "(STUBBED) called"); - *out_buffer_size = 0; - R_SUCCEED(); -} - -Result IAlbumAccessorService::GetAlbumFileListEx0( - Out out_entries_size, AlbumStorage storage, u8 flags, - OutArray out_entries) { - LOG_INFO(Service_Capture, "called, storage={}, flags={}", storage, flags); - - const Result result = manager->GetAlbumFileList(out_entries, *out_entries_size, storage, flags); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::GetAutoSavingStorage(Out out_is_autosaving) { - LOG_WARNING(Service_Capture, "(STUBBED) called"); - - const Result result = manager->GetAutoSavingStorage(*out_is_autosaving); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::LoadAlbumScreenShotImageEx1( - const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options, - OutLargeData out_image_output, - OutArray out_image, - OutArray out_buffer) { - LOG_INFO(Service_Capture, "called, application_id={:#0x}, storage={}, type={}, flags={}", - file_id.application_id, file_id.storage, file_id.type, decoder_options.flags); - - const Result result = - manager->LoadAlbumScreenShotImage(*out_image_output, out_image, file_id, decoder_options); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1( - const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options, - OutLargeData out_image_output, - OutArray out_image, - OutArray out_buffer) { - LOG_INFO(Service_Capture, "called, application_id={:#0x}, storage={}, type={}, flags={}", - file_id.application_id, file_id.storage, file_id.type, decoder_options.flags); - - const Result result = manager->LoadAlbumScreenShotThumbnail(*out_image_output, out_image, - file_id, decoder_options); - R_RETURN(TranslateResult(result)); -} - -Result IAlbumAccessorService::TranslateResult(Result in_result) { - if (in_result.IsSuccess()) { - return in_result; - } - - if ((in_result.raw & 0x3801ff) == ResultUnknown1024.raw) { - if (in_result.GetDescription() - 0x514 < 100) { - return ResultInvalidFileData; - } - if (in_result.GetDescription() - 0x5dc < 100) { - return ResultInvalidFileData; - } - - if (in_result.GetDescription() - 0x578 < 100) { - if (in_result == ResultFileCountLimit) { - return ResultUnknown22; - } - return ResultUnknown25; - } - - if (in_result.raw < ResultUnknown1801.raw) { - if (in_result == ResultUnknown1202) { - return ResultUnknown810; - } - if (in_result == ResultUnknown1203) { - return ResultUnknown810; - } - if (in_result == ResultUnknown1701) { - return ResultUnknown5; - } - } else if (in_result.raw < ResultUnknown1803.raw) { - if (in_result == ResultUnknown1801) { - return ResultUnknown5; - } - if (in_result == ResultUnknown1802) { - return ResultUnknown6; - } - } else { - if (in_result == ResultUnknown1803) { - return ResultUnknown7; - } - if (in_result == ResultUnknown1804) { - return ResultOutOfRange; - } - } - return ResultUnknown1024; - } - - if (in_result.GetModule() == ErrorModule::FS) { - if ((in_result.GetDescription() >> 0xc < 0x7d) || - (in_result.GetDescription() - 1000 < 2000) || - (((in_result.GetDescription() - 3000) >> 3) < 0x271)) { - // TODO: Translate FS error - return in_result; - } - } - - return in_result; -} - - -Result IAlbumAccessorService::GetAlbumAccessResultForDebug(Out out_result) { - LOG_WARNING(Service_Capture, "(STUBBED) called"); - *out_result = ResultSuccess; - R_SUCCEED(); -} - -} // namespace Service::Capture diff --git a/src/core/hle/service/caps/caps_a.h b/src/core/hle/service/caps/caps_a.h deleted file mode 100644 index 55e5c77264..0000000000 --- a/src/core/hle/service/caps/caps_a.h +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/caps/caps_types.h" -#include "core/hle/service/cmif_types.h" -#include "core/hle/service/service.h" - -namespace Core { -class System; -} - -namespace Service::Capture { -class AlbumManager; - -class IAlbumAccessorService final : public ServiceFramework { -public: - explicit IAlbumAccessorService(Core::System& system_, - std::shared_ptr album_manager); - ~IAlbumAccessorService() override; - -private: - Result GetAlbumFileList(Out out_count, AlbumStorage storage, - OutArray out_entries); - - Result DeleteAlbumFile(AlbumFileId file_id); - - Result IsAlbumMounted(Out out_is_mounted, AlbumStorage storage); - - Result Unknown18( - Out out_buffer_size, - OutArray - out_buffer); - - Result GetAlbumFileListEx0(Out out_entries_size, AlbumStorage storage, u8 flags, - OutArray out_entries); - - Result GetAutoSavingStorage(Out out_is_autosaving); - - Result LoadAlbumScreenShotImageEx1( - const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options, - OutLargeData out_image_output, - OutArray out_image, - OutArray out_buffer); - - Result LoadAlbumScreenShotThumbnailImageEx1( - const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options, - OutLargeData out_image_output, - OutArray out_image, - OutArray out_buffer); - - Result TranslateResult(Result in_result); - - Result GetAlbumAccessResultForDebug(Out out_result); - - std::optional FindRequest(u32 key) override; - std::shared_ptr manager = nullptr; -}; - -} // namespace Service::Capture diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index ba9d5504a1..ae260c18c0 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -11,13 +11,27 @@ #include "core/hle/kernel/k_event.h" #include "core/hle/service/acc/errors.h" #include "core/hle/service/friend/friend.h" -#include "core/hle/service/friend/friend_interface.h" #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/server_manager.h" namespace Service::Friend { +class Friend final : public Module::Interface { +public: + explicit Friend(std::shared_ptr module_, Core::System& system_, const char* name) : Interface(std::move(module_), system_, name) {} + ~Friend() override = default; + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &Friend::CreateFriendService, "CreateFriendService"}, + FunctionInfo{1, &Friend::CreateNotificationService, "CreateNotificationService"}, + FunctionInfo{2, nullptr, "CreateDaemonSuspendSessionService"} + ); +}; + class IFriendService final : public ServiceFramework { public: explicit IFriendService(Core::System& system_) diff --git a/src/core/hle/service/friend/friend_interface.cpp b/src/core/hle/service/friend/friend_interface.cpp deleted file mode 100644 index 88a84da413..0000000000 --- a/src/core/hle/service/friend/friend_interface.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/friend/friend_interface.h" - -namespace Service::Friend { - -Friend::Friend(std::shared_ptr module_, Core::System& system_, const char* name) - : Interface(std::move(module_), system_, name) { -} - -Friend::~Friend() = default; - -} // namespace Service::Friend diff --git a/src/core/hle/service/friend/friend_interface.h b/src/core/hle/service/friend/friend_interface.h deleted file mode 100644 index f67aeab79d..0000000000 --- a/src/core/hle/service/friend/friend_interface.h +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/friend/friend.h" - -namespace Service::Friend { - -class Friend final : public Module::Interface { -public: - explicit Friend(std::shared_ptr module_, Core::System& system_, const char* name); - ~Friend() override; - - std::optional FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, &Friend::CreateFriendService, "CreateFriendService"}, - FunctionInfo{1, &Friend::CreateNotificationService, "CreateNotificationService"}, - FunctionInfo{2, nullptr, "CreateDaemonSuspendSessionService"} - ); -}; - -} // namespace Service::Friend diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index 427904010e..170886e16e 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp @@ -9,7 +9,6 @@ #include "core/hle/service/ldn/ldn.h" #include "core/hle/service/ldn/monitor_service.h" #include "core/hle/service/ldn/sf_monitor_service.h" -#include "core/hle/service/ldn/sf_service.h" #include "core/hle/service/ldn/sf_service_monitor.h" #include "core/hle/service/ldn/system_local_communication_service.h" #include "core/hle/service/ldn/user_local_communication_service.h" @@ -116,6 +115,36 @@ private: ); }; +class ISfService final : public ServiceFramework { +public: + explicit ISfService(Core::System& system_) : ServiceFramework{system_, "ISfService"} {} + ~ISfService() override = default; + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Initialize"}, + FunctionInfo{256, nullptr, "AttachNetworkInterfaceStateChangeEvent"}, + FunctionInfo{264, nullptr, "GetNetworkInterfaceLastError"}, + FunctionInfo{272, nullptr, "GetRole"}, + FunctionInfo{280, nullptr, "GetAdvertiseData"}, + FunctionInfo{288, nullptr, "GetGroupInfo"}, + FunctionInfo{296, nullptr, "GetGroupInfo2"}, + FunctionInfo{304, nullptr, "GetGroupOwner"}, + FunctionInfo{312, nullptr, "GetIpConfig"}, + FunctionInfo{320, nullptr, "GetLinkLevel"}, + FunctionInfo{512, nullptr, "Scan"}, + FunctionInfo{768, nullptr, "CreateGroup"}, + FunctionInfo{776, nullptr, "DestroyGroup"}, + FunctionInfo{784, nullptr, "SetAdvertiseData"}, + FunctionInfo{1536, nullptr, "SendToOtherGroup"}, + FunctionInfo{1544, nullptr, "RecvFromOtherGroup"}, + FunctionInfo{1552, nullptr, "AddAcceptableGroupId"}, + FunctionInfo{1560, nullptr, "ClearAcceptableGroupId"} + ); +}; + class ISfServiceCreator final : public ServiceFramework { public: explicit ISfServiceCreator(Core::System& system_, bool is_system_, const char* name_) : ServiceFramework{system_, name_}, is_system{is_system_} {} diff --git a/src/core/hle/service/ldn/sf_service.cpp b/src/core/hle/service/ldn/sf_service.cpp deleted file mode 100644 index cb003d1a63..0000000000 --- a/src/core/hle/service/ldn/sf_service.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "core/hle/service/ldn/sf_service.h" - -namespace Service::LDN { - -ISfService::ISfService(Core::System& system_) : ServiceFramework{system_, "ISfService"} { -} - -ISfService::~ISfService() = default; - -} // namespace Service::LDN diff --git a/src/core/hle/service/ldn/sf_service.h b/src/core/hle/service/ldn/sf_service.h deleted file mode 100644 index 1b3e1b731d..0000000000 --- a/src/core/hle/service/ldn/sf_service.h +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -#pragma once - -#include "core/hle/service/cmif_types.h" -#include "core/hle/service/service.h" - -namespace Core { -class System; -} - -namespace Service::LDN { - -class ISfService final : public ServiceFramework { -public: - explicit ISfService(Core::System& system_); - ~ISfService() override; - - std::optional FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "Initialize"}, - FunctionInfo{256, nullptr, "AttachNetworkInterfaceStateChangeEvent"}, - FunctionInfo{264, nullptr, "GetNetworkInterfaceLastError"}, - FunctionInfo{272, nullptr, "GetRole"}, - FunctionInfo{280, nullptr, "GetAdvertiseData"}, - FunctionInfo{288, nullptr, "GetGroupInfo"}, - FunctionInfo{296, nullptr, "GetGroupInfo2"}, - FunctionInfo{304, nullptr, "GetGroupOwner"}, - FunctionInfo{312, nullptr, "GetIpConfig"}, - FunctionInfo{320, nullptr, "GetLinkLevel"}, - FunctionInfo{512, nullptr, "Scan"}, - FunctionInfo{768, nullptr, "CreateGroup"}, - FunctionInfo{776, nullptr, "DestroyGroup"}, - FunctionInfo{784, nullptr, "SetAdvertiseData"}, - FunctionInfo{1536, nullptr, "SendToOtherGroup"}, - FunctionInfo{1544, nullptr, "RecvFromOtherGroup"}, - FunctionInfo{1552, nullptr, "AddAcceptableGroupId"}, - FunctionInfo{1560, nullptr, "ClearAcceptableGroupId"} - ); -}; - -} // namespace Service::LDN diff --git a/src/core/hle/service/psc/ovln/receiver.cpp b/src/core/hle/service/psc/ovln/receiver.cpp deleted file mode 100644 index 4c64f3ef0e..0000000000 --- a/src/core/hle/service/psc/ovln/receiver.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/psc/ovln/receiver.h" -#include "core/hle/service/cmif_serialization.h" - -namespace Service::PSC { - -std::optional IReceiver::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, D<&IReceiver::AddSource>, "AddSource"}, - FunctionInfo{1, D<&IReceiver::RemoveSource>, "RemoveSource"}, - FunctionInfo{2, D<&IReceiver::GetReceiveEventHandle>, "GetReceiveEventHandle"}, - FunctionInfo{3, D<&IReceiver::Receive>, "Receive"}, - FunctionInfo{4, D<&IReceiver::ReceiveWithTick>, "ReceiveWithTick"} - ); - return HandlerTableGenerateWithFind(key, functions); -} - -IReceiver::IReceiver(Core::System& system_) - : ServiceFramework{system_, "IReceiver"}, service_context{system_, "IReceiver"} { - receive_event = service_context.CreateEvent("IReceiver::ReceiveEvent"); -} - -IReceiver::~IReceiver() { - service_context.CloseEvent(receive_event); -} - -Result IReceiver::AddSource(SourceName source_name) { - const std::string name = source_name.GetString(); - LOG_INFO(Service_PSC, "called: source_name={}", name); - - // Add source if it doesn't already exist - if (message_sources.find(name) == message_sources.end()) { - message_sources[name] = {}; - } - - R_SUCCEED(); -} - -Result IReceiver::RemoveSource(SourceName source_name) { - const std::string name = source_name.GetString(); - LOG_INFO(Service_PSC, "called: source_name={}", name); - - // Remove source if it exists - message_sources.erase(name); - - R_SUCCEED(); -} - -Result IReceiver::GetReceiveEventHandle(OutCopyHandle out_event) { - LOG_INFO(Service_PSC, "called"); - *out_event = &receive_event->GetReadableEvent(); - R_SUCCEED(); -} - -Result IReceiver::Receive(Out out_notification, Out out_flags) { - u64 tick; - return ReceiveWithTick(out_notification, out_flags, Out(&tick)); -} - -Result IReceiver::ReceiveWithTick(Out out_notification, - Out out_flags, Out out_tick) { - LOG_DEBUG(Service_PSC, "called"); - - // Find the message with the lowest ID across all sources - const std::string* target_source = nullptr; - size_t target_index = 0; - - for (const auto& [source_name, messages] : message_sources) { - if (!messages.empty()) { - if (target_source == nullptr) { - target_source = &source_name; - target_index = 0; - } - // Note: In the real implementation, we would track message IDs - // For now, just use FIFO order - } - } - - if (target_source != nullptr) { - auto& messages = message_sources[*target_source]; - *out_notification = messages[target_index].first; - *out_flags = messages[target_index].second; - *out_tick = 0; // TODO: Implement tick tracking - - // Remove the message - messages.erase(messages.begin() + target_index); - - // Clear event if no more messages - bool has_messages = false; - for (const auto& [_, msgs] : message_sources) { - if (!msgs.empty()) { - has_messages = true; - break; - } - } - if (!has_messages) { - receive_event->Clear(system.Kernel()); - } - - R_SUCCEED(); - } - - // No messages available - *out_notification = {}; - *out_flags = {}; - *out_tick = 0; - - LOG_WARNING(Service_PSC, "No messages available"); - R_THROW(ResultUnknown); // TODO: Use proper OvlnResult::NoMessages when available -} - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/ovln/receiver.h b/src/core/hle/service/psc/ovln/receiver.h deleted file mode 100644 index ebf9f1ab23..0000000000 --- a/src/core/hle/service/psc/ovln/receiver.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include -#include -#include "core/hle/result.h" -#include "core/hle/service/cmif_types.h" -#include "core/hle/service/kernel_helpers.h" -#include "core/hle/service/service.h" -#include "core/hle/service/psc/ovln/ovln_types.h" - -namespace Kernel { -class KReadableEvent; -} - -namespace Service::PSC { - -class IReceiver final : public ServiceFramework { -public: - explicit IReceiver(Core::System& system_); - ~IReceiver() override; - - IReceiver(const IReceiver&) = delete; - IReceiver& operator=(const IReceiver&) = delete; - -private: - Result AddSource(SourceName source_name); - Result RemoveSource(SourceName source_name); - Result GetReceiveEventHandle(OutCopyHandle out_event); - Result Receive(Out out_notification, Out out_flags); - Result ReceiveWithTick(Out out_notification, Out out_flags, - Out out_tick); - std::optional FindRequest(u32 key) override; - - KernelHelpers::ServiceContext service_context; - Kernel::KEvent* receive_event; - - std::map>> message_sources; -}; - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/ovln/receiver_service.cpp b/src/core/hle/service/psc/ovln/receiver_service.cpp index a065637e5a..0df9d802b9 100644 --- a/src/core/hle/service/psc/ovln/receiver_service.cpp +++ b/src/core/hle/service/psc/ovln/receiver_service.cpp @@ -5,17 +5,124 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/cmif_serialization.h" -#include "core/hle/service/psc/ovln/receiver.h" +#include "core/hle/service/psc/ovln/ovln_types.h" #include "core/hle/service/psc/ovln/receiver_service.h" namespace Service::PSC { - std::optional IReceiverService::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, D<&IReceiverService::OpenReceiver>, "OpenReceiver"} - ); +class IReceiver final : public ServiceFramework { +public: + explicit IReceiver(Core::System& system_) : ServiceFramework{system_, "IReceiver"}, service_context{system_, "IReceiver"} { + receive_event = service_context.CreateEvent("IReceiver::ReceiveEvent"); + } + + ~IReceiver() override { + service_context.CloseEvent(receive_event); + } + + Result AddSource(SourceName source_name) { + const std::string name = source_name.GetString(); + LOG_INFO(Service_PSC, "called: source_name={}", name); + // Add source if it doesn't already exist + if (message_sources.find(name) == message_sources.end()) { + message_sources[name] = {}; + } + R_SUCCEED(); + } + + Result RemoveSource(SourceName source_name) { + const std::string name = source_name.GetString(); + LOG_INFO(Service_PSC, "called: source_name={}", name); + // Remove source if it exists + message_sources.erase(name); + R_SUCCEED(); + } + + Result GetReceiveEventHandle(OutCopyHandle out_event) { + LOG_INFO(Service_PSC, "called"); + *out_event = &receive_event->GetReadableEvent(); + R_SUCCEED(); + } + + Result Receive(Out out_notification, Out out_flags) { + u64 tick; + return ReceiveWithTick(out_notification, out_flags, Out(&tick)); + } + + Result ReceiveWithTick(Out out_notification, Out out_flags, Out out_tick) { + LOG_DEBUG(Service_PSC, "called"); + + // Find the message with the lowest ID across all sources + const std::string* target_source = nullptr; + size_t target_index = 0; + + for (const auto& [source_name, messages] : message_sources) { + if (!messages.empty()) { + if (target_source == nullptr) { + target_source = &source_name; + target_index = 0; + } + // Note: In the real implementation, we would track message IDs + // For now, just use FIFO order + } + } + + if (target_source != nullptr) { + auto& messages = message_sources[*target_source]; + *out_notification = messages[target_index].first; + *out_flags = messages[target_index].second; + *out_tick = 0; // TODO: Implement tick tracking + + // Remove the message + messages.erase(messages.begin() + target_index); + + // Clear event if no more messages + bool has_messages = false; + for (const auto& [_, msgs] : message_sources) { + if (!msgs.empty()) { + has_messages = true; + break; + } + } + if (!has_messages) { + receive_event->Clear(system.Kernel()); + } + + R_SUCCEED(); + } + + // No messages available + *out_notification = {}; + *out_flags = {}; + *out_tick = 0; + + LOG_WARNING(Service_PSC, "No messages available"); + R_THROW(ResultUnknown); // TODO: Use proper OvlnResult::NoMessages when available + } + + std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&IReceiver::AddSource>, "AddSource"}, + FunctionInfo{1, D<&IReceiver::RemoveSource>, "RemoveSource"}, + FunctionInfo{2, D<&IReceiver::GetReceiveEventHandle>, "GetReceiveEventHandle"}, + FunctionInfo{3, D<&IReceiver::Receive>, "Receive"}, + FunctionInfo{4, D<&IReceiver::ReceiveWithTick>, "ReceiveWithTick"} + ); + + KernelHelpers::ServiceContext service_context; + Kernel::KEvent* receive_event; + + std::map>> message_sources; +}; + +std::optional IReceiverService::FindRequest(u32 key) { + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&IReceiverService::OpenReceiver>, "OpenReceiver"} + ); + return HandlerTableGenerateWithFind(key, functions); +} IReceiverService::IReceiverService(Core::System& system_) : ServiceFramework{system_, "ovln:rcv"} { } diff --git a/src/core/hle/service/psc/ovln/sender.cpp b/src/core/hle/service/psc/ovln/sender.cpp deleted file mode 100644 index c270b376fb..0000000000 --- a/src/core/hle/service/psc/ovln/sender.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/cmif_serialization.h" -#include "core/hle/service/psc/ovln/sender.h" - -namespace Service::PSC { - - std::optional ISender::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, D<&ISender::Send>, "Send"}, - FunctionInfo{1, nullptr, "GetUnreceivedMessageCount"} - ); - return HandlerTableGenerateWithFind(key, functions); - } - -ISender::ISender(Core::System& system_) : ServiceFramework{system_, "ISender"} { -} - -ISender::~ISender() = default; - -Result ISender::Send(const OverlayNotification& notification, MessageFlags flags) { - std::string data; - for (const auto m : notification) { - data += fmt::format("{:016X} ", m); - } - - LOG_WARNING(Service_PSC, "(STUBBED) called, flags={} notification={}", flags.raw, data); - R_SUCCEED(); -} - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/ovln/sender.h b/src/core/hle/service/psc/ovln/sender.h deleted file mode 100644 index 0ebb060f98..0000000000 --- a/src/core/hle/service/psc/ovln/sender.h +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/cmif_types.h" -#include "core/hle/service/psc/ovln/ovln_types.h" -#include "core/hle/service/service.h" - -namespace Service::PSC { - -class ISender final : public ServiceFramework { -public: - explicit ISender(Core::System& system_); - ~ISender() override; - -private: - Result Send(const OverlayNotification& notification, MessageFlags flags); - - std::optional FindRequest(u32 key) override; -}; - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/ovln/sender_service.cpp b/src/core/hle/service/psc/ovln/sender_service.cpp index 4c24e33ce0..5a36f1e1ec 100644 --- a/src/core/hle/service/psc/ovln/sender_service.cpp +++ b/src/core/hle/service/psc/ovln/sender_service.cpp @@ -5,17 +5,41 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/cmif_serialization.h" -#include "core/hle/service/psc/ovln/sender.h" +#include "core/hle/service/psc/ovln/ovln_types.h" #include "core/hle/service/psc/ovln/sender_service.h" namespace Service::PSC { - std::optional ISenderService::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, D<&ISenderService::OpenSender>, "OpenSender"} - ); +class ISender final : public ServiceFramework { +public: + explicit ISender(Core::System& system_) : ServiceFramework{system_, "ISender"} {} + ~ISender() override = default; + + Result Send(const OverlayNotification& notification, MessageFlags flags) { + std::string data; + for (const auto m : notification) { + data += fmt::format("{:016X} ", m); + } + + LOG_WARNING(Service_PSC, "(STUBBED) called, flags={} notification={}", flags.raw, data); + R_SUCCEED(); + } + + std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&ISender::Send>, "Send"}, + FunctionInfo{1, nullptr, "GetUnreceivedMessageCount"} + ); +}; + +std::optional ISenderService::FindRequest(u32 key) { + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, D<&ISenderService::OpenSender>, "OpenSender"} + ); + return HandlerTableGenerateWithFind(key, functions); +} ISenderService::ISenderService(Core::System& system_) : ServiceFramework{system_, "ovln:snd"} { } diff --git a/src/core/hle/service/psc/pm_control.cpp b/src/core/hle/service/psc/pm_control.cpp deleted file mode 100644 index cc16a109e0..0000000000 --- a/src/core/hle/service/psc/pm_control.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/psc/pm_control.h" - -namespace Service::PSC { - -IPmControl::IPmControl(Core::System& system_) : ServiceFramework{system_, "psc:c"} { -} - -IPmControl::~IPmControl() = default; - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/pm_control.h b/src/core/hle/service/psc/pm_control.h deleted file mode 100644 index 716fd25411..0000000000 --- a/src/core/hle/service/psc/pm_control.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/service.h" - -namespace Service::PSC { - -class IPmControl final : public ServiceFramework { -public: - explicit IPmControl(Core::System& system_); - ~IPmControl() override; - - std::optional FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "Initialize"}, - FunctionInfo{1, nullptr, "DispatchRequest"}, - FunctionInfo{2, nullptr, "GetResult"}, - FunctionInfo{3, nullptr, "GetState"}, - FunctionInfo{4, nullptr, "Cancel"}, - FunctionInfo{5, nullptr, "PrintModuleInformation"}, - FunctionInfo{6, nullptr, "GetModuleInformation"}, - FunctionInfo{10, nullptr, "AcquireStateLock"}, - FunctionInfo{11, nullptr, "HasStateLock"} - ); -}; - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/pm_module.cpp b/src/core/hle/service/psc/pm_module.cpp deleted file mode 100644 index 7e3ec55a0b..0000000000 --- a/src/core/hle/service/psc/pm_module.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/psc/pm_module.h" - -namespace Service::PSC { - -std::optional IPmModule::FindRequest(u32 key) { - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "Initialize"}, - FunctionInfo{1, nullptr, "GetRequest"}, - FunctionInfo{2, nullptr, "Acknowledge"}, - FunctionInfo{3, nullptr, "Finalize"}, - FunctionInfo{4, nullptr, "AcknowledgeEx"} - ); - return HandlerTableGenerateWithFind(key, functions); -} - -IPmModule::IPmModule(Core::System& system_) : ServiceFramework{system_, "IPmModule"} { -} - -IPmModule::~IPmModule() = default; - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/pm_module.h b/src/core/hle/service/psc/pm_module.h deleted file mode 100644 index 811e50e8f6..0000000000 --- a/src/core/hle/service/psc/pm_module.h +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/service.h" - -namespace Service::PSC { - -class IPmModule final : public ServiceFramework { -public: - explicit IPmModule(Core::System& system_); - ~IPmModule() override; - std::optional FindRequest(u32 key) override; -}; - -} // namespace Service::PSC diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp index 43da055aa2..553c4f63a4 100644 --- a/src/core/hle/service/psc/psc.cpp +++ b/src/core/hle/service/psc/psc.cpp @@ -6,8 +6,6 @@ #include "core/hle/service/psc/ovln/receiver_service.h" #include "core/hle/service/psc/ovln/sender_service.h" -#include "core/hle/service/psc/pm_control.h" -#include "core/hle/service/psc/pm_module.h" #include "core/hle/service/psc/psc.h" #include "core/hle/service/psc/time/manager.h" #include "core/hle/service/psc/time/power_state_service.h" @@ -103,7 +101,22 @@ public: } }; -class IPmModule; +class IPmModule final : public ServiceFramework { +public: + explicit IPmModule(Core::System& system_) : ServiceFramework{system_, "IPmModule"} {} + ~IPmModule() override = default; + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Initialize"}, + FunctionInfo{1, nullptr, "GetRequest"}, + FunctionInfo{2, nullptr, "Acknowledge"}, + FunctionInfo{3, nullptr, "Finalize"}, + FunctionInfo{4, nullptr, "AcknowledgeEx"} + ); +}; class IPmService final : public ServiceFramework { public: @@ -125,6 +138,27 @@ private: ); }; +class IPmControl final : public ServiceFramework { +public: + explicit IPmControl(Core::System& system_) : ServiceFramework{system_, "psc:c"} {} + ~IPmControl() override = default; + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, nullptr, "Initialize"}, + FunctionInfo{1, nullptr, "DispatchRequest"}, + FunctionInfo{2, nullptr, "GetResult"}, + FunctionInfo{3, nullptr, "GetState"}, + FunctionInfo{4, nullptr, "Cancel"}, + FunctionInfo{5, nullptr, "PrintModuleInformation"}, + FunctionInfo{6, nullptr, "GetModuleInformation"}, + FunctionInfo{10, nullptr, "AcquireStateLock"}, + FunctionInfo{11, nullptr, "HasStateLock"} + ); +}; + void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); diff --git a/src/core/hle/service/ro/ro.cpp b/src/core/hle/service/ro/ro.cpp index 368e1c9fb4..d0ddfc280e 100644 --- a/src/core/hle/service/ro/ro.cpp +++ b/src/core/hle/service/ro/ro.cpp @@ -8,17 +8,330 @@ #include #include "core/hle/kernel/k_process.h" - -#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/ro/ro.h" -#include "core/hle/service/ro/ro_nro_utils.h" -#include "core/hle/service/ro/ro_results.h" -#include "core/hle/service/ro/ro_types.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" +#include "core/hle/service/cmif_serialization.h" namespace Service::RO { +constexpr Result ResultOutOfAddressSpace{ErrorModule::RO, 2}; +constexpr Result ResultAlreadyLoaded{ErrorModule::RO, 3}; +constexpr Result ResultInvalidNro{ErrorModule::RO, 4}; +constexpr Result ResultInvalidNrr{ErrorModule::RO, 6}; +constexpr Result ResultTooManyNro{ErrorModule::RO, 7}; +constexpr Result ResultTooManyNrr{ErrorModule::RO, 8}; +constexpr Result ResultNotAuthorized{ErrorModule::RO, 9}; +constexpr Result ResultInvalidNrrKind{ErrorModule::RO, 10}; +constexpr Result ResultInternalError{ErrorModule::RO, 1023}; +constexpr Result ResultInvalidAddress{ErrorModule::RO, 1025}; +constexpr Result ResultInvalidSize{ErrorModule::RO, 1026}; +constexpr Result ResultNotLoaded{ErrorModule::RO, 1028}; +constexpr Result ResultNotRegistered{ErrorModule::RO, 1029}; +constexpr Result ResultInvalidSession{ErrorModule::RO, 1030}; +constexpr Result ResultInvalidProcess{ErrorModule::RO, 1031}; + +namespace { + +struct ProcessMemoryRegion { + u64 address; + u64 size; +}; + +size_t GetTotalProcessMemoryRegionSize(const ProcessMemoryRegion* regions, size_t num_regions) { + size_t total = 0; + + for (size_t i = 0; i < num_regions; ++i) { + total += regions[i].size; + } + + return total; +} + +size_t SetupNroProcessMemoryRegions(ProcessMemoryRegion* regions, u64 nro_heap_address, + u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size) { + // Reset region count. + size_t num_regions = 0; + + // We always want a region for the nro. + regions[num_regions++] = {nro_heap_address, nro_heap_size}; + + // If we have bss, create a region for bss. + if (bss_heap_size > 0) { + regions[num_regions++] = {bss_heap_address, bss_heap_size}; + } + + return num_regions; +} + +Result SetProcessMemoryPermission(Kernel::KProcess* process, u64 address, u64 size, + Kernel::Svc::MemoryPermission permission) { + auto& page_table = process->GetPageTable(); + + // Set permission. + R_RETURN(page_table.SetProcessMemoryPermission(address, size, permission)); +} + +Result UnmapProcessCodeMemory(Kernel::KProcess* process, u64 process_code_address, + const ProcessMemoryRegion* regions, size_t num_regions) { + // Get the total process memory region size. + const size_t total_size = GetTotalProcessMemoryRegionSize(regions, num_regions); + + auto& page_table = process->GetPageTable(); + + // Unmap each region in order. + size_t cur_offset = total_size; + for (size_t i = 0; i < num_regions; ++i) { + // We want to unmap in reverse order. + const auto& cur_region = regions[num_regions - 1 - i]; + + // Subtract to update the current offset. + cur_offset -= cur_region.size; + + // Unmap. + R_TRY(page_table.UnmapCodeMemory(process_code_address + cur_offset, cur_region.address, + cur_region.size)); + } + + R_SUCCEED(); +} + +Result EnsureGuardPages(Kernel::KProcessPageTable& page_table, u64 map_address, u64 map_size) { + Kernel::KMemoryInfo memory_info; + Kernel::Svc::PageInfo page_info; + + // Ensure page before mapping is unmapped. + R_TRY(page_table.QueryInfo(std::addressof(memory_info), std::addressof(page_info), + map_address - 1)); + R_UNLESS(memory_info.GetSvcState() == Kernel::Svc::MemoryState::Free, + Kernel::ResultInvalidState); + + // Ensure page after mapping is unmapped. + R_TRY(page_table.QueryInfo(std::addressof(memory_info), std::addressof(page_info), + map_address + map_size)); + R_UNLESS(memory_info.GetSvcState() == Kernel::Svc::MemoryState::Free, + Kernel::ResultInvalidState); + + // Successfully verified guard pages. + R_SUCCEED(); +} + +Result MapProcessCodeMemory(u64* out, Kernel::KProcess* process, const ProcessMemoryRegion* regions, + size_t num_regions, std::mt19937_64& generate_random) { + auto& page_table = process->GetPageTable(); + const u64 alias_code_start = + GetInteger(page_table.GetAliasCodeRegionStart()) / Kernel::PageSize; + const u64 alias_code_size = page_table.GetAliasCodeRegionSize() / Kernel::PageSize; + + for (size_t trial = 0; trial < 64; trial++) { + // Generate a new trial address. + const u64 mapped_address = + (alias_code_start + (generate_random() % alias_code_size)) * Kernel::PageSize; + + const auto MapRegions = [&] { + // Map the regions in order. + u64 mapped_size = 0; + for (size_t i = 0; i < num_regions; ++i) { + // If we fail, unmap up to where we've mapped. + ON_RESULT_FAILURE { + R_ASSERT(UnmapProcessCodeMemory(process, mapped_address, regions, i)); + }; + + // Map the current region. + R_TRY(page_table.MapCodeMemory(mapped_address + mapped_size, regions[i].address, + regions[i].size)); + + mapped_size += regions[i].size; + } + + // If we fail, unmap all mapped regions. + ON_RESULT_FAILURE { + R_ASSERT(UnmapProcessCodeMemory(process, mapped_address, regions, num_regions)); + }; + + // Ensure guard pages. + R_RETURN(EnsureGuardPages(page_table, mapped_address, mapped_size)); + }; + + if (R_SUCCEEDED(MapRegions())) { + // Set the output address. + *out = mapped_address; + R_SUCCEED(); + } + } + + // We failed to map anything. + R_THROW(RO::ResultOutOfAddressSpace); +} + +Result MapNro(u64* out_base_address, Kernel::KProcess* process, u64 nro_heap_address, + u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size, + std::mt19937_64& generate_random) { + // Set up the process memory regions. + std::array regions{}; + const size_t num_regions = SetupNroProcessMemoryRegions( + regions.data(), nro_heap_address, nro_heap_size, bss_heap_address, bss_heap_size); + + // Re-map the nro/bss as code memory in the destination process. + R_RETURN(MapProcessCodeMemory(out_base_address, process, regions.data(), num_regions, + generate_random)); +} + +Result SetNroPerms(Kernel::KProcess* process, u64 base_address, u64 rx_size, u64 ro_size, + u64 rw_size) { + const u64 rx_offset = 0; + const u64 ro_offset = rx_offset + rx_size; + const u64 rw_offset = ro_offset + ro_size; + + R_TRY(SetProcessMemoryPermission(process, base_address + rx_offset, rx_size, + Kernel::Svc::MemoryPermission::ReadExecute)); + R_TRY(SetProcessMemoryPermission(process, base_address + ro_offset, ro_size, + Kernel::Svc::MemoryPermission::Read)); + R_TRY(SetProcessMemoryPermission(process, base_address + rw_offset, rw_size, + Kernel::Svc::MemoryPermission::ReadWrite)); + + R_SUCCEED(); +} + +Result UnmapNro(Kernel::KProcess* process, u64 base_address, u64 nro_heap_address, + u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size) { + // Set up the process memory regions. + std::array regions{}; + const size_t num_regions = SetupNroProcessMemoryRegions( + regions.data(), nro_heap_address, nro_heap_size, bss_heap_address, bss_heap_size); + + // Unmap the nro/bss. + R_RETURN(UnmapProcessCodeMemory(process, base_address, regions.data(), num_regions)); +} + +} // namespace + +enum class NrrKind : u8 { + User = 0, + JitPlugin = 1, + Count, +}; + +static constexpr size_t ModuleIdSize = 0x20; +struct ModuleId { + std::array data; +}; +static_assert(sizeof(ModuleId) == ModuleIdSize); + +struct NrrCertification { + static constexpr size_t RsaKeySize = 0x100; + static constexpr size_t SignedSize = 0x120; + + u64 program_id_mask; + u64 program_id_pattern; + std::array reserved_10; + std::array modulus; + std::array signature; +}; +static_assert(sizeof(NrrCertification) == NrrCertification::RsaKeySize + NrrCertification::SignedSize); + +class NrrHeader { +public: + static constexpr u32 Magic = Common::MakeMagic('N', 'R', 'R', '0'); + +public: + bool IsMagicValid() const { + return m_magic == Magic; + } + + bool IsProgramIdValid() const { + return (m_program_id & m_certification.program_id_mask) == + m_certification.program_id_pattern; + } + + NrrKind GetNrrKind() const { + const NrrKind kind = static_cast(m_nrr_kind); + ASSERT(kind < NrrKind::Count); + return kind; + } + + u64 GetProgramId() const { + return m_program_id; + } + + u32 GetSize() const { + return m_size; + } + + u32 GetNumHashes() const { + return m_num_hashes; + } + + size_t GetHashesOffset() const { + return m_hashes_offset; + } + + u32 GetKeyGeneration() const { + return m_key_generation; + } + + const u8* GetCertificationSignature() const { + return m_certification.signature.data(); + } + + const u8* GetCertificationSignedArea() const { + return reinterpret_cast(std::addressof(m_certification)); + } + + const u8* GetCertificationModulus() const { + return m_certification.modulus.data(); + } + + const u8* GetSignature() const { + return m_signature.data(); + } + + size_t GetSignedAreaSize() const { + return m_size - GetSignedAreaOffset(); + } + + static constexpr size_t GetSignedAreaOffset() { + return offsetof(NrrHeader, m_program_id); + } + +private: + u32 m_magic; + u32 m_key_generation; + INSERT_PADDING_BYTES_NOINIT(8); + NrrCertification m_certification; + std::array m_signature; + u64 m_program_id; + u32 m_size; + u8 m_nrr_kind; // 7.0.0+ + INSERT_PADDING_BYTES_NOINIT(3); + u32 m_hashes_offset; + u32 m_num_hashes; + INSERT_PADDING_BYTES_NOINIT(8); +}; +static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader has wrong size"); + +static constexpr u32 NRO_HEADER_MAGIC = Common::MakeMagic('N', 'R', 'O', '0'); +struct NroHeader { + u32 m_entrypoint_insn; + u32 m_mod_offset; + INSERT_PADDING_BYTES_NOINIT(0x8); + u32 m_magic; + INSERT_PADDING_BYTES_NOINIT(0x4); + u32 m_size; + INSERT_PADDING_BYTES_NOINIT(0x4); + u32 m_text_offset; + u32 m_text_size; + u32 m_ro_offset; + u32 m_ro_size; + u32 m_rw_offset; + u32 m_rw_size; + u32 m_bss_size; + INSERT_PADDING_BYTES_NOINIT(0x4); + ModuleId m_module_id; + INSERT_PADDING_BYTES_NOINIT(0x20); +}; +static_assert(sizeof(NroHeader) == 0x80, "NroHeader has wrong size"); + namespace { // Atmosphere defines as follows: diff --git a/src/core/hle/service/ro/ro_nro_utils.cpp b/src/core/hle/service/ro/ro_nro_utils.cpp deleted file mode 100644 index 268c7f93e7..0000000000 --- a/src/core/hle/service/ro/ro_nro_utils.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/kernel/k_process.h" -#include "core/hle/service/ro/ro_nro_utils.h" -#include "core/hle/service/ro/ro_results.h" - -namespace Service::RO { - -namespace { - -struct ProcessMemoryRegion { - u64 address; - u64 size; -}; - -size_t GetTotalProcessMemoryRegionSize(const ProcessMemoryRegion* regions, size_t num_regions) { - size_t total = 0; - - for (size_t i = 0; i < num_regions; ++i) { - total += regions[i].size; - } - - return total; -} - -size_t SetupNroProcessMemoryRegions(ProcessMemoryRegion* regions, u64 nro_heap_address, - u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size) { - // Reset region count. - size_t num_regions = 0; - - // We always want a region for the nro. - regions[num_regions++] = {nro_heap_address, nro_heap_size}; - - // If we have bss, create a region for bss. - if (bss_heap_size > 0) { - regions[num_regions++] = {bss_heap_address, bss_heap_size}; - } - - return num_regions; -} - -Result SetProcessMemoryPermission(Kernel::KProcess* process, u64 address, u64 size, - Kernel::Svc::MemoryPermission permission) { - auto& page_table = process->GetPageTable(); - - // Set permission. - R_RETURN(page_table.SetProcessMemoryPermission(address, size, permission)); -} - -Result UnmapProcessCodeMemory(Kernel::KProcess* process, u64 process_code_address, - const ProcessMemoryRegion* regions, size_t num_regions) { - // Get the total process memory region size. - const size_t total_size = GetTotalProcessMemoryRegionSize(regions, num_regions); - - auto& page_table = process->GetPageTable(); - - // Unmap each region in order. - size_t cur_offset = total_size; - for (size_t i = 0; i < num_regions; ++i) { - // We want to unmap in reverse order. - const auto& cur_region = regions[num_regions - 1 - i]; - - // Subtract to update the current offset. - cur_offset -= cur_region.size; - - // Unmap. - R_TRY(page_table.UnmapCodeMemory(process_code_address + cur_offset, cur_region.address, - cur_region.size)); - } - - R_SUCCEED(); -} - -Result EnsureGuardPages(Kernel::KProcessPageTable& page_table, u64 map_address, u64 map_size) { - Kernel::KMemoryInfo memory_info; - Kernel::Svc::PageInfo page_info; - - // Ensure page before mapping is unmapped. - R_TRY(page_table.QueryInfo(std::addressof(memory_info), std::addressof(page_info), - map_address - 1)); - R_UNLESS(memory_info.GetSvcState() == Kernel::Svc::MemoryState::Free, - Kernel::ResultInvalidState); - - // Ensure page after mapping is unmapped. - R_TRY(page_table.QueryInfo(std::addressof(memory_info), std::addressof(page_info), - map_address + map_size)); - R_UNLESS(memory_info.GetSvcState() == Kernel::Svc::MemoryState::Free, - Kernel::ResultInvalidState); - - // Successfully verified guard pages. - R_SUCCEED(); -} - -Result MapProcessCodeMemory(u64* out, Kernel::KProcess* process, const ProcessMemoryRegion* regions, - size_t num_regions, std::mt19937_64& generate_random) { - auto& page_table = process->GetPageTable(); - const u64 alias_code_start = - GetInteger(page_table.GetAliasCodeRegionStart()) / Kernel::PageSize; - const u64 alias_code_size = page_table.GetAliasCodeRegionSize() / Kernel::PageSize; - - for (size_t trial = 0; trial < 64; trial++) { - // Generate a new trial address. - const u64 mapped_address = - (alias_code_start + (generate_random() % alias_code_size)) * Kernel::PageSize; - - const auto MapRegions = [&] { - // Map the regions in order. - u64 mapped_size = 0; - for (size_t i = 0; i < num_regions; ++i) { - // If we fail, unmap up to where we've mapped. - ON_RESULT_FAILURE { - R_ASSERT(UnmapProcessCodeMemory(process, mapped_address, regions, i)); - }; - - // Map the current region. - R_TRY(page_table.MapCodeMemory(mapped_address + mapped_size, regions[i].address, - regions[i].size)); - - mapped_size += regions[i].size; - } - - // If we fail, unmap all mapped regions. - ON_RESULT_FAILURE { - R_ASSERT(UnmapProcessCodeMemory(process, mapped_address, regions, num_regions)); - }; - - // Ensure guard pages. - R_RETURN(EnsureGuardPages(page_table, mapped_address, mapped_size)); - }; - - if (R_SUCCEEDED(MapRegions())) { - // Set the output address. - *out = mapped_address; - R_SUCCEED(); - } - } - - // We failed to map anything. - R_THROW(RO::ResultOutOfAddressSpace); -} - -} // namespace - -Result MapNro(u64* out_base_address, Kernel::KProcess* process, u64 nro_heap_address, - u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size, - std::mt19937_64& generate_random) { - // Set up the process memory regions. - std::array regions{}; - const size_t num_regions = SetupNroProcessMemoryRegions( - regions.data(), nro_heap_address, nro_heap_size, bss_heap_address, bss_heap_size); - - // Re-map the nro/bss as code memory in the destination process. - R_RETURN(MapProcessCodeMemory(out_base_address, process, regions.data(), num_regions, - generate_random)); -} - -Result SetNroPerms(Kernel::KProcess* process, u64 base_address, u64 rx_size, u64 ro_size, - u64 rw_size) { - const u64 rx_offset = 0; - const u64 ro_offset = rx_offset + rx_size; - const u64 rw_offset = ro_offset + ro_size; - - R_TRY(SetProcessMemoryPermission(process, base_address + rx_offset, rx_size, - Kernel::Svc::MemoryPermission::ReadExecute)); - R_TRY(SetProcessMemoryPermission(process, base_address + ro_offset, ro_size, - Kernel::Svc::MemoryPermission::Read)); - R_TRY(SetProcessMemoryPermission(process, base_address + rw_offset, rw_size, - Kernel::Svc::MemoryPermission::ReadWrite)); - - R_SUCCEED(); -} - -Result UnmapNro(Kernel::KProcess* process, u64 base_address, u64 nro_heap_address, - u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size) { - // Set up the process memory regions. - std::array regions{}; - const size_t num_regions = SetupNroProcessMemoryRegions( - regions.data(), nro_heap_address, nro_heap_size, bss_heap_address, bss_heap_size); - - // Unmap the nro/bss. - R_RETURN(UnmapProcessCodeMemory(process, base_address, regions.data(), num_regions)); -} - -} // namespace Service::RO diff --git a/src/core/hle/service/ro/ro_nro_utils.h b/src/core/hle/service/ro/ro_nro_utils.h deleted file mode 100644 index f7083a1ba3..0000000000 --- a/src/core/hle/service/ro/ro_nro_utils.h +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -#include "common/common_types.h" - -namespace Kernel { -class KProcess; -} - -union Result; - -namespace Service::RO { - -Result MapNro(u64* out_base_address, Kernel::KProcess* process, u64 nro_heap_address, - u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size, - std::mt19937_64& generate_random); -Result SetNroPerms(Kernel::KProcess* process, u64 base_address, u64 rx_size, u64 ro_size, - u64 rw_size); -Result UnmapNro(Kernel::KProcess* process, u64 base_address, u64 nro_heap_address, - u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size); - -} // namespace Service::RO diff --git a/src/core/hle/service/ro/ro_results.h b/src/core/hle/service/ro/ro_results.h deleted file mode 100644 index 906378bc7f..0000000000 --- a/src/core/hle/service/ro/ro_results.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/result.h" - -namespace Service::RO { - -constexpr Result ResultOutOfAddressSpace{ErrorModule::RO, 2}; -constexpr Result ResultAlreadyLoaded{ErrorModule::RO, 3}; -constexpr Result ResultInvalidNro{ErrorModule::RO, 4}; -constexpr Result ResultInvalidNrr{ErrorModule::RO, 6}; -constexpr Result ResultTooManyNro{ErrorModule::RO, 7}; -constexpr Result ResultTooManyNrr{ErrorModule::RO, 8}; -constexpr Result ResultNotAuthorized{ErrorModule::RO, 9}; -constexpr Result ResultInvalidNrrKind{ErrorModule::RO, 10}; -constexpr Result ResultInternalError{ErrorModule::RO, 1023}; -constexpr Result ResultInvalidAddress{ErrorModule::RO, 1025}; -constexpr Result ResultInvalidSize{ErrorModule::RO, 1026}; -constexpr Result ResultNotLoaded{ErrorModule::RO, 1028}; -constexpr Result ResultNotRegistered{ErrorModule::RO, 1029}; -constexpr Result ResultInvalidSession{ErrorModule::RO, 1030}; -constexpr Result ResultInvalidProcess{ErrorModule::RO, 1031}; - -} // namespace Service::RO diff --git a/src/core/hle/service/ro/ro_types.h b/src/core/hle/service/ro/ro_types.h deleted file mode 100644 index 8e88f43246..0000000000 --- a/src/core/hle/service/ro/ro_types.h +++ /dev/null @@ -1,142 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "common/assert.h" -#include "common/common_funcs.h" -#include "common/common_types.h" - -namespace Service::RO { - -enum class NrrKind : u8 { - User = 0, - JitPlugin = 1, - Count, -}; - -static constexpr size_t ModuleIdSize = 0x20; -struct ModuleId { - std::array data; -}; -static_assert(sizeof(ModuleId) == ModuleIdSize); - -struct NrrCertification { - static constexpr size_t RsaKeySize = 0x100; - static constexpr size_t SignedSize = 0x120; - - u64 program_id_mask; - u64 program_id_pattern; - std::array reserved_10; - std::array modulus; - std::array signature; -}; -static_assert(sizeof(NrrCertification) == - NrrCertification::RsaKeySize + NrrCertification::SignedSize); - -class NrrHeader { -public: - static constexpr u32 Magic = Common::MakeMagic('N', 'R', 'R', '0'); - -public: - bool IsMagicValid() const { - return m_magic == Magic; - } - - bool IsProgramIdValid() const { - return (m_program_id & m_certification.program_id_mask) == - m_certification.program_id_pattern; - } - - NrrKind GetNrrKind() const { - const NrrKind kind = static_cast(m_nrr_kind); - ASSERT(kind < NrrKind::Count); - return kind; - } - - u64 GetProgramId() const { - return m_program_id; - } - - u32 GetSize() const { - return m_size; - } - - u32 GetNumHashes() const { - return m_num_hashes; - } - - size_t GetHashesOffset() const { - return m_hashes_offset; - } - - u32 GetKeyGeneration() const { - return m_key_generation; - } - - const u8* GetCertificationSignature() const { - return m_certification.signature.data(); - } - - const u8* GetCertificationSignedArea() const { - return reinterpret_cast(std::addressof(m_certification)); - } - - const u8* GetCertificationModulus() const { - return m_certification.modulus.data(); - } - - const u8* GetSignature() const { - return m_signature.data(); - } - - size_t GetSignedAreaSize() const { - return m_size - GetSignedAreaOffset(); - } - - static constexpr size_t GetSignedAreaOffset() { - return offsetof(NrrHeader, m_program_id); - } - -private: - u32 m_magic; - u32 m_key_generation; - INSERT_PADDING_BYTES_NOINIT(8); - NrrCertification m_certification; - std::array m_signature; - u64 m_program_id; - u32 m_size; - u8 m_nrr_kind; // 7.0.0+ - INSERT_PADDING_BYTES_NOINIT(3); - u32 m_hashes_offset; - u32 m_num_hashes; - INSERT_PADDING_BYTES_NOINIT(8); -}; -static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader has wrong size"); - -static constexpr u32 NRO_HEADER_MAGIC = Common::MakeMagic('N', 'R', 'O', '0'); -struct NroHeader { - u32 m_entrypoint_insn; - u32 m_mod_offset; - INSERT_PADDING_BYTES_NOINIT(0x8); - u32 m_magic; - INSERT_PADDING_BYTES_NOINIT(0x4); - u32 m_size; - INSERT_PADDING_BYTES_NOINIT(0x4); - u32 m_text_offset; - u32 m_text_size; - u32 m_ro_offset; - u32 m_ro_size; - u32 m_rw_offset; - u32 m_rw_size; - u32 m_bss_size; - INSERT_PADDING_BYTES_NOINIT(0x4); - ModuleId m_module_id; - INSERT_PADDING_BYTES_NOINIT(0x20); -}; -static_assert(sizeof(NroHeader) == 0x80, "NroHeader has wrong size"); - -} // namespace Service::RO diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 588fa3df06..5c196b3218 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -18,7 +18,16 @@ #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm.h" -#include "core/hle/service/sm/sm_controller.h" +#include "common/assert.h" +#include "common/logging.h" +#include "core/core.h" +#include "core/hle/kernel/k_client_port.h" +#include "core/hle/kernel/k_port.h" +#include "core/hle/kernel/k_scoped_resource_reservation.h" +#include "core/hle/kernel/k_server_session.h" +#include "core/hle/kernel/k_session.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/server_manager.h" namespace Service::SM { @@ -27,6 +36,116 @@ constexpr Result ResultAlreadyRegistered(ErrorModule::SM, 4); constexpr Result ResultInvalidServiceName(ErrorModule::SM, 6); constexpr Result ResultNotRegistered(ErrorModule::SM, 7); +class Controller final : public ServiceFramework { +public: + // https://switchbrew.org/wiki/IPC_Marshalling + explicit Controller(Core::System& system_) : ServiceFramework{system_, "IpcController"} {} + ~Controller() override = default; + + void ConvertCurrentObjectToDomain(HLERequestContext& ctx) { + ASSERT_MSG(!ctx.GetManager()->IsDomain(), "Session is already a domain"); + LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId()); + ctx.GetManager()->ConvertToDomainOnRequestEnd(); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(1); // Converted sessions start with 1 request handler + } + + void CloneCurrentObject(HLERequestContext& ctx) { + LOG_DEBUG(Service, "called"); + + auto session_manager = ctx.GetManager(); + + // FIXME: this is duplicated from the SVC, it should just call it instead + // once this is a proper process + + // Reserve a new session from the process resource limit. + Kernel::KScopedResourceReservation session_reservation(system.Kernel(), Kernel::GetCurrentProcessPointer(kernel), Kernel::LimitableResource::SessionCountMax); + ASSERT(session_reservation.Succeeded()); + + // Create the session. + Kernel::KSession* session = Kernel::KSession::Create(kernel); + ASSERT(session != nullptr); + + // Initialize the session. + session->Initialize(kernel, nullptr, 0); + + // Commit the session reservation. + session_reservation.Commit(); + + // Register the session. + Kernel::KSession::Register(kernel, session); + + // Register with server manager. + session_manager->GetServerManager().RegisterSession(&session->GetServerSession(), + session_manager); + + // We succeeded. + IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; + rb.Push(ResultSuccess); + rb.PushMoveObjects(ctx, session->GetClientSession()); + } + + void CloneCurrentObjectEx(HLERequestContext& ctx) { + LOG_DEBUG(Service, "called"); + + CloneCurrentObject(ctx); + } + + void QueryPointerBufferSize(HLERequestContext& ctx) { + LOG_DEBUG(Service, "called"); + + auto* process = Kernel::GetCurrentProcessPointer(kernel); + ASSERT(process != nullptr); + + u32 buffer_size = process->GetPointerBufferSize(); + if (buffer_size > (std::numeric_limits::max)()) { + LOG_WARNING(Service, "Pointer buffer size exceeds u16 max, clamping"); + buffer_size = (std::numeric_limits::max)(); + } + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(static_cast(buffer_size)); + } + + void SetPointerBufferSize(HLERequestContext& ctx) { + LOG_DEBUG(Service, "called"); + + auto* process = Kernel::GetCurrentProcessPointer(kernel); + ASSERT(process != nullptr); + + IPC::RequestParser rp{ctx}; + + u32 requested_size = rp.PopRaw(); + + if (requested_size > (std::numeric_limits::max)()) { + LOG_WARNING(Service, "Requested pointer buffer size too large, clamping to 0xFFFF"); + requested_size = (std::numeric_limits::max)(); + } + + process->SetPointerBufferSize(requested_size); + + LOG_INFO(Service, "Pointer buffer size dynamically updated to {:#x} bytes by process", requested_size); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } + + std::optional FindRequest(u32 key) override { + return HandlerTableGenerateWithFind(key, functions); + } + static constexpr auto functions = CreateStaticMap( + FunctionInfo{0, &Controller::ConvertCurrentObjectToDomain, "ConvertCurrentObjectToDomain"}, + FunctionInfo{1, nullptr, "CopyFromCurrentDomain"}, + FunctionInfo{2, &Controller::CloneCurrentObject, "CloneCurrentObject"}, + FunctionInfo{3, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"}, + FunctionInfo{4, &Controller::CloneCurrentObjectEx, "CloneCurrentObjectEx"}, + FunctionInfo{5, &Controller::SetPointerBufferSize, "SetPointerBufferSize"} //TODO: where does this come from + ); +}; + ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} { controller_interface = std::make_unique(kernel.System()); } diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp deleted file mode 100644 index 1cbb27c3a4..0000000000 --- a/src/core/hle/service/sm/sm_controller.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/assert.h" -#include "common/logging.h" -#include "core/core.h" -#include "core/hle/kernel/k_client_port.h" -#include "core/hle/kernel/k_port.h" -#include "core/hle/kernel/k_scoped_resource_reservation.h" -#include "core/hle/kernel/k_server_session.h" -#include "core/hle/kernel/k_session.h" -#include "core/hle/service/ipc_helpers.h" -#include "core/hle/service/server_manager.h" -#include "core/hle/service/sm/sm_controller.h" - -namespace Service::SM { - -void Controller::ConvertCurrentObjectToDomain(HLERequestContext& ctx) { - ASSERT_MSG(!ctx.GetManager()->IsDomain(), "Session is already a domain"); - LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId()); - ctx.GetManager()->ConvertToDomainOnRequestEnd(); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(1); // Converted sessions start with 1 request handler -} - -void Controller::CloneCurrentObject(HLERequestContext& ctx) { - LOG_DEBUG(Service, "called"); - - auto session_manager = ctx.GetManager(); - - // FIXME: this is duplicated from the SVC, it should just call it instead - // once this is a proper process - - // Reserve a new session from the process resource limit. - Kernel::KScopedResourceReservation session_reservation(system.Kernel(), Kernel::GetCurrentProcessPointer(kernel), Kernel::LimitableResource::SessionCountMax); - ASSERT(session_reservation.Succeeded()); - - // Create the session. - Kernel::KSession* session = Kernel::KSession::Create(kernel); - ASSERT(session != nullptr); - - // Initialize the session. - session->Initialize(kernel, nullptr, 0); - - // Commit the session reservation. - session_reservation.Commit(); - - // Register the session. - Kernel::KSession::Register(kernel, session); - - // Register with server manager. - session_manager->GetServerManager().RegisterSession(&session->GetServerSession(), - session_manager); - - // We succeeded. - IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; - rb.Push(ResultSuccess); - rb.PushMoveObjects(ctx, session->GetClientSession()); -} - -void Controller::CloneCurrentObjectEx(HLERequestContext& ctx) { - LOG_DEBUG(Service, "called"); - - CloneCurrentObject(ctx); -} - -void Controller::QueryPointerBufferSize(HLERequestContext& ctx) { - LOG_DEBUG(Service, "called"); - - auto* process = Kernel::GetCurrentProcessPointer(kernel); - ASSERT(process != nullptr); - - u32 buffer_size = process->GetPointerBufferSize(); - if (buffer_size > (std::numeric_limits::max)()) { - LOG_WARNING(Service, "Pointer buffer size exceeds u16 max, clamping"); - buffer_size = (std::numeric_limits::max)(); - } - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(static_cast(buffer_size)); -} - -void Controller::SetPointerBufferSize(HLERequestContext& ctx) { - LOG_DEBUG(Service, "called"); - - auto* process = Kernel::GetCurrentProcessPointer(kernel); - ASSERT(process != nullptr); - - IPC::RequestParser rp{ctx}; - - u32 requested_size = rp.PopRaw(); - - if (requested_size > (std::numeric_limits::max)()) { - LOG_WARNING(Service, "Requested pointer buffer size too large, clamping to 0xFFFF"); - requested_size = (std::numeric_limits::max)(); - } - - process->SetPointerBufferSize(requested_size); - - LOG_INFO(Service, "Pointer buffer size dynamically updated to {:#x} bytes by process", requested_size); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} - - -// https://switchbrew.org/wiki/IPC_Marshalling -Controller::Controller(Core::System& system_) : ServiceFramework{system_, "IpcController"} { -} - -Controller::~Controller() = default; - -} // namespace Service::SM diff --git a/src/core/hle/service/sm/sm_controller.h b/src/core/hle/service/sm/sm_controller.h deleted file mode 100644 index 8109d93f06..0000000000 --- a/src/core/hle/service/sm/sm_controller.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/service.h" - -namespace Core { -class System; -} - -namespace Service::SM { - -class Controller final : public ServiceFramework { -public: - explicit Controller(Core::System& system_); - ~Controller() override; - -private: - void ConvertCurrentObjectToDomain(HLERequestContext& ctx); - void CloneCurrentObject(HLERequestContext& ctx); - void CloneCurrentObjectEx(HLERequestContext& ctx); - void QueryPointerBufferSize(HLERequestContext& ctx); - void SetPointerBufferSize(HLERequestContext& ctx); - - std::optional FindRequest(u32 key) override { - return HandlerTableGenerateWithFind(key, functions); - } - static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, &Controller::ConvertCurrentObjectToDomain, "ConvertCurrentObjectToDomain"}, - FunctionInfo{1, nullptr, "CopyFromCurrentDomain"}, - FunctionInfo{2, &Controller::CloneCurrentObject, "CloneCurrentObject"}, - FunctionInfo{3, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"}, - FunctionInfo{4, &Controller::CloneCurrentObjectEx, "CloneCurrentObjectEx"}, - FunctionInfo{5, &Controller::SetPointerBufferSize, "SetPointerBufferSize"} //TODO: where does this come from - ); -}; - -} // namespace Service::SM diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp index 27e04aab8b..f7dc15e3db 100644 --- a/src/core/hle/service/usb/usb.cpp +++ b/src/core/hle/service/usb/usb.cpp @@ -20,20 +20,20 @@ public: explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "AddEndpoint"}, - FunctionInfo{1, nullptr, "GetSetupEvent"}, - FunctionInfo{2, nullptr, "GetSetupPacket"}, - FunctionInfo{3, nullptr, "Enable"}, - FunctionInfo{4, nullptr, "Disable"}, - FunctionInfo{5, nullptr, "CtrlIn"}, - FunctionInfo{6, nullptr, "CtrlOut"}, - FunctionInfo{7, nullptr, "GetCtrlInCompletionEvent"}, - FunctionInfo{8, nullptr, "GetCtrlInUrbReport"}, - FunctionInfo{9, nullptr, "GetCtrlOutCompletionEvent"}, - FunctionInfo{10, nullptr, "GetCtrlOutUrbReport"}, - FunctionInfo{11, nullptr, "CtrlStall"}, - FunctionInfo{12, nullptr, "AppendConfigurationData"} - ); + FunctionInfo{0, nullptr, "AddEndpoint"}, + FunctionInfo{1, nullptr, "GetSetupEvent"}, + FunctionInfo{2, nullptr, "GetSetupPacket"}, + FunctionInfo{3, nullptr, "Enable"}, + FunctionInfo{4, nullptr, "Disable"}, + FunctionInfo{5, nullptr, "CtrlIn"}, + FunctionInfo{6, nullptr, "CtrlOut"}, + FunctionInfo{7, nullptr, "GetCtrlInCompletionEvent"}, + FunctionInfo{8, nullptr, "GetCtrlInUrbReport"}, + FunctionInfo{9, nullptr, "GetCtrlOutCompletionEvent"}, + FunctionInfo{10, nullptr, "GetCtrlOutUrbReport"}, + FunctionInfo{11, nullptr, "CtrlStall"}, + FunctionInfo{12, nullptr, "AppendConfigurationData"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -44,8 +44,8 @@ public: explicit IDsRootSession(Core::System& system_) : ServiceFramework{system_, "usb:ds"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "OpenDsService"} - ); + FunctionInfo{0, nullptr, "OpenDsService"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -57,16 +57,16 @@ public: : ServiceFramework{system_, "IClientEpSession"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "ReOpen"}, - FunctionInfo{1, nullptr, "Close"}, - FunctionInfo{2, nullptr, "GetCompletionEvent"}, - FunctionInfo{3, nullptr, "PopulateRing"}, - FunctionInfo{4, nullptr, "PostBufferAsync"}, - FunctionInfo{5, nullptr, "GetXferReport"}, - FunctionInfo{6, nullptr, "PostBufferMultiAsync"}, - FunctionInfo{7, nullptr, "CreateSmmuSpace"}, - FunctionInfo{8, nullptr, "ShareReportRing"} - ); + FunctionInfo{0, nullptr, "ReOpen"}, + FunctionInfo{1, nullptr, "Close"}, + FunctionInfo{2, nullptr, "GetCompletionEvent"}, + FunctionInfo{3, nullptr, "PopulateRing"}, + FunctionInfo{4, nullptr, "PostBufferAsync"}, + FunctionInfo{5, nullptr, "GetXferReport"}, + FunctionInfo{6, nullptr, "PostBufferMultiAsync"}, + FunctionInfo{7, nullptr, "CreateSmmuSpace"}, + FunctionInfo{8, nullptr, "ShareReportRing"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -78,17 +78,17 @@ public: : ServiceFramework{system_, "IClientIfSession"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "GetStateChangeEvent"}, - FunctionInfo{1, nullptr, "SetInterface"}, - FunctionInfo{2, nullptr, "GetInterface"}, - FunctionInfo{3, nullptr, "GetAlternateInterface"}, - FunctionInfo{4, nullptr, "GetCurrentFrame"}, - FunctionInfo{5, nullptr, "CtrlXferAsync"}, - FunctionInfo{6, nullptr, "GetCtrlXferCompletionEvent"}, - FunctionInfo{7, nullptr, "GetCtrlXferReport"}, - FunctionInfo{8, nullptr, "ResetDevice"}, - FunctionInfo{9, nullptr, "OpenUsbEp"} - ); + FunctionInfo{0, nullptr, "GetStateChangeEvent"}, + FunctionInfo{1, nullptr, "SetInterface"}, + FunctionInfo{2, nullptr, "GetInterface"}, + FunctionInfo{3, nullptr, "GetAlternateInterface"}, + FunctionInfo{4, nullptr, "GetCurrentFrame"}, + FunctionInfo{5, nullptr, "CtrlXferAsync"}, + FunctionInfo{6, nullptr, "GetCtrlXferCompletionEvent"}, + FunctionInfo{7, nullptr, "GetCtrlXferReport"}, + FunctionInfo{8, nullptr, "ResetDevice"}, + FunctionInfo{9, nullptr, "OpenUsbEp"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -99,16 +99,16 @@ public: explicit IClientRootSession(Core::System& system_) : ServiceFramework{system_, "usb:hs"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "BindClientProcess"}, - FunctionInfo{1, nullptr, "QueryAllInterfaces"}, - FunctionInfo{2, nullptr, "QueryAvailableInterfaces"}, - FunctionInfo{3, nullptr, "QueryAcquiredInterfaces"}, - FunctionInfo{4, nullptr, "CreateInterfaceAvailableEvent"}, - FunctionInfo{5, nullptr, "DestroyInterfaceAvailableEvent"}, - FunctionInfo{6, nullptr, "GetInterfaceStateChangeEvent"}, - FunctionInfo{7, nullptr, "AcquireUsbIf"}, - FunctionInfo{8, nullptr, "SetTestMode"} - ); + FunctionInfo{0, nullptr, "BindClientProcess"}, + FunctionInfo{1, nullptr, "QueryAllInterfaces"}, + FunctionInfo{2, nullptr, "QueryAvailableInterfaces"}, + FunctionInfo{3, nullptr, "QueryAcquiredInterfaces"}, + FunctionInfo{4, nullptr, "CreateInterfaceAvailableEvent"}, + FunctionInfo{5, nullptr, "DestroyInterfaceAvailableEvent"}, + FunctionInfo{6, nullptr, "GetInterfaceStateChangeEvent"}, + FunctionInfo{7, nullptr, "AcquireUsbIf"}, + FunctionInfo{8, nullptr, "SetTestMode"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -119,14 +119,14 @@ public: explicit IPdSession(Core::System& system_) : ServiceFramework{system_, "IPdSession"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "BindNoticeEvent"}, - FunctionInfo{1, nullptr, "UnbindNoticeEvent"}, - FunctionInfo{2, nullptr, "GetStatus"}, - FunctionInfo{3, nullptr, "GetNotice"}, - FunctionInfo{4, nullptr, "EnablePowerRequestNotice"}, - FunctionInfo{5, nullptr, "DisablePowerRequestNotice"}, - FunctionInfo{6, nullptr, "ReplyPowerRequest"} - ); + FunctionInfo{0, nullptr, "BindNoticeEvent"}, + FunctionInfo{1, nullptr, "UnbindNoticeEvent"}, + FunctionInfo{2, nullptr, "GetStatus"}, + FunctionInfo{3, nullptr, "GetNotice"}, + FunctionInfo{4, nullptr, "EnablePowerRequestNotice"}, + FunctionInfo{5, nullptr, "DisablePowerRequestNotice"}, + FunctionInfo{6, nullptr, "ReplyPowerRequest"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -160,16 +160,16 @@ public: : ServiceFramework{system_, "IPdCradleSession"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "SetCradleVdo"}, - FunctionInfo{1, nullptr, "GetCradleVdo"}, - FunctionInfo{2, nullptr, "ResetCradleUsbHub"}, - FunctionInfo{3, nullptr, "GetHostPdcFirmwareType"}, - FunctionInfo{4, nullptr, "GetHostPdcFirmwareRevision"}, - FunctionInfo{5, nullptr, "GetHostPdcManufactureId"}, - FunctionInfo{6, nullptr, "GetHostPdcDeviceId"}, - FunctionInfo{7, nullptr, "EnableCradleRecovery"}, - FunctionInfo{8, nullptr, "DisableCradleRecovery"} - ); + FunctionInfo{0, nullptr, "SetCradleVdo"}, + FunctionInfo{1, nullptr, "GetCradleVdo"}, + FunctionInfo{2, nullptr, "ResetCradleUsbHub"}, + FunctionInfo{3, nullptr, "GetHostPdcFirmwareType"}, + FunctionInfo{4, nullptr, "GetHostPdcFirmwareRevision"}, + FunctionInfo{5, nullptr, "GetHostPdcManufactureId"}, + FunctionInfo{6, nullptr, "GetHostPdcDeviceId"}, + FunctionInfo{7, nullptr, "EnableCradleRecovery"}, + FunctionInfo{8, nullptr, "DisableCradleRecovery"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -202,13 +202,13 @@ public: explicit IPmMainService(Core::System& system_) : ServiceFramework{system_, "usb:pm"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "GetPowerEvent"}, - FunctionInfo{1, nullptr, "GetPowerState"}, - FunctionInfo{2, nullptr, "GetDataEvent"}, - FunctionInfo{3, nullptr, "GetDataRole"}, - FunctionInfo{4, nullptr, "SetDiagData"}, - FunctionInfo{5, nullptr, "GetDiagData"} - ); + FunctionInfo{0, nullptr, "GetPowerEvent"}, + FunctionInfo{1, nullptr, "GetPowerState"}, + FunctionInfo{2, nullptr, "GetDataEvent"}, + FunctionInfo{3, nullptr, "GetDataRole"}, + FunctionInfo{4, nullptr, "SetDiagData"}, + FunctionInfo{5, nullptr, "GetDiagData"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -219,8 +219,8 @@ public: explicit IPdManufactureManager(Core::System& system_) : ServiceFramework{system_, "usb:pd:m"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "OpenManufactureSession"} - ); + FunctionInfo{0, nullptr, "OpenManufactureSession"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -231,9 +231,9 @@ public: explicit IQdbManager(Core::System& system_) : ServiceFramework{system_, "usb:qdb"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "ImportQuirkDevices"}, - FunctionInfo{1, nullptr, "HasQuirk"} - ); + FunctionInfo{0, nullptr, "ImportQuirkDevices"}, + FunctionInfo{1, nullptr, "HasQuirk"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } @@ -244,9 +244,9 @@ public: explicit IPmObserverService(Core::System& system_) : ServiceFramework{system_, "usb:obsv"} {} static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "GetTopologyChangeEvent"}, - FunctionInfo{1, nullptr, "GetFlattenedTopology"} - ); + FunctionInfo{0, nullptr, "GetTopologyChangeEvent"}, + FunctionInfo{1, nullptr, "GetFlattenedTopology"} + ); std::optional FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } diff --git a/src/core/hle/service/wlan/wlan.cpp b/src/core/hle/service/wlan/wlan.cpp index c4bbd87f6c..fa68ff51ba 100644 --- a/src/core/hle/service/wlan/wlan.cpp +++ b/src/core/hle/service/wlan/wlan.cpp @@ -22,103 +22,103 @@ public: return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "OpenMasterMode" }, - FunctionInfo{0, nullptr, "OpenMode_2" }, - FunctionInfo{1, nullptr, "CloseMasterMode" }, - FunctionInfo{1, nullptr, "CloseMode_2" }, - FunctionInfo{2, nullptr, "OpenClientMode" }, - FunctionInfo{2, nullptr, "GetMacAddress_2" }, - FunctionInfo{3, nullptr, "CloseClientMode" }, - FunctionInfo{3, nullptr, "CreateBss" }, - FunctionInfo{4, nullptr, "OpenSpectatorMode" }, - FunctionInfo{4, nullptr, "DestroyBss" }, - FunctionInfo{5, nullptr, "CloseSpectatorMode" }, - FunctionInfo{5, nullptr, "StartScan_2" }, - FunctionInfo{6, nullptr, "GetMacAddress_2" }, - FunctionInfo{6, nullptr, "StopScan_2" }, - FunctionInfo{7, nullptr, "CreateBss" }, - FunctionInfo{7, nullptr, "Connect_2" }, - FunctionInfo{8, nullptr, "DestroyBss" }, - FunctionInfo{8, nullptr, "CancelConnect_2" }, - FunctionInfo{9, nullptr, "StartScan_2" }, - FunctionInfo{9, nullptr, "Join" }, - FunctionInfo{10, nullptr, "StopScan_2" }, - FunctionInfo{10, nullptr, "CancelJoin" }, - FunctionInfo{11, nullptr, "Connect_2" }, - FunctionInfo{11, nullptr, "Disconnect_2" }, - FunctionInfo{12, nullptr, "CancelConnect_2" }, - FunctionInfo{12, nullptr, "SetBeaconLostCount" }, - FunctionInfo{13, nullptr, "Join" }, - FunctionInfo{13, nullptr, "GetSystemEvent_2" }, - FunctionInfo{14, nullptr, "CancelJoin" }, - FunctionInfo{14, nullptr, "GetConnectionStatus_2" }, - FunctionInfo{15, nullptr, "Disconnect_2" }, - FunctionInfo{15, nullptr, "GetClientStatus" }, - FunctionInfo{16, nullptr, "SetBeaconLostCount" }, - FunctionInfo{16, nullptr, "GetBssIndicationEvent" }, - FunctionInfo{17, nullptr, "GetSystemEvent_2" }, - FunctionInfo{17, nullptr, "GetBssIndicationInfo" }, - FunctionInfo{18, nullptr, "GetConnectionStatus_2" }, - FunctionInfo{18, nullptr, "GetState_2" }, - FunctionInfo{19, nullptr, "GetClientStatus" }, - FunctionInfo{19, nullptr, "GetAllowedChannels" }, - FunctionInfo{20, nullptr, "GetBssIndicationEvent" }, - FunctionInfo{20, nullptr, "AddIe" }, - FunctionInfo{21, nullptr, "GetBssIndicationInfo" }, - FunctionInfo{21, nullptr, "DeleteIe" }, - FunctionInfo{22, nullptr, "GetState_2" }, - FunctionInfo{22, nullptr, "PutFrameRaw" }, - FunctionInfo{23, nullptr, "GetAllowedChannels" }, - FunctionInfo{23, nullptr, "CancelGetFrame" }, - FunctionInfo{24, nullptr, "AddIe" }, - FunctionInfo{24, nullptr, "CreateRxEntry" }, - FunctionInfo{25, nullptr, "DeleteIe" }, - FunctionInfo{25, nullptr, "DeleteRxEntry" }, - FunctionInfo{26, nullptr, "PutFrameRaw" }, - FunctionInfo{26, nullptr, "AddEthertypeToRxEntry" }, - FunctionInfo{27, nullptr, "CancelGetFrame" }, - FunctionInfo{27, nullptr, "DeleteEthertypeFromRxEntry" }, - FunctionInfo{28, nullptr, "CreateRxEntry" }, - FunctionInfo{28, nullptr, "AddMatchingDataToRxEntry" }, - FunctionInfo{29, nullptr, "DeleteRxEntry" }, - FunctionInfo{29, nullptr, "RemoveMatchingDataFromRxEntry" }, - FunctionInfo{30, nullptr, "AddEthertypeToRxEntry" }, - FunctionInfo{30, nullptr, "GetScanResult_2" }, - FunctionInfo{31, nullptr, "DeleteEthertypeFromRxEntry" }, - FunctionInfo{31, nullptr, "PutActionFrameOneShot" }, - FunctionInfo{32, nullptr, "AddMatchingDataToRxEntry" }, - FunctionInfo{32, nullptr, "SetActionFrameWithBeacon" }, - FunctionInfo{33, nullptr, "RemoveMatchingDataFromRxEntry" }, - FunctionInfo{33, nullptr, "CancelActionFrameWithBeacon" }, - FunctionInfo{34, nullptr, "GetScanResult_2" }, - FunctionInfo{34, nullptr, "CreateRxEntryForActionFrame" }, - FunctionInfo{35, nullptr, "PutActionFrameOneShot" }, - FunctionInfo{35, nullptr, "DeleteRxEntryForActionFrame" }, - FunctionInfo{36, nullptr, "SetActionFrameWithBeacon" }, - FunctionInfo{36, nullptr, "AddSubtypeToRxEntryForActionFrame" }, - FunctionInfo{37, nullptr, "CancelActionFrameWithBeacon" }, - FunctionInfo{37, nullptr, "DeleteSubtypeFromRxEntryForActionFrame" }, - FunctionInfo{38, nullptr, "CreateRxEntryForActionFrame" }, - FunctionInfo{38, nullptr, "CancelGetActionFrame" }, - FunctionInfo{39, nullptr, "DeleteRxEntryForActionFrame" }, - FunctionInfo{39, nullptr, "GetRssi_2" }, - FunctionInfo{40, nullptr, "AddSubtypeToRxEntryForActionFrame" }, - FunctionInfo{40, nullptr, "SetMaxAssociationNumber" }, - FunctionInfo{41, nullptr, "DeleteSubtypeFromRxEntryForActionFrame" }, - FunctionInfo{41, nullptr, "Cmd41" }, - FunctionInfo{42, nullptr, "CancelGetActionFrame" }, - FunctionInfo{42, nullptr, "Cmd42" }, - FunctionInfo{43, nullptr, "GetRssi_2" }, - FunctionInfo{43, nullptr, "Cmd43" }, - FunctionInfo{44, nullptr, "SetMaxAssociationNumber" }, - FunctionInfo{45, nullptr, "OpenLcsMasterMode" }, - FunctionInfo{46, nullptr, "CloseLcsMasterMode" }, - FunctionInfo{47, nullptr, "OpenLcsClientMode" }, - FunctionInfo{48, nullptr, "CloseLcsClientMode" }, - FunctionInfo{49, nullptr, "GetChannelStats" }, - FunctionInfo{50, nullptr, "Cmd50" }, - FunctionInfo{51, nullptr, "Cmd51" }, - FunctionInfo{52, nullptr, "Cmd52" } + FunctionInfo{0, nullptr, "OpenMasterMode"}, + FunctionInfo{0, nullptr, "OpenMode_2"}, + FunctionInfo{1, nullptr, "CloseMasterMode"}, + FunctionInfo{1, nullptr, "CloseMode_2"}, + FunctionInfo{2, nullptr, "OpenClientMode"}, + FunctionInfo{2, nullptr, "GetMacAddress_2"}, + FunctionInfo{3, nullptr, "CloseClientMode"}, + FunctionInfo{3, nullptr, "CreateBss"}, + FunctionInfo{4, nullptr, "OpenSpectatorMode"}, + FunctionInfo{4, nullptr, "DestroyBss"}, + FunctionInfo{5, nullptr, "CloseSpectatorMode"}, + FunctionInfo{5, nullptr, "StartScan_2"}, + FunctionInfo{6, nullptr, "GetMacAddress_2"}, + FunctionInfo{6, nullptr, "StopScan_2"}, + FunctionInfo{7, nullptr, "CreateBss"}, + FunctionInfo{7, nullptr, "Connect_2"}, + FunctionInfo{8, nullptr, "DestroyBss"}, + FunctionInfo{8, nullptr, "CancelConnect_2"}, + FunctionInfo{9, nullptr, "StartScan_2"}, + FunctionInfo{9, nullptr, "Join"}, + FunctionInfo{10, nullptr, "StopScan_2"}, + FunctionInfo{10, nullptr, "CancelJoin"}, + FunctionInfo{11, nullptr, "Connect_2"}, + FunctionInfo{11, nullptr, "Disconnect_2"}, + FunctionInfo{12, nullptr, "CancelConnect_2"}, + FunctionInfo{12, nullptr, "SetBeaconLostCount"}, + FunctionInfo{13, nullptr, "Join"}, + FunctionInfo{13, nullptr, "GetSystemEvent_2"}, + FunctionInfo{14, nullptr, "CancelJoin"}, + FunctionInfo{14, nullptr, "GetConnectionStatus_2"}, + FunctionInfo{15, nullptr, "Disconnect_2"}, + FunctionInfo{15, nullptr, "GetClientStatus"}, + FunctionInfo{16, nullptr, "SetBeaconLostCount"}, + FunctionInfo{16, nullptr, "GetBssIndicationEvent"}, + FunctionInfo{17, nullptr, "GetSystemEvent_2"}, + FunctionInfo{17, nullptr, "GetBssIndicationInfo"}, + FunctionInfo{18, nullptr, "GetConnectionStatus_2"}, + FunctionInfo{18, nullptr, "GetState_2"}, + FunctionInfo{19, nullptr, "GetClientStatus"}, + FunctionInfo{19, nullptr, "GetAllowedChannels"}, + FunctionInfo{20, nullptr, "GetBssIndicationEvent"}, + FunctionInfo{20, nullptr, "AddIe"}, + FunctionInfo{21, nullptr, "GetBssIndicationInfo"}, + FunctionInfo{21, nullptr, "DeleteIe"}, + FunctionInfo{22, nullptr, "GetState_2"}, + FunctionInfo{22, nullptr, "PutFrameRaw"}, + FunctionInfo{23, nullptr, "GetAllowedChannels"}, + FunctionInfo{23, nullptr, "CancelGetFrame"}, + FunctionInfo{24, nullptr, "AddIe"}, + FunctionInfo{24, nullptr, "CreateRxEntry"}, + FunctionInfo{25, nullptr, "DeleteIe"}, + FunctionInfo{25, nullptr, "DeleteRxEntry"}, + FunctionInfo{26, nullptr, "PutFrameRaw"}, + FunctionInfo{26, nullptr, "AddEthertypeToRxEntry"}, + FunctionInfo{27, nullptr, "CancelGetFrame"}, + FunctionInfo{27, nullptr, "DeleteEthertypeFromRxEntry"}, + FunctionInfo{28, nullptr, "CreateRxEntry"}, + FunctionInfo{28, nullptr, "AddMatchingDataToRxEntry"}, + FunctionInfo{29, nullptr, "DeleteRxEntry"}, + FunctionInfo{29, nullptr, "RemoveMatchingDataFromRxEntry"}, + FunctionInfo{30, nullptr, "AddEthertypeToRxEntry"}, + FunctionInfo{30, nullptr, "GetScanResult_2"}, + FunctionInfo{31, nullptr, "DeleteEthertypeFromRxEntry"}, + FunctionInfo{31, nullptr, "PutActionFrameOneShot"}, + FunctionInfo{32, nullptr, "AddMatchingDataToRxEntry"}, + FunctionInfo{32, nullptr, "SetActionFrameWithBeacon"}, + FunctionInfo{33, nullptr, "RemoveMatchingDataFromRxEntry"}, + FunctionInfo{33, nullptr, "CancelActionFrameWithBeacon"}, + FunctionInfo{34, nullptr, "GetScanResult_2"}, + FunctionInfo{34, nullptr, "CreateRxEntryForActionFrame"}, + FunctionInfo{35, nullptr, "PutActionFrameOneShot"}, + FunctionInfo{35, nullptr, "DeleteRxEntryForActionFrame"}, + FunctionInfo{36, nullptr, "SetActionFrameWithBeacon"}, + FunctionInfo{36, nullptr, "AddSubtypeToRxEntryForActionFrame"}, + FunctionInfo{37, nullptr, "CancelActionFrameWithBeacon"}, + FunctionInfo{37, nullptr, "DeleteSubtypeFromRxEntryForActionFrame"}, + FunctionInfo{38, nullptr, "CreateRxEntryForActionFrame"}, + FunctionInfo{38, nullptr, "CancelGetActionFrame"}, + FunctionInfo{39, nullptr, "DeleteRxEntryForActionFrame"}, + FunctionInfo{39, nullptr, "GetRssi_2"}, + FunctionInfo{40, nullptr, "AddSubtypeToRxEntryForActionFrame"}, + FunctionInfo{40, nullptr, "SetMaxAssociationNumber"}, + FunctionInfo{41, nullptr, "DeleteSubtypeFromRxEntryForActionFrame"}, + FunctionInfo{41, nullptr, "Cmd41"}, + FunctionInfo{42, nullptr, "CancelGetActionFrame"}, + FunctionInfo{42, nullptr, "Cmd42"}, + FunctionInfo{43, nullptr, "GetRssi_2"}, + FunctionInfo{43, nullptr, "Cmd43"}, + FunctionInfo{44, nullptr, "SetMaxAssociationNumber"}, + FunctionInfo{45, nullptr, "OpenLcsMasterMode"}, + FunctionInfo{46, nullptr, "CloseLcsMasterMode"}, + FunctionInfo{47, nullptr, "OpenLcsClientMode"}, + FunctionInfo{48, nullptr, "CloseLcsClientMode"}, + FunctionInfo{49, nullptr, "GetChannelStats"}, + FunctionInfo{50, nullptr, "Cmd50"}, + FunctionInfo{51, nullptr, "Cmd51"}, + FunctionInfo{52, nullptr, "Cmd52"} ); }; @@ -174,19 +174,19 @@ public: return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "PutFrameRaw_2" }, - FunctionInfo{1, nullptr, "CancelGetFrame_2" }, - FunctionInfo{2, nullptr, "CreateRxEntry_2" }, - FunctionInfo{3, nullptr, "DeleteRxEntry_2" }, - FunctionInfo{4, nullptr, "AddEthertypeToRxEntry_2" }, - FunctionInfo{5, nullptr, "DeleteEthertypeFromRxEntry_2" }, - FunctionInfo{6, nullptr, "GetMacAddress_3" }, - FunctionInfo{7, nullptr, "SwitchTsfTimerFunction" }, - FunctionInfo{8, nullptr, "GetDeltaTimeBetweenSystemAndTsf" }, - FunctionInfo{9, nullptr, "RegisterSharedMemory" }, - FunctionInfo{10, nullptr, "UnregisterSharedMemory" }, - FunctionInfo{11, nullptr, "EnableSharedMemory" }, - FunctionInfo{12, nullptr, "SetMulticastFilter" } + FunctionInfo{0, nullptr, "PutFrameRaw_2"}, + FunctionInfo{1, nullptr, "CancelGetFrame_2"}, + FunctionInfo{2, nullptr, "CreateRxEntry_2"}, + FunctionInfo{3, nullptr, "DeleteRxEntry_2"}, + FunctionInfo{4, nullptr, "AddEthertypeToRxEntry_2"}, + FunctionInfo{5, nullptr, "DeleteEthertypeFromRxEntry_2"}, + FunctionInfo{6, nullptr, "GetMacAddress_3"}, + FunctionInfo{7, nullptr, "SwitchTsfTimerFunction"}, + FunctionInfo{8, nullptr, "GetDeltaTimeBetweenSystemAndTsf"}, + FunctionInfo{9, nullptr, "RegisterSharedMemory"}, + FunctionInfo{10, nullptr, "UnregisterSharedMemory"}, + FunctionInfo{11, nullptr, "EnableSharedMemory"}, + FunctionInfo{12, nullptr, "SetMulticastFilter"} ); }; @@ -200,34 +200,34 @@ public: return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "Cmd0" }, - FunctionInfo{1, nullptr, "Cmd1" }, - FunctionInfo{2, nullptr, "Cmd2" }, - FunctionInfo{3, nullptr, "Cmd3" }, - FunctionInfo{4, nullptr, "Cmd4" }, - FunctionInfo{5, nullptr, "Cmd5" }, - FunctionInfo{6, nullptr, "Cmd6" }, - FunctionInfo{7, nullptr, "Cmd7" }, - FunctionInfo{8, nullptr, "Cmd8" }, - FunctionInfo{9, nullptr, "Cmd9" }, - FunctionInfo{10, nullptr, "Cmd10" }, - FunctionInfo{11, nullptr, "Cmd11" }, - FunctionInfo{12, nullptr, "Cmd12" }, - FunctionInfo{13, nullptr, "Cmd13" }, - FunctionInfo{14, nullptr, "Cmd14" }, - FunctionInfo{15, nullptr, "Cmd15" }, - FunctionInfo{16, nullptr, "Cmd16" }, - FunctionInfo{17, nullptr, "Cmd17" }, - FunctionInfo{18, nullptr, "Cmd18" }, - FunctionInfo{19, nullptr, "Cmd19" }, - FunctionInfo{20, nullptr, "Cmd20" }, - FunctionInfo{21, nullptr, "Cmd21" }, - FunctionInfo{22, nullptr, "Cmd22" }, - FunctionInfo{23, nullptr, "Cmd23" }, - FunctionInfo{24, nullptr, "Cmd24" }, - FunctionInfo{25, nullptr, "Cmd25" }, - FunctionInfo{26, nullptr, "Cmd26" }, - FunctionInfo{27, nullptr, "Cmd27" } + FunctionInfo{0, nullptr, "Cmd0"}, + FunctionInfo{1, nullptr, "Cmd1"}, + FunctionInfo{2, nullptr, "Cmd2"}, + FunctionInfo{3, nullptr, "Cmd3"}, + FunctionInfo{4, nullptr, "Cmd4"}, + FunctionInfo{5, nullptr, "Cmd5"}, + FunctionInfo{6, nullptr, "Cmd6"}, + FunctionInfo{7, nullptr, "Cmd7"}, + FunctionInfo{8, nullptr, "Cmd8"}, + FunctionInfo{9, nullptr, "Cmd9"}, + FunctionInfo{10, nullptr, "Cmd10"}, + FunctionInfo{11, nullptr, "Cmd11"}, + FunctionInfo{12, nullptr, "Cmd12"}, + FunctionInfo{13, nullptr, "Cmd13"}, + FunctionInfo{14, nullptr, "Cmd14"}, + FunctionInfo{15, nullptr, "Cmd15"}, + FunctionInfo{16, nullptr, "Cmd16"}, + FunctionInfo{17, nullptr, "Cmd17"}, + FunctionInfo{18, nullptr, "Cmd18"}, + FunctionInfo{19, nullptr, "Cmd19"}, + FunctionInfo{20, nullptr, "Cmd20"}, + FunctionInfo{21, nullptr, "Cmd21"}, + FunctionInfo{22, nullptr, "Cmd22"}, + FunctionInfo{23, nullptr, "Cmd23"}, + FunctionInfo{24, nullptr, "Cmd24"}, + FunctionInfo{25, nullptr, "Cmd25"}, + FunctionInfo{26, nullptr, "Cmd26"}, + FunctionInfo{27, nullptr, "Cmd27"} ); }; @@ -241,8 +241,8 @@ public: return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMap( - FunctionInfo{0, nullptr, "CreateWirelessCommunicationService" }, - FunctionInfo{1, nullptr, "CreatePrivateWirelessCommunicationService" } + FunctionInfo{0, nullptr, "CreateWirelessCommunicationService"}, + FunctionInfo{1, nullptr, "CreatePrivateWirelessCommunicationService"} ); };