Browse Source

am: rewrite appletAE, appletOE

Liam 2 years ago
parent
commit
b2e140b032

+ 0 - 2
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"

+ 4 - 4
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

+ 6 - 6
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<ServerManager>(system);
 
-    server_manager->RegisterNamedService("appletAE",
-                                         std::make_shared<AppletAE>(nvnflinger, system));
-    server_manager->RegisterNamedService("appletOE",
-                                         std::make_shared<AppletOE>(nvnflinger, system));
+    server_manager->RegisterNamedService(
+        "appletAE", std::make_shared<IAllSystemAppletProxiesService>(system, nvnflinger));
+    server_manager->RegisterNamedService(
+        "appletOE", std::make_shared<IApplicationProxyService>(system, nvnflinger));
     server_manager->RegisterNamedService("idle:sys", std::make_shared<IdleSys>(system));
     server_manager->RegisterNamedService("omm", std::make_shared<OMM>(system));
     server_manager->RegisterNamedService("spsm", std::make_shared<SPSM>(system));

+ 6 - 0
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;
 

+ 0 - 73
src/core/hle/service/am/applet_ae.cpp

@@ -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<ISystemAppletProxy>(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<ILibraryAppletProxy>(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<Applet> AppletAE::GetAppletFromContext(HLERequestContext& ctx) {
-    const auto aruid = ctx.GetPID();
-    return system.GetAppletManager().GetByAppletResourceUserId(aruid);
-}
-
-} // namespace Service::AM

+ 0 - 39
src/core/hle/service/am/applet_ae.h

@@ -1,39 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#pragma once
-
-#include <memory>
-
-#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<AppletAE> {
-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<Applet> GetAppletFromContext(HLERequestContext& ctx);
-
-    Nvnflinger::Nvnflinger& nvnflinger;
-};
-
-} // namespace AM
-} // namespace Service

+ 0 - 42
src/core/hle/service/am/applet_oe.cpp

@@ -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<IApplicationProxy>(nvnflinger, applet, system);
-    } else {
-        UNIMPLEMENTED();
-
-        IPC::ResponseBuilder rb{ctx, 2};
-        rb.Push(ResultUnknown);
-    }
-}
-
-std::shared_ptr<Applet> AppletOE::GetAppletFromContext(HLERequestContext& ctx) {
-    const auto aruid = ctx.GetPID();
-    return system.GetAppletManager().GetByAppletResourceUserId(aruid);
-}
-
-} // namespace Service::AM

+ 0 - 37
src/core/hle/service/am/applet_oe.h

@@ -1,37 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#pragma once
-
-#include <memory>
-
-#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<AppletOE> {
-public:
-    explicit AppletOE(Nvnflinger::Nvnflinger& nvnflinger_, Core::System& system_);
-    ~AppletOE() override;
-
-private:
-    void OpenApplicationProxy(HLERequestContext& ctx);
-
-    std::shared_ptr<Applet> GetAppletFromContext(HLERequestContext& ctx);
-
-    Nvnflinger::Nvnflinger& nvnflinger;
-};
-
-} // namespace AM
-} // namespace Service

+ 0 - 3
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"

+ 80 - 0
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<SharedPointer<ISystemAppletProxy>> out_system_applet_proxy, ClientProcessId pid,
+    InCopyHandle<Kernel::KProcess> process_handle) {
+    LOG_DEBUG(Service_AM, "called");
+
+    if (const auto applet = this->GetAppletFromProcessId(pid); applet) {
+        *out_system_applet_proxy =
+            std::make_shared<ISystemAppletProxy>(m_nvnflinger, applet, system);
+        R_SUCCEED();
+    } else {
+        UNIMPLEMENTED();
+        R_THROW(ResultUnknown);
+    }
+}
+
+Result IAllSystemAppletProxiesService::OpenLibraryAppletProxy(
+    Out<SharedPointer<ILibraryAppletProxy>> out_library_applet_proxy, ClientProcessId pid,
+    InCopyHandle<Kernel::KProcess> process_handle,
+    InLargeData<AppletAttribute, BufferAttr_HipcMapAlias> attribute) {
+    LOG_DEBUG(Service_AM, "called");
+
+    if (const auto applet = this->GetAppletFromProcessId(pid); applet) {
+        *out_library_applet_proxy =
+            std::make_shared<ILibraryAppletProxy>(m_nvnflinger, applet, system);
+        R_SUCCEED();
+    } else {
+        UNIMPLEMENTED();
+        R_THROW(ResultUnknown);
+    }
+}
+
+Result IAllSystemAppletProxiesService::OpenLibraryAppletProxyOld(
+    Out<SharedPointer<ILibraryAppletProxy>> out_library_applet_proxy, ClientProcessId pid,
+    InCopyHandle<Kernel::KProcess> process_handle) {
+    LOG_DEBUG(Service_AM, "called");
+
+    AppletAttribute attribute{};
+    R_RETURN(
+        this->OpenLibraryAppletProxy(out_library_applet_proxy, pid, process_handle, attribute));
+}
+
+std::shared_ptr<Applet> IAllSystemAppletProxiesService::GetAppletFromProcessId(
+    ProcessId process_id) {
+    return system.GetAppletManager().GetByAppletResourceUserId(process_id.pid);
+}
+
+} // namespace Service::AM

+ 47 - 0
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<IAllSystemAppletProxiesService> {
+public:
+    explicit IAllSystemAppletProxiesService(Core::System& system_,
+                                            Nvnflinger::Nvnflinger& nvnflinger);
+    ~IAllSystemAppletProxiesService() override;
+
+private:
+    Result OpenSystemAppletProxy(Out<SharedPointer<ISystemAppletProxy>> out_system_applet_proxy,
+                                 ClientProcessId pid,
+                                 InCopyHandle<Kernel::KProcess> process_handle);
+    Result OpenLibraryAppletProxy(Out<SharedPointer<ILibraryAppletProxy>> out_library_applet_proxy,
+                                  ClientProcessId pid,
+                                  InCopyHandle<Kernel::KProcess> process_handle,
+                                  InLargeData<AppletAttribute, BufferAttr_HipcMapAlias> attribute);
+    Result OpenLibraryAppletProxyOld(
+        Out<SharedPointer<ILibraryAppletProxy>> out_library_applet_proxy, ClientProcessId pid,
+        InCopyHandle<Kernel::KProcess> process_handle);
+
+private:
+    std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid);
+    Nvnflinger::Nvnflinger& m_nvnflinger;
+};
+
+} // namespace AM
+} // namespace Service

+ 42 - 0
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<SharedPointer<IApplicationProxy>> out_application_proxy, ClientProcessId pid,
+    InCopyHandle<Kernel::KProcess> process_handle) {
+    LOG_DEBUG(Service_AM, "called");
+
+    if (const auto applet = this->GetAppletFromProcessId(pid)) {
+        *out_application_proxy = std::make_shared<IApplicationProxy>(m_nvnflinger, applet, system);
+        R_SUCCEED();
+    } else {
+        UNIMPLEMENTED();
+        R_THROW(ResultUnknown);
+    }
+}
+
+std::shared_ptr<Applet> IApplicationProxyService::GetAppletFromProcessId(ProcessId process_id) {
+    return system.GetAppletManager().GetByAppletResourceUserId(process_id.pid);
+}
+
+} // namespace Service::AM

+ 35 - 0
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<IApplicationProxyService> {
+public:
+    explicit IApplicationProxyService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger);
+    ~IApplicationProxyService() override;
+
+private:
+    Result OpenApplicationProxy(Out<SharedPointer<IApplicationProxy>> out_application_proxy,
+                                ClientProcessId pid, InCopyHandle<Kernel::KProcess> process_handle);
+
+private:
+    std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid);
+    Nvnflinger::Nvnflinger& m_nvnflinger;
+};
+
+} // namespace AM
+} // namespace Service

+ 0 - 3
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"

+ 0 - 3
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"