From b2e140b03284fac8fecc7f5bd86f538b76dadc8b Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 11 Feb 2024 18:26:32 -0500 Subject: [PATCH] am: rewrite appletAE, appletOE --- src/android/app/src/main/jni/native.cpp | 2 - src/core/CMakeLists.txt | 8 +- src/core/hle/service/am/am.cpp | 12 +-- src/core/hle/service/am/am_types.h | 6 ++ src/core/hle/service/am/applet_ae.cpp | 73 ----------------- src/core/hle/service/am/applet_ae.h | 39 --------- src/core/hle/service/am/applet_oe.cpp | 42 ---------- src/core/hle/service/am/applet_oe.h | 37 --------- src/core/hle/service/am/frontend/applets.cpp | 3 - .../all_system_applet_proxies_service.cpp | 80 +++++++++++++++++++ .../all_system_applet_proxies_service.h | 47 +++++++++++ .../am/service/application_proxy_service.cpp | 42 ++++++++++ .../am/service/application_proxy_service.h | 35 ++++++++ src/yuzu/configuration/configure_input.cpp | 3 - src/yuzu/main.cpp | 3 - 15 files changed, 220 insertions(+), 212 deletions(-) delete mode 100644 src/core/hle/service/am/applet_ae.cpp delete mode 100644 src/core/hle/service/am/applet_ae.h delete mode 100644 src/core/hle/service/am/applet_oe.cpp delete mode 100644 src/core/hle/service/am/applet_oe.h create mode 100644 src/core/hle/service/am/service/all_system_applet_proxies_service.cpp create mode 100644 src/core/hle/service/am/service/all_system_applet_proxies_service.h create mode 100644 src/core/hle/service/am/service/application_proxy_service.cpp create mode 100644 src/core/hle/service/am/service/application_proxy_service.h diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 4acc60956..a4d8454e8 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -49,9 +49,7 @@ #include "core/frontend/applets/profile_select.h" #include "core/frontend/applets/software_keyboard.h" #include "core/frontend/applets/web_browser.h" -#include "core/hle/service/am/applet_ae.h" #include "core/hle/service/am/applet_manager.h" -#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/am/frontend/applets.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/loader/loader.h" diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2d5490968..5ae31932c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -417,14 +417,10 @@ add_library(core STATIC hle/service/am/am_types.h hle/service/am/applet.cpp hle/service/am/applet.h - hle/service/am/applet_ae.cpp - hle/service/am/applet_ae.h hle/service/am/applet_manager.cpp hle/service/am/applet_data_broker.cpp hle/service/am/applet_data_broker.h hle/service/am/applet_manager.h - hle/service/am/applet_oe.cpp - hle/service/am/applet_oe.h hle/service/am/applet_common_functions.cpp hle/service/am/applet_common_functions.h hle/service/am/applet_message_queue.cpp @@ -473,6 +469,10 @@ add_library(core STATIC hle/service/am/process.h hle/service/am/self_controller.cpp hle/service/am/self_controller.h + hle/service/am/service/all_system_applet_proxies_service.cpp + hle/service/am/service/all_system_applet_proxies_service.h + hle/service/am/service/application_proxy_service.cpp + hle/service/am/service/application_proxy_service.h hle/service/am/system_applet_proxy.cpp hle/service/am/system_applet_proxy.h hle/service/am/system_buffer_manager.cpp diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 8f90eba34..da0f9e3df 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/am/am.h" -#include "core/hle/service/am/applet_ae.h" -#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/am/idle.h" #include "core/hle/service/am/omm.h" +#include "core/hle/service/am/service/all_system_applet_proxies_service.h" +#include "core/hle/service/am/service/application_proxy_service.h" #include "core/hle/service/am/spsm.h" #include "core/hle/service/server_manager.h" @@ -14,10 +14,10 @@ namespace Service::AM { void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system) { auto server_manager = std::make_unique(system); - server_manager->RegisterNamedService("appletAE", - std::make_shared(nvnflinger, system)); - server_manager->RegisterNamedService("appletOE", - std::make_shared(nvnflinger, system)); + server_manager->RegisterNamedService( + "appletAE", std::make_shared(system, nvnflinger)); + server_manager->RegisterNamedService( + "appletOE", std::make_shared(system, nvnflinger)); server_manager->RegisterNamedService("idle:sys", std::make_shared(system)); server_manager->RegisterNamedService("omm", std::make_shared(system)); server_manager->RegisterNamedService("spsm", std::make_shared(system)); diff --git a/src/core/hle/service/am/am_types.h b/src/core/hle/service/am/am_types.h index 8c33feb15..749081e3d 100644 --- a/src/core/hle/service/am/am_types.h +++ b/src/core/hle/service/am/am_types.h @@ -169,6 +169,12 @@ struct AppletIdentityInfo { }; static_assert(sizeof(AppletIdentityInfo) == 0x10, "AppletIdentityInfo has incorrect size."); +struct AppletAttribute { + u8 flag; + INSERT_PADDING_BYTES_NOINIT(0x7F); +}; +static_assert(sizeof(AppletAttribute) == 0x80, "AppletAttribute has incorrect size."); + using AppletResourceUserId = u64; using ProgramId = u64; diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp deleted file mode 100644 index 1b715dea6..000000000 --- a/src/core/hle/service/am/applet_ae.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/am/applet_ae.h" -#include "core/hle/service/am/applet_manager.h" -#include "core/hle/service/am/library_applet_proxy.h" -#include "core/hle/service/am/system_applet_proxy.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::AM { - -AppletAE::AppletAE(Nvnflinger::Nvnflinger& nvnflinger_, Core::System& system_) - : ServiceFramework{system_, "appletAE"}, nvnflinger{nvnflinger_} { - // clang-format off - static const FunctionInfo functions[] = { - {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"}, - {200, &AppletAE::OpenLibraryAppletProxyOld, "OpenLibraryAppletProxyOld"}, - {201, &AppletAE::OpenLibraryAppletProxy, "OpenLibraryAppletProxy"}, - {300, nullptr, "OpenOverlayAppletProxy"}, - {350, nullptr, "OpenSystemApplicationProxy"}, - {400, nullptr, "CreateSelfLibraryAppletCreatorForDevelop"}, - {410, nullptr, "GetSystemAppletControllerForDebug"}, - {1000, nullptr, "GetDebugFunctions"}, - }; - // clang-format on - - RegisterHandlers(functions); -} - -AppletAE::~AppletAE() = default; - -void AppletAE::OpenSystemAppletProxy(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - if (const auto applet = GetAppletFromContext(ctx)) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(nvnflinger, applet, system); - } else { - UNIMPLEMENTED(); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - } -} - -void AppletAE::OpenLibraryAppletProxy(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - if (const auto applet = GetAppletFromContext(ctx)) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(nvnflinger, applet, system); - } else { - UNIMPLEMENTED(); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - } -} - -void AppletAE::OpenLibraryAppletProxyOld(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - return OpenLibraryAppletProxy(ctx); -} - -std::shared_ptr AppletAE::GetAppletFromContext(HLERequestContext& ctx) { - const auto aruid = ctx.GetPID(); - return system.GetAppletManager().GetByAppletResourceUserId(aruid); -} - -} // namespace Service::AM diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h deleted file mode 100644 index 3d7961fa1..000000000 --- a/src/core/hle/service/am/applet_ae.h +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -#include "core/hle/service/service.h" - -namespace Service { -namespace FileSystem { -class FileSystemController; -} - -namespace Nvnflinger { -class Nvnflinger; -} - -namespace AM { - -struct Applet; - -class AppletAE final : public ServiceFramework { -public: - explicit AppletAE(Nvnflinger::Nvnflinger& nvnflinger_, Core::System& system_); - ~AppletAE() override; - -private: - void OpenSystemAppletProxy(HLERequestContext& ctx); - void OpenLibraryAppletProxy(HLERequestContext& ctx); - void OpenLibraryAppletProxyOld(HLERequestContext& ctx); - - std::shared_ptr GetAppletFromContext(HLERequestContext& ctx); - - Nvnflinger::Nvnflinger& nvnflinger; -}; - -} // namespace AM -} // namespace Service diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp deleted file mode 100644 index 56bafd162..000000000 --- a/src/core/hle/service/am/applet_oe.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/am/am.h" -#include "core/hle/service/am/applet_manager.h" -#include "core/hle/service/am/applet_oe.h" -#include "core/hle/service/am/application_proxy.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::AM { - -AppletOE::AppletOE(Nvnflinger::Nvnflinger& nvnflinger_, Core::System& system_) - : ServiceFramework{system_, "appletOE"}, nvnflinger{nvnflinger_} { - static const FunctionInfo functions[] = { - {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, - }; - RegisterHandlers(functions); -} - -AppletOE::~AppletOE() = default; - -void AppletOE::OpenApplicationProxy(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - if (const auto applet = GetAppletFromContext(ctx)) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(nvnflinger, applet, system); - } else { - UNIMPLEMENTED(); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - } -} - -std::shared_ptr AppletOE::GetAppletFromContext(HLERequestContext& ctx) { - const auto aruid = ctx.GetPID(); - return system.GetAppletManager().GetByAppletResourceUserId(aruid); -} - -} // namespace Service::AM diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h deleted file mode 100644 index f2ba1c924..000000000 --- a/src/core/hle/service/am/applet_oe.h +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -#include "core/hle/service/service.h" - -namespace Service { -namespace FileSystem { -class FileSystemController; -} - -namespace Nvnflinger { -class Nvnflinger; -} - -namespace AM { - -struct Applet; - -class AppletOE final : public ServiceFramework { -public: - explicit AppletOE(Nvnflinger::Nvnflinger& nvnflinger_, Core::System& system_); - ~AppletOE() override; - -private: - void OpenApplicationProxy(HLERequestContext& ctx); - - std::shared_ptr GetAppletFromContext(HLERequestContext& ctx); - - Nvnflinger::Nvnflinger& nvnflinger; -}; - -} // namespace AM -} // namespace Service diff --git a/src/core/hle/service/am/frontend/applets.cpp b/src/core/hle/service/am/frontend/applets.cpp index db2b04575..944d8b105 100644 --- a/src/core/hle/service/am/frontend/applets.cpp +++ b/src/core/hle/service/am/frontend/applets.cpp @@ -15,11 +15,8 @@ #include "core/frontend/applets/web_browser.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/am/am.h" -#include "core/hle/service/am/applet_ae.h" #include "core/hle/service/am/applet_data_broker.h" #include "core/hle/service/am/applet_manager.h" -#include "core/hle/service/am/applet_message_queue.h" -#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/am/frontend/applet_cabinet.h" #include "core/hle/service/am/frontend/applet_controller.h" #include "core/hle/service/am/frontend/applet_error.h" 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 new file mode 100644 index 000000000..66c23a749 --- /dev/null +++ b/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp @@ -0,0 +1,80 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core.h" +#include "core/hle/service/am/applet_manager.h" +#include "core/hle/service/am/library_applet_proxy.h" +#include "core/hle/service/am/service/all_system_applet_proxies_service.h" +#include "core/hle/service/am/system_applet_proxy.h" +#include "core/hle/service/cmif_serialization.h" + +namespace Service::AM { + +IAllSystemAppletProxiesService::IAllSystemAppletProxiesService(Core::System& system_, + Nvnflinger::Nvnflinger& nvnflinger) + : ServiceFramework{system_, "appletAE"}, m_nvnflinger{nvnflinger} { + // clang-format off + static const FunctionInfo functions[] = { + {100, D<&IAllSystemAppletProxiesService::OpenSystemAppletProxy>, "OpenSystemAppletProxy"}, + {200, D<&IAllSystemAppletProxiesService::OpenLibraryAppletProxyOld>, "OpenLibraryAppletProxyOld"}, + {201, D<&IAllSystemAppletProxiesService::OpenLibraryAppletProxy>, "OpenLibraryAppletProxy"}, + {300, nullptr, "OpenOverlayAppletProxy"}, + {350, nullptr, "OpenSystemApplicationProxy"}, + {400, nullptr, "CreateSelfLibraryAppletCreatorForDevelop"}, + {410, nullptr, "GetSystemAppletControllerForDebug"}, + {1000, nullptr, "GetDebugFunctions"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IAllSystemAppletProxiesService::~IAllSystemAppletProxiesService() = default; + +Result IAllSystemAppletProxiesService::OpenSystemAppletProxy( + Out> out_system_applet_proxy, ClientProcessId pid, + InCopyHandle process_handle) { + LOG_DEBUG(Service_AM, "called"); + + if (const auto applet = this->GetAppletFromProcessId(pid); applet) { + *out_system_applet_proxy = + std::make_shared(m_nvnflinger, applet, system); + R_SUCCEED(); + } else { + UNIMPLEMENTED(); + R_THROW(ResultUnknown); + } +} + +Result IAllSystemAppletProxiesService::OpenLibraryAppletProxy( + Out> out_library_applet_proxy, ClientProcessId pid, + InCopyHandle process_handle, + InLargeData attribute) { + LOG_DEBUG(Service_AM, "called"); + + if (const auto applet = this->GetAppletFromProcessId(pid); applet) { + *out_library_applet_proxy = + std::make_shared(m_nvnflinger, applet, system); + R_SUCCEED(); + } else { + UNIMPLEMENTED(); + R_THROW(ResultUnknown); + } +} + +Result IAllSystemAppletProxiesService::OpenLibraryAppletProxyOld( + Out> out_library_applet_proxy, ClientProcessId pid, + InCopyHandle process_handle) { + LOG_DEBUG(Service_AM, "called"); + + AppletAttribute attribute{}; + R_RETURN( + this->OpenLibraryAppletProxy(out_library_applet_proxy, pid, process_handle, attribute)); +} + +std::shared_ptr IAllSystemAppletProxiesService::GetAppletFromProcessId( + ProcessId process_id) { + return system.GetAppletManager().GetByAppletResourceUserId(process_id.pid); +} + +} // namespace Service::AM diff --git a/src/core/hle/service/am/service/all_system_applet_proxies_service.h b/src/core/hle/service/am/service/all_system_applet_proxies_service.h new file mode 100644 index 000000000..38b1ca2ea --- /dev/null +++ b/src/core/hle/service/am/service/all_system_applet_proxies_service.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: Copyright 2018 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 { + +namespace Nvnflinger { +class Nvnflinger; +} + +namespace AM { + +struct Applet; +struct AppletAttribute; +class ILibraryAppletProxy; +class ISystemAppletProxy; + +class IAllSystemAppletProxiesService final + : public ServiceFramework { +public: + explicit IAllSystemAppletProxiesService(Core::System& system_, + Nvnflinger::Nvnflinger& nvnflinger); + ~IAllSystemAppletProxiesService() override; + +private: + Result OpenSystemAppletProxy(Out> out_system_applet_proxy, + ClientProcessId pid, + InCopyHandle process_handle); + Result OpenLibraryAppletProxy(Out> out_library_applet_proxy, + ClientProcessId pid, + InCopyHandle process_handle, + InLargeData attribute); + Result OpenLibraryAppletProxyOld( + Out> out_library_applet_proxy, ClientProcessId pid, + InCopyHandle process_handle); + +private: + std::shared_ptr GetAppletFromProcessId(ProcessId pid); + Nvnflinger::Nvnflinger& m_nvnflinger; +}; + +} // namespace AM +} // namespace Service diff --git a/src/core/hle/service/am/service/application_proxy_service.cpp b/src/core/hle/service/am/service/application_proxy_service.cpp new file mode 100644 index 000000000..b8532d047 --- /dev/null +++ b/src/core/hle/service/am/service/application_proxy_service.cpp @@ -0,0 +1,42 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core.h" +#include "core/hle/service/am/am.h" +#include "core/hle/service/am/applet_manager.h" +#include "core/hle/service/am/application_proxy.h" +#include "core/hle/service/am/service/application_proxy_service.h" +#include "core/hle/service/cmif_serialization.h" + +namespace Service::AM { + +IApplicationProxyService::IApplicationProxyService(Core::System& system_, + Nvnflinger::Nvnflinger& nvnflinger) + : ServiceFramework{system_, "appletOE"}, m_nvnflinger{nvnflinger} { + static const FunctionInfo functions[] = { + {0, D<&IApplicationProxyService::OpenApplicationProxy>, "OpenApplicationProxy"}, + }; + RegisterHandlers(functions); +} + +IApplicationProxyService::~IApplicationProxyService() = default; + +Result IApplicationProxyService::OpenApplicationProxy( + Out> out_application_proxy, ClientProcessId pid, + InCopyHandle process_handle) { + LOG_DEBUG(Service_AM, "called"); + + if (const auto applet = this->GetAppletFromProcessId(pid)) { + *out_application_proxy = std::make_shared(m_nvnflinger, applet, system); + R_SUCCEED(); + } else { + UNIMPLEMENTED(); + R_THROW(ResultUnknown); + } +} + +std::shared_ptr IApplicationProxyService::GetAppletFromProcessId(ProcessId process_id) { + return system.GetAppletManager().GetByAppletResourceUserId(process_id.pid); +} + +} // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_proxy_service.h b/src/core/hle/service/am/service/application_proxy_service.h new file mode 100644 index 000000000..1c1d32d0b --- /dev/null +++ b/src/core/hle/service/am/service/application_proxy_service.h @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: Copyright 2018 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 { + +namespace Nvnflinger { +class Nvnflinger; +} + +namespace AM { + +struct Applet; +class IApplicationProxy; + +class IApplicationProxyService final : public ServiceFramework { +public: + explicit IApplicationProxyService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger); + ~IApplicationProxyService() override; + +private: + Result OpenApplicationProxy(Out> out_application_proxy, + ClientProcessId pid, InCopyHandle process_handle); + +private: + std::shared_ptr GetAppletFromProcessId(ProcessId pid); + Nvnflinger::Nvnflinger& m_nvnflinger; +}; + +} // namespace AM +} // namespace Service diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index e28df10bd..28c3baf08 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -8,10 +8,7 @@ #include "common/settings_enums.h" #include "core/core.h" #include "core/hle/service/am/am.h" -#include "core/hle/service/am/applet_ae.h" #include "core/hle/service/am/applet_manager.h" -#include "core/hle/service/am/applet_message_queue.h" -#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/sm/sm.h" #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 13381fea8..dfa50006a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -44,9 +44,6 @@ #include "core/frontend/applets/mii_edit.h" #include "core/frontend/applets/software_keyboard.h" #include "core/hle/service/acc/profile_manager.h" -#include "core/hle/service/am/applet_ae.h" -#include "core/hle/service/am/applet_message_queue.h" -#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/am/frontend/applets.h" #include "core/hle/service/set/system_settings_server.h" #include "frontend_common/content_manager.h"