From 6fd6c65fd40d2e719cbb62b7e05468d632c04d88 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 11 Feb 2024 19:16:36 -0500 Subject: am: rewrite ISystemAppletProxy --- src/core/CMakeLists.txt | 4 +- .../service/all_system_applet_proxies_service.cpp | 6 +- .../hle/service/am/service/system_applet_proxy.cpp | 132 ++++++++++++++++++++ .../hle/service/am/service/system_applet_proxy.h | 54 ++++++++ src/core/hle/service/am/system_applet_proxy.cpp | 136 --------------------- src/core/hle/service/am/system_applet_proxy.h | 36 ------ 6 files changed, 191 insertions(+), 177 deletions(-) create mode 100644 src/core/hle/service/am/service/system_applet_proxy.cpp create mode 100644 src/core/hle/service/am/service/system_applet_proxy.h delete mode 100644 src/core/hle/service/am/system_applet_proxy.cpp delete mode 100644 src/core/hle/service/am/system_applet_proxy.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8fd62e45e..4486a355c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -473,8 +473,8 @@ add_library(core STATIC hle/service/am/service/application_proxy.h hle/service/am/service/library_applet_proxy.cpp hle/service/am/service/library_applet_proxy.h - hle/service/am/system_applet_proxy.cpp - hle/service/am/system_applet_proxy.h + hle/service/am/service/system_applet_proxy.cpp + hle/service/am/service/system_applet_proxy.h hle/service/am/system_buffer_manager.cpp hle/service/am/system_buffer_manager.h hle/service/am/spsm.cpp diff --git a/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp b/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp index dfefc9310..eebd90ba2 100644 --- a/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp +++ b/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp @@ -5,7 +5,7 @@ #include "core/hle/service/am/applet_manager.h" #include "core/hle/service/am/service/all_system_applet_proxies_service.h" #include "core/hle/service/am/service/library_applet_proxy.h" -#include "core/hle/service/am/system_applet_proxy.h" +#include "core/hle/service/am/service/system_applet_proxy.h" #include "core/hle/service/cmif_serialization.h" namespace Service::AM { @@ -37,8 +37,8 @@ Result IAllSystemAppletProxiesService::OpenSystemAppletProxy( LOG_DEBUG(Service_AM, "called"); if (const auto applet = this->GetAppletFromProcessId(pid); applet) { - *out_system_applet_proxy = - std::make_shared(m_nvnflinger, applet, system); + *out_system_applet_proxy = std::make_shared( + system, applet, process_handle.Get(), m_nvnflinger); R_SUCCEED(); } else { UNIMPLEMENTED(); diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp new file mode 100644 index 000000000..0a69d1502 --- /dev/null +++ b/src/core/hle/service/am/service/system_applet_proxy.cpp @@ -0,0 +1,132 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/am/applet_common_functions.h" +#include "core/hle/service/am/application_creator.h" +#include "core/hle/service/am/audio_controller.h" +#include "core/hle/service/am/common_state_getter.h" +#include "core/hle/service/am/debug_functions.h" +#include "core/hle/service/am/display_controller.h" +#include "core/hle/service/am/global_state_controller.h" +#include "core/hle/service/am/home_menu_functions.h" +#include "core/hle/service/am/library_applet_creator.h" +#include "core/hle/service/am/library_applet_self_accessor.h" +#include "core/hle/service/am/process_winding_controller.h" +#include "core/hle/service/am/self_controller.h" +#include "core/hle/service/am/service/system_applet_proxy.h" +#include "core/hle/service/am/window_controller.h" +#include "core/hle/service/cmif_serialization.h" + +namespace Service::AM { + +ISystemAppletProxy::ISystemAppletProxy(Core::System& system_, std::shared_ptr applet, + Kernel::KProcess* process, + Nvnflinger::Nvnflinger& nvnflinger) + : ServiceFramework{system_, "ISystemAppletProxy"}, + m_nvnflinger{nvnflinger}, m_process{process}, m_applet{std::move(applet)} { + // clang-format off + static const FunctionInfo functions[] = { + {0, D<&ISystemAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, + {1, D<&ISystemAppletProxy::GetSelfController>, "GetSelfController"}, + {2, D<&ISystemAppletProxy::GetWindowController>, "GetWindowController"}, + {3, D<&ISystemAppletProxy::GetAudioController>, "GetAudioController"}, + {4, D<&ISystemAppletProxy::GetDisplayController>, "GetDisplayController"}, + {10, D<&ISystemAppletProxy::GetProcessWindingController>, "GetProcessWindingController"}, + {11, D<&ISystemAppletProxy::GetLibraryAppletCreator>, "GetLibraryAppletCreator"}, + {20, D<&ISystemAppletProxy::GetHomeMenuFunctions>, "GetHomeMenuFunctions"}, + {21, D<&ISystemAppletProxy::GetGlobalStateController>, "GetGlobalStateController"}, + {22, D<&ISystemAppletProxy::GetApplicationCreator>, "GetApplicationCreator"}, + {23, D<&ISystemAppletProxy::GetAppletCommonFunctions>, "GetAppletCommonFunctions"}, + {1000, D<&ISystemAppletProxy::GetDebugFunctions>, "GetDebugFunctions"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +ISystemAppletProxy::~ISystemAppletProxy() = default; + +Result ISystemAppletProxy::GetAudioController( + Out> out_audio_controller) { + LOG_DEBUG(Service_AM, "called"); + *out_audio_controller = std::make_shared(system); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetDisplayController( + Out> out_display_controller) { + LOG_DEBUG(Service_AM, "called"); + *out_display_controller = std::make_shared(system, m_applet); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetProcessWindingController( + Out> out_process_winding_controller) { + LOG_DEBUG(Service_AM, "called"); + *out_process_winding_controller = std::make_shared(system, m_applet); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetDebugFunctions( + Out> out_debug_functions) { + LOG_DEBUG(Service_AM, "called"); + *out_debug_functions = std::make_shared(system); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetWindowController( + Out> out_window_controller) { + LOG_DEBUG(Service_AM, "called"); + *out_window_controller = std::make_shared(system, m_applet); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetSelfController( + Out> out_self_controller) { + LOG_DEBUG(Service_AM, "called"); + *out_self_controller = std::make_shared(system, m_applet, m_nvnflinger); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetCommonStateGetter( + Out> out_common_state_getter) { + LOG_DEBUG(Service_AM, "called"); + *out_common_state_getter = std::make_shared(system, m_applet); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetLibraryAppletCreator( + Out> out_library_applet_creator) { + LOG_DEBUG(Service_AM, "called"); + *out_library_applet_creator = std::make_shared(system, m_applet); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetApplicationCreator( + Out> out_application_creator) { + LOG_ERROR(Service_AM, "called"); + R_THROW(ResultUnknown); +} + +Result ISystemAppletProxy::GetAppletCommonFunctions( + Out> out_applet_common_functions) { + LOG_DEBUG(Service_AM, "called"); + *out_applet_common_functions = std::make_shared(system, m_applet); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetHomeMenuFunctions( + Out> out_home_menu_functions) { + LOG_DEBUG(Service_AM, "called"); + *out_home_menu_functions = std::make_shared(system); + R_SUCCEED(); +} + +Result ISystemAppletProxy::GetGlobalStateController( + Out> out_global_state_controller) { + LOG_DEBUG(Service_AM, "called"); + *out_global_state_controller = std::make_shared(system); + R_SUCCEED(); +} + +} // namespace Service::AM diff --git a/src/core/hle/service/am/service/system_applet_proxy.h b/src/core/hle/service/am/service/system_applet_proxy.h new file mode 100644 index 000000000..3d5040315 --- /dev/null +++ b/src/core/hle/service/am/service/system_applet_proxy.h @@ -0,0 +1,54 @@ +// 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; +class IApplicationCreator; +class IAudioController; +class ICommonStateGetter; +class IDebugFunctions; +class IDisplayController; +class IHomeMenuFunctions; +class IGlobalStateController; +class ILibraryAppletCreator; +class IProcessWindingController; +class ISelfController; +class IWindowController; + +class ISystemAppletProxy final : public ServiceFramework { +public: + explicit ISystemAppletProxy(Core::System& system, std::shared_ptr applet, + Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger); + ~ISystemAppletProxy(); + +private: + Result GetAudioController(Out> out_audio_controller); + Result GetDisplayController(Out> out_display_controller); + Result GetProcessWindingController( + Out> out_process_winding_controller); + Result GetDebugFunctions(Out> out_debug_functions); + Result GetWindowController(Out> out_window_controller); + Result GetSelfController(Out> out_self_controller); + Result GetCommonStateGetter(Out> out_common_state_getter); + Result GetLibraryAppletCreator( + Out> out_library_applet_creator); + Result GetApplicationCreator(Out> out_application_creator); + Result GetAppletCommonFunctions( + Out> out_applet_common_functions); + Result GetHomeMenuFunctions(Out> out_home_menu_functions); + Result GetGlobalStateController( + Out> out_global_state_controller); + + Nvnflinger::Nvnflinger& m_nvnflinger; + Kernel::KProcess* const m_process; + const std::shared_ptr m_applet; +}; + +} // namespace Service::AM diff --git a/src/core/hle/service/am/system_applet_proxy.cpp b/src/core/hle/service/am/system_applet_proxy.cpp deleted file mode 100644 index 38643408e..000000000 --- a/src/core/hle/service/am/system_applet_proxy.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/am/applet_common_functions.h" -#include "core/hle/service/am/application_creator.h" -#include "core/hle/service/am/audio_controller.h" -#include "core/hle/service/am/common_state_getter.h" -#include "core/hle/service/am/debug_functions.h" -#include "core/hle/service/am/display_controller.h" -#include "core/hle/service/am/global_state_controller.h" -#include "core/hle/service/am/home_menu_functions.h" -#include "core/hle/service/am/library_applet_creator.h" -#include "core/hle/service/am/library_applet_self_accessor.h" -#include "core/hle/service/am/process_winding_controller.h" -#include "core/hle/service/am/self_controller.h" -#include "core/hle/service/am/system_applet_proxy.h" -#include "core/hle/service/am/window_controller.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::AM { - -ISystemAppletProxy::ISystemAppletProxy(Nvnflinger::Nvnflinger& nvnflinger_, - std::shared_ptr applet_, Core::System& system_) - : ServiceFramework{system_, "ISystemAppletProxy"}, nvnflinger{nvnflinger_}, applet{std::move( - applet_)} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &ISystemAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, - {1, &ISystemAppletProxy::GetSelfController, "GetSelfController"}, - {2, &ISystemAppletProxy::GetWindowController, "GetWindowController"}, - {3, &ISystemAppletProxy::GetAudioController, "GetAudioController"}, - {4, &ISystemAppletProxy::GetDisplayController, "GetDisplayController"}, - {10, nullptr, "GetProcessWindingController"}, - {11, &ISystemAppletProxy::GetLibraryAppletCreator, "GetLibraryAppletCreator"}, - {20, &ISystemAppletProxy::GetHomeMenuFunctions, "GetHomeMenuFunctions"}, - {21, &ISystemAppletProxy::GetGlobalStateController, "GetGlobalStateController"}, - {22, &ISystemAppletProxy::GetApplicationCreator, "GetApplicationCreator"}, - {23, &ISystemAppletProxy::GetAppletCommonFunctions, "GetAppletCommonFunctions"}, - {1000, &ISystemAppletProxy::GetDebugFunctions, "GetDebugFunctions"}, - }; - // clang-format on - - RegisterHandlers(functions); -} - -ISystemAppletProxy::~ISystemAppletProxy() = default; - -void ISystemAppletProxy::GetCommonStateGetter(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, applet); -} - -void ISystemAppletProxy::GetSelfController(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, applet, nvnflinger); -} - -void ISystemAppletProxy::GetWindowController(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, applet); -} - -void ISystemAppletProxy::GetAudioController(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); -} - -void ISystemAppletProxy::GetDisplayController(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, applet); -} - -void ISystemAppletProxy::GetLibraryAppletCreator(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, applet); -} - -void ISystemAppletProxy::GetHomeMenuFunctions(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); -} - -void ISystemAppletProxy::GetGlobalStateController(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); -} - -void ISystemAppletProxy::GetApplicationCreator(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); -} - -void ISystemAppletProxy::GetAppletCommonFunctions(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, applet); -} - -void ISystemAppletProxy::GetDebugFunctions(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); -} - -} // namespace Service::AM diff --git a/src/core/hle/service/am/system_applet_proxy.h b/src/core/hle/service/am/system_applet_proxy.h deleted file mode 100644 index 0390cd1e5..000000000 --- a/src/core/hle/service/am/system_applet_proxy.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/am/applet_message_queue.h" -#include "core/hle/service/service.h" - -namespace Service::AM { - -struct Applet; - -class ISystemAppletProxy final : public ServiceFramework { -public: - explicit ISystemAppletProxy(Nvnflinger::Nvnflinger& nvnflinger_, - std::shared_ptr applet_, Core::System& system_); - ~ISystemAppletProxy(); - -private: - void GetCommonStateGetter(HLERequestContext& ctx); - void GetSelfController(HLERequestContext& ctx); - void GetWindowController(HLERequestContext& ctx); - void GetAudioController(HLERequestContext& ctx); - void GetDisplayController(HLERequestContext& ctx); - void GetLibraryAppletCreator(HLERequestContext& ctx); - void GetHomeMenuFunctions(HLERequestContext& ctx); - void GetGlobalStateController(HLERequestContext& ctx); - void GetApplicationCreator(HLERequestContext& ctx); - void GetAppletCommonFunctions(HLERequestContext& ctx); - void GetDebugFunctions(HLERequestContext& ctx); - - Nvnflinger::Nvnflinger& nvnflinger; - std::shared_ptr applet; -}; - -} // namespace Service::AM -- cgit v1.2.3