diff options
| author | 2024-02-11 19:56:09 -0500 | |
|---|---|---|
| committer | 2024-02-12 09:16:02 -0500 | |
| commit | f9bba8007d3978ca9309ae82ec05299aacdfd24b (patch) | |
| tree | 47a323d8ca20ef63b4dd58601b7d906fbad6a354 /src | |
| parent | am: rewrite IHomeMenuFunctions (diff) | |
| download | yuzu-f9bba8007d3978ca9309ae82ec05299aacdfd24b.tar.gz yuzu-f9bba8007d3978ca9309ae82ec05299aacdfd24b.tar.xz yuzu-f9bba8007d3978ca9309ae82ec05299aacdfd24b.zip | |
am: rewrite ILibraryAppletAccessor
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/hle/service/am/library_applet_accessor.cpp | 202 | ||||
| -rw-r--r-- | src/core/hle/service/am/library_applet_accessor.h | 43 | ||||
| -rw-r--r-- | src/core/hle/service/am/library_applet_creator.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/process_winding_controller.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/library_applet_accessor.cpp | 157 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/library_applet_accessor.h | 45 |
7 files changed, 206 insertions, 249 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ae2fe0b68..d763663e6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -429,8 +429,6 @@ add_library(core STATIC | |||
| 429 | hle/service/am/hid_registration.h | 429 | hle/service/am/hid_registration.h |
| 430 | hle/service/am/idle.cpp | 430 | hle/service/am/idle.cpp |
| 431 | hle/service/am/idle.h | 431 | hle/service/am/idle.h |
| 432 | hle/service/am/library_applet_accessor.cpp | ||
| 433 | hle/service/am/library_applet_accessor.h | ||
| 434 | hle/service/am/library_applet_creator.cpp | 432 | hle/service/am/library_applet_creator.cpp |
| 435 | hle/service/am/library_applet_creator.h | 433 | hle/service/am/library_applet_creator.h |
| 436 | hle/service/am/library_applet_self_accessor.cpp | 434 | hle/service/am/library_applet_self_accessor.cpp |
| @@ -473,6 +471,8 @@ add_library(core STATIC | |||
| 473 | hle/service/am/service/global_state_controller.h | 471 | hle/service/am/service/global_state_controller.h |
| 474 | hle/service/am/service/home_menu_functions.cpp | 472 | hle/service/am/service/home_menu_functions.cpp |
| 475 | hle/service/am/service/home_menu_functions.h | 473 | hle/service/am/service/home_menu_functions.h |
| 474 | hle/service/am/service/library_applet_accessor.cpp | ||
| 475 | hle/service/am/service/library_applet_accessor.h | ||
| 476 | hle/service/am/service/library_applet_proxy.cpp | 476 | hle/service/am/service/library_applet_proxy.cpp |
| 477 | hle/service/am/service/library_applet_proxy.h | 477 | hle/service/am/service/library_applet_proxy.h |
| 478 | hle/service/am/service/system_applet_proxy.cpp | 478 | hle/service/am/service/system_applet_proxy.cpp |
diff --git a/src/core/hle/service/am/library_applet_accessor.cpp b/src/core/hle/service/am/library_applet_accessor.cpp deleted file mode 100644 index 6b20814f8..000000000 --- a/src/core/hle/service/am/library_applet_accessor.cpp +++ /dev/null | |||
| @@ -1,202 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/scope_exit.h" | ||
| 5 | #include "core/hle/service/am/am_results.h" | ||
| 6 | #include "core/hle/service/am/applet_data_broker.h" | ||
| 7 | #include "core/hle/service/am/frontend/applets.h" | ||
| 8 | #include "core/hle/service/am/library_applet_accessor.h" | ||
| 9 | #include "core/hle/service/am/storage.h" | ||
| 10 | #include "core/hle/service/ipc_helpers.h" | ||
| 11 | |||
| 12 | namespace Service::AM { | ||
| 13 | |||
| 14 | ILibraryAppletAccessor::ILibraryAppletAccessor(Core::System& system_, | ||
| 15 | std::shared_ptr<AppletDataBroker> broker_, | ||
| 16 | std::shared_ptr<Applet> applet_) | ||
| 17 | : ServiceFramework{system_, "ILibraryAppletAccessor"}, broker{std::move(broker_)}, | ||
| 18 | applet{std::move(applet_)} { | ||
| 19 | // clang-format off | ||
| 20 | static const FunctionInfo functions[] = { | ||
| 21 | {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"}, | ||
| 22 | {1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"}, | ||
| 23 | {10, &ILibraryAppletAccessor::Start, "Start"}, | ||
| 24 | {20, &ILibraryAppletAccessor::RequestExit, "RequestExit"}, | ||
| 25 | {25, nullptr, "Terminate"}, | ||
| 26 | {30, &ILibraryAppletAccessor::GetResult, "GetResult"}, | ||
| 27 | {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"}, | ||
| 28 | {60, &ILibraryAppletAccessor::PresetLibraryAppletGpuTimeSliceZero, "PresetLibraryAppletGpuTimeSliceZero"}, | ||
| 29 | {100, &ILibraryAppletAccessor::PushInData, "PushInData"}, | ||
| 30 | {101, &ILibraryAppletAccessor::PopOutData, "PopOutData"}, | ||
| 31 | {102, nullptr, "PushExtraStorage"}, | ||
| 32 | {103, &ILibraryAppletAccessor::PushInteractiveInData, "PushInteractiveInData"}, | ||
| 33 | {104, &ILibraryAppletAccessor::PopInteractiveOutData, "PopInteractiveOutData"}, | ||
| 34 | {105, &ILibraryAppletAccessor::GetPopOutDataEvent, "GetPopOutDataEvent"}, | ||
| 35 | {106, &ILibraryAppletAccessor::GetPopInteractiveOutDataEvent, "GetPopInteractiveOutDataEvent"}, | ||
| 36 | {110, nullptr, "NeedsToExitProcess"}, | ||
| 37 | {120, nullptr, "GetLibraryAppletInfo"}, | ||
| 38 | {150, nullptr, "RequestForAppletToGetForeground"}, | ||
| 39 | {160, &ILibraryAppletAccessor::GetIndirectLayerConsumerHandle, "GetIndirectLayerConsumerHandle"}, | ||
| 40 | }; | ||
| 41 | // clang-format on | ||
| 42 | |||
| 43 | RegisterHandlers(functions); | ||
| 44 | } | ||
| 45 | |||
| 46 | ILibraryAppletAccessor::~ILibraryAppletAccessor() = default; | ||
| 47 | |||
| 48 | void ILibraryAppletAccessor::GetAppletStateChangedEvent(HLERequestContext& ctx) { | ||
| 49 | LOG_DEBUG(Service_AM, "called"); | ||
| 50 | |||
| 51 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 52 | rb.Push(ResultSuccess); | ||
| 53 | rb.PushCopyObjects(broker->GetStateChangedEvent().GetHandle()); | ||
| 54 | } | ||
| 55 | |||
| 56 | void ILibraryAppletAccessor::IsCompleted(HLERequestContext& ctx) { | ||
| 57 | LOG_DEBUG(Service_AM, "called"); | ||
| 58 | |||
| 59 | std::scoped_lock lk{applet->lock}; | ||
| 60 | |||
| 61 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 62 | rb.Push(ResultSuccess); | ||
| 63 | rb.Push<u32>(broker->IsCompleted()); | ||
| 64 | } | ||
| 65 | |||
| 66 | void ILibraryAppletAccessor::GetResult(HLERequestContext& ctx) { | ||
| 67 | LOG_DEBUG(Service_AM, "called"); | ||
| 68 | |||
| 69 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 70 | rb.Push(applet->terminate_result); | ||
| 71 | } | ||
| 72 | |||
| 73 | void ILibraryAppletAccessor::PresetLibraryAppletGpuTimeSliceZero(HLERequestContext& ctx) { | ||
| 74 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 75 | |||
| 76 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 77 | rb.Push(ResultSuccess); | ||
| 78 | } | ||
| 79 | |||
| 80 | void ILibraryAppletAccessor::Start(HLERequestContext& ctx) { | ||
| 81 | LOG_DEBUG(Service_AM, "called"); | ||
| 82 | |||
| 83 | applet->process->Run(); | ||
| 84 | FrontendExecute(); | ||
| 85 | |||
| 86 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 87 | rb.Push(ResultSuccess); | ||
| 88 | } | ||
| 89 | |||
| 90 | void ILibraryAppletAccessor::RequestExit(HLERequestContext& ctx) { | ||
| 91 | LOG_DEBUG(Service_AM, "called"); | ||
| 92 | |||
| 93 | ASSERT(applet != nullptr); | ||
| 94 | applet->message_queue.RequestExit(); | ||
| 95 | FrontendRequestExit(); | ||
| 96 | |||
| 97 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 98 | rb.Push(ResultSuccess); | ||
| 99 | } | ||
| 100 | |||
| 101 | void ILibraryAppletAccessor::PushInData(HLERequestContext& ctx) { | ||
| 102 | LOG_DEBUG(Service_AM, "called"); | ||
| 103 | |||
| 104 | IPC::RequestParser rp{ctx}; | ||
| 105 | broker->GetInData().Push(rp.PopIpcInterface<IStorage>().lock()); | ||
| 106 | |||
| 107 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 108 | rb.Push(ResultSuccess); | ||
| 109 | } | ||
| 110 | |||
| 111 | void ILibraryAppletAccessor::PopOutData(HLERequestContext& ctx) { | ||
| 112 | LOG_DEBUG(Service_AM, "called"); | ||
| 113 | |||
| 114 | std::shared_ptr<IStorage> data; | ||
| 115 | const auto res = broker->GetOutData().Pop(&data); | ||
| 116 | |||
| 117 | if (res.IsSuccess()) { | ||
| 118 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 119 | rb.Push(res); | ||
| 120 | rb.PushIpcInterface(std::move(data)); | ||
| 121 | } else { | ||
| 122 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 123 | rb.Push(res); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | void ILibraryAppletAccessor::PushInteractiveInData(HLERequestContext& ctx) { | ||
| 128 | LOG_DEBUG(Service_AM, "called"); | ||
| 129 | |||
| 130 | IPC::RequestParser rp{ctx}; | ||
| 131 | broker->GetInteractiveInData().Push(rp.PopIpcInterface<IStorage>().lock()); | ||
| 132 | FrontendExecuteInteractive(); | ||
| 133 | |||
| 134 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 135 | rb.Push(ResultSuccess); | ||
| 136 | } | ||
| 137 | |||
| 138 | void ILibraryAppletAccessor::PopInteractiveOutData(HLERequestContext& ctx) { | ||
| 139 | LOG_DEBUG(Service_AM, "called"); | ||
| 140 | |||
| 141 | std::shared_ptr<IStorage> data; | ||
| 142 | const auto res = broker->GetInteractiveOutData().Pop(&data); | ||
| 143 | |||
| 144 | if (res.IsSuccess()) { | ||
| 145 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 146 | rb.Push(res); | ||
| 147 | rb.PushIpcInterface(std::move(data)); | ||
| 148 | } else { | ||
| 149 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 150 | rb.Push(res); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | void ILibraryAppletAccessor::GetPopOutDataEvent(HLERequestContext& ctx) { | ||
| 155 | LOG_DEBUG(Service_AM, "called"); | ||
| 156 | |||
| 157 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 158 | rb.Push(ResultSuccess); | ||
| 159 | rb.PushCopyObjects(broker->GetOutData().GetEvent()); | ||
| 160 | } | ||
| 161 | |||
| 162 | void ILibraryAppletAccessor::GetPopInteractiveOutDataEvent(HLERequestContext& ctx) { | ||
| 163 | LOG_DEBUG(Service_AM, "called"); | ||
| 164 | |||
| 165 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 166 | rb.Push(ResultSuccess); | ||
| 167 | rb.PushCopyObjects(broker->GetInteractiveOutData().GetEvent()); | ||
| 168 | } | ||
| 169 | |||
| 170 | void ILibraryAppletAccessor::GetIndirectLayerConsumerHandle(HLERequestContext& ctx) { | ||
| 171 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 172 | |||
| 173 | // We require a non-zero handle to be valid. Using 0xdeadbeef allows us to trace if this is | ||
| 174 | // actually used anywhere | ||
| 175 | constexpr u64 handle = 0xdeadbeef; | ||
| 176 | |||
| 177 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 178 | rb.Push(ResultSuccess); | ||
| 179 | rb.Push(handle); | ||
| 180 | } | ||
| 181 | |||
| 182 | void ILibraryAppletAccessor::FrontendExecute() { | ||
| 183 | if (applet->frontend) { | ||
| 184 | applet->frontend->Initialize(); | ||
| 185 | applet->frontend->Execute(); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | void ILibraryAppletAccessor::FrontendExecuteInteractive() { | ||
| 190 | if (applet->frontend) { | ||
| 191 | applet->frontend->ExecuteInteractive(); | ||
| 192 | applet->frontend->Execute(); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | void ILibraryAppletAccessor::FrontendRequestExit() { | ||
| 197 | if (applet->frontend) { | ||
| 198 | applet->frontend->RequestExit(); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/library_applet_accessor.h b/src/core/hle/service/am/library_applet_accessor.h deleted file mode 100644 index 8be29e003..000000000 --- a/src/core/hle/service/am/library_applet_accessor.h +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/service.h" | ||
| 7 | |||
| 8 | namespace Service::AM { | ||
| 9 | |||
| 10 | class AppletDataBroker; | ||
| 11 | struct Applet; | ||
| 12 | |||
| 13 | class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> { | ||
| 14 | public: | ||
| 15 | explicit ILibraryAppletAccessor(Core::System& system_, | ||
| 16 | std::shared_ptr<AppletDataBroker> broker_, | ||
| 17 | std::shared_ptr<Applet> applet_); | ||
| 18 | ~ILibraryAppletAccessor(); | ||
| 19 | |||
| 20 | protected: | ||
| 21 | void GetAppletStateChangedEvent(HLERequestContext& ctx); | ||
| 22 | void IsCompleted(HLERequestContext& ctx); | ||
| 23 | void GetResult(HLERequestContext& ctx); | ||
| 24 | void PresetLibraryAppletGpuTimeSliceZero(HLERequestContext& ctx); | ||
| 25 | void Start(HLERequestContext& ctx); | ||
| 26 | void RequestExit(HLERequestContext& ctx); | ||
| 27 | void PushInData(HLERequestContext& ctx); | ||
| 28 | void PopOutData(HLERequestContext& ctx); | ||
| 29 | void PushInteractiveInData(HLERequestContext& ctx); | ||
| 30 | void PopInteractiveOutData(HLERequestContext& ctx); | ||
| 31 | void GetPopOutDataEvent(HLERequestContext& ctx); | ||
| 32 | void GetPopInteractiveOutDataEvent(HLERequestContext& ctx); | ||
| 33 | void GetIndirectLayerConsumerHandle(HLERequestContext& ctx); | ||
| 34 | |||
| 35 | void FrontendExecute(); | ||
| 36 | void FrontendExecuteInteractive(); | ||
| 37 | void FrontendRequestExit(); | ||
| 38 | |||
| 39 | const std::shared_ptr<AppletDataBroker> broker; | ||
| 40 | const std::shared_ptr<Applet> applet; | ||
| 41 | }; | ||
| 42 | |||
| 43 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/library_applet_creator.cpp b/src/core/hle/service/am/library_applet_creator.cpp index f7fdcb5db..bc2e18e38 100644 --- a/src/core/hle/service/am/library_applet_creator.cpp +++ b/src/core/hle/service/am/library_applet_creator.cpp | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | #include "core/hle/service/am/applet_data_broker.h" | 6 | #include "core/hle/service/am/applet_data_broker.h" |
| 7 | #include "core/hle/service/am/applet_manager.h" | 7 | #include "core/hle/service/am/applet_manager.h" |
| 8 | #include "core/hle/service/am/frontend/applets.h" | 8 | #include "core/hle/service/am/frontend/applets.h" |
| 9 | #include "core/hle/service/am/library_applet_accessor.h" | ||
| 10 | #include "core/hle/service/am/library_applet_creator.h" | 9 | #include "core/hle/service/am/library_applet_creator.h" |
| 11 | #include "core/hle/service/am/library_applet_storage.h" | 10 | #include "core/hle/service/am/library_applet_storage.h" |
| 11 | #include "core/hle/service/am/service/library_applet_accessor.h" | ||
| 12 | #include "core/hle/service/am/storage.h" | 12 | #include "core/hle/service/am/storage.h" |
| 13 | #include "core/hle/service/ipc_helpers.h" | 13 | #include "core/hle/service/ipc_helpers.h" |
| 14 | #include "core/hle/service/sm/sm.h" | 14 | #include "core/hle/service/sm/sm.h" |
diff --git a/src/core/hle/service/am/process_winding_controller.cpp b/src/core/hle/service/am/process_winding_controller.cpp index b48b52797..bc5a50a3d 100644 --- a/src/core/hle/service/am/process_winding_controller.cpp +++ b/src/core/hle/service/am/process_winding_controller.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/am/frontend/applets.h" | 4 | #include "core/hle/service/am/frontend/applets.h" |
| 5 | #include "core/hle/service/am/library_applet_accessor.h" | ||
| 6 | #include "core/hle/service/am/process_winding_controller.h" | 5 | #include "core/hle/service/am/process_winding_controller.h" |
| 6 | #include "core/hle/service/am/service/library_applet_accessor.h" | ||
| 7 | #include "core/hle/service/ipc_helpers.h" | 7 | #include "core/hle/service/ipc_helpers.h" |
| 8 | 8 | ||
| 9 | namespace Service::AM { | 9 | namespace Service::AM { |
diff --git a/src/core/hle/service/am/service/library_applet_accessor.cpp b/src/core/hle/service/am/service/library_applet_accessor.cpp new file mode 100644 index 000000000..aac875ef4 --- /dev/null +++ b/src/core/hle/service/am/service/library_applet_accessor.cpp | |||
| @@ -0,0 +1,157 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/am/applet_data_broker.h" | ||
| 5 | #include "core/hle/service/am/applet_manager.h" | ||
| 6 | #include "core/hle/service/am/frontend/applets.h" | ||
| 7 | #include "core/hle/service/am/service/library_applet_accessor.h" | ||
| 8 | #include "core/hle/service/am/storage.h" | ||
| 9 | #include "core/hle/service/cmif_serialization.h" | ||
| 10 | |||
| 11 | namespace Service::AM { | ||
| 12 | |||
| 13 | ILibraryAppletAccessor::ILibraryAppletAccessor(Core::System& system_, | ||
| 14 | std::shared_ptr<AppletDataBroker> broker, | ||
| 15 | std::shared_ptr<Applet> applet) | ||
| 16 | : ServiceFramework{system_, "ILibraryAppletAccessor"}, m_broker{std::move(broker)}, | ||
| 17 | m_applet{std::move(applet)} { | ||
| 18 | // clang-format off | ||
| 19 | static const FunctionInfo functions[] = { | ||
| 20 | {0, D<&ILibraryAppletAccessor::GetAppletStateChangedEvent>, "GetAppletStateChangedEvent"}, | ||
| 21 | {1, D<&ILibraryAppletAccessor::IsCompleted>, "IsCompleted"}, | ||
| 22 | {10, D<&ILibraryAppletAccessor::Start>, "Start"}, | ||
| 23 | {20, D<&ILibraryAppletAccessor::RequestExit>, "RequestExit"}, | ||
| 24 | {25, D<&ILibraryAppletAccessor::Terminate>, "Terminate"}, | ||
| 25 | {30, D<&ILibraryAppletAccessor::GetResult>, "GetResult"}, | ||
| 26 | {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"}, | ||
| 27 | {60, D<&ILibraryAppletAccessor::PresetLibraryAppletGpuTimeSliceZero>, "PresetLibraryAppletGpuTimeSliceZero"}, | ||
| 28 | {100, D<&ILibraryAppletAccessor::PushInData>, "PushInData"}, | ||
| 29 | {101, D<&ILibraryAppletAccessor::PopOutData>, "PopOutData"}, | ||
| 30 | {102, nullptr, "PushExtraStorage"}, | ||
| 31 | {103, D<&ILibraryAppletAccessor::PushInteractiveInData>, "PushInteractiveInData"}, | ||
| 32 | {104, D<&ILibraryAppletAccessor::PopInteractiveOutData>, "PopInteractiveOutData"}, | ||
| 33 | {105, D<&ILibraryAppletAccessor::GetPopOutDataEvent>, "GetPopOutDataEvent"}, | ||
| 34 | {106, D<&ILibraryAppletAccessor::GetPopInteractiveOutDataEvent>, "GetPopInteractiveOutDataEvent"}, | ||
| 35 | {110, nullptr, "NeedsToExitProcess"}, | ||
| 36 | {120, nullptr, "GetLibraryAppletInfo"}, | ||
| 37 | {150, nullptr, "RequestForAppletToGetForeground"}, | ||
| 38 | {160, D<&ILibraryAppletAccessor::GetIndirectLayerConsumerHandle>, "GetIndirectLayerConsumerHandle"}, | ||
| 39 | }; | ||
| 40 | // clang-format on | ||
| 41 | |||
| 42 | RegisterHandlers(functions); | ||
| 43 | } | ||
| 44 | |||
| 45 | ILibraryAppletAccessor::~ILibraryAppletAccessor() = default; | ||
| 46 | |||
| 47 | Result ILibraryAppletAccessor::GetAppletStateChangedEvent( | ||
| 48 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 49 | LOG_DEBUG(Service_AM, "called"); | ||
| 50 | *out_event = m_broker->GetStateChangedEvent().GetHandle(); | ||
| 51 | R_SUCCEED(); | ||
| 52 | } | ||
| 53 | |||
| 54 | Result ILibraryAppletAccessor::IsCompleted(Out<bool> out_is_completed) { | ||
| 55 | LOG_DEBUG(Service_AM, "called"); | ||
| 56 | *out_is_completed = m_broker->IsCompleted(); | ||
| 57 | R_SUCCEED(); | ||
| 58 | } | ||
| 59 | |||
| 60 | Result ILibraryAppletAccessor::GetResult(Out<Result> out_result) { | ||
| 61 | LOG_DEBUG(Service_AM, "called"); | ||
| 62 | *out_result = m_applet->terminate_result; | ||
| 63 | R_SUCCEED(); | ||
| 64 | } | ||
| 65 | |||
| 66 | Result ILibraryAppletAccessor::PresetLibraryAppletGpuTimeSliceZero() { | ||
| 67 | LOG_INFO(Service_AM, "(STUBBED) called"); | ||
| 68 | R_SUCCEED(); | ||
| 69 | } | ||
| 70 | |||
| 71 | Result ILibraryAppletAccessor::Start() { | ||
| 72 | LOG_DEBUG(Service_AM, "called"); | ||
| 73 | m_applet->process->Run(); | ||
| 74 | FrontendExecute(); | ||
| 75 | R_SUCCEED(); | ||
| 76 | } | ||
| 77 | |||
| 78 | Result ILibraryAppletAccessor::RequestExit() { | ||
| 79 | LOG_DEBUG(Service_AM, "called"); | ||
| 80 | m_applet->message_queue.RequestExit(); | ||
| 81 | FrontendRequestExit(); | ||
| 82 | R_SUCCEED(); | ||
| 83 | } | ||
| 84 | |||
| 85 | Result ILibraryAppletAccessor::Terminate() { | ||
| 86 | LOG_DEBUG(Service_AM, "called"); | ||
| 87 | m_applet->process->Terminate(); | ||
| 88 | FrontendRequestExit(); | ||
| 89 | R_SUCCEED(); | ||
| 90 | } | ||
| 91 | |||
| 92 | Result ILibraryAppletAccessor::PushInData(SharedPointer<IStorage> storage) { | ||
| 93 | LOG_DEBUG(Service_AM, "called"); | ||
| 94 | m_broker->GetInData().Push(storage); | ||
| 95 | R_SUCCEED(); | ||
| 96 | } | ||
| 97 | |||
| 98 | Result ILibraryAppletAccessor::PopOutData(Out<SharedPointer<IStorage>> out_storage) { | ||
| 99 | LOG_DEBUG(Service_AM, "called"); | ||
| 100 | R_RETURN(m_broker->GetOutData().Pop(out_storage.Get())); | ||
| 101 | } | ||
| 102 | |||
| 103 | Result ILibraryAppletAccessor::PushInteractiveInData(SharedPointer<IStorage> storage) { | ||
| 104 | LOG_DEBUG(Service_AM, "called"); | ||
| 105 | m_broker->GetInteractiveInData().Push(storage); | ||
| 106 | FrontendExecuteInteractive(); | ||
| 107 | R_SUCCEED(); | ||
| 108 | } | ||
| 109 | |||
| 110 | Result ILibraryAppletAccessor::PopInteractiveOutData(Out<SharedPointer<IStorage>> out_storage) { | ||
| 111 | LOG_DEBUG(Service_AM, "called"); | ||
| 112 | R_RETURN(m_broker->GetInteractiveOutData().Pop(out_storage.Get())); | ||
| 113 | } | ||
| 114 | |||
| 115 | Result ILibraryAppletAccessor::GetPopOutDataEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 116 | LOG_DEBUG(Service_AM, "called"); | ||
| 117 | *out_event = m_broker->GetOutData().GetEvent(); | ||
| 118 | R_SUCCEED(); | ||
| 119 | } | ||
| 120 | |||
| 121 | Result ILibraryAppletAccessor::GetPopInteractiveOutDataEvent( | ||
| 122 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 123 | LOG_DEBUG(Service_AM, "called"); | ||
| 124 | *out_event = m_broker->GetInteractiveOutData().GetEvent(); | ||
| 125 | R_SUCCEED(); | ||
| 126 | } | ||
| 127 | |||
| 128 | Result ILibraryAppletAccessor::GetIndirectLayerConsumerHandle(Out<u64> out_handle) { | ||
| 129 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 130 | |||
| 131 | // We require a non-zero handle to be valid. Using 0xdeadbeef allows us to trace if this is | ||
| 132 | // actually used anywhere | ||
| 133 | *out_handle = 0xdeadbeef; | ||
| 134 | R_SUCCEED(); | ||
| 135 | } | ||
| 136 | |||
| 137 | void ILibraryAppletAccessor::FrontendExecute() { | ||
| 138 | if (m_applet->frontend) { | ||
| 139 | m_applet->frontend->Initialize(); | ||
| 140 | m_applet->frontend->Execute(); | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | void ILibraryAppletAccessor::FrontendExecuteInteractive() { | ||
| 145 | if (m_applet->frontend) { | ||
| 146 | m_applet->frontend->ExecuteInteractive(); | ||
| 147 | m_applet->frontend->Execute(); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | void ILibraryAppletAccessor::FrontendRequestExit() { | ||
| 152 | if (m_applet->frontend) { | ||
| 153 | m_applet->frontend->RequestExit(); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/service/library_applet_accessor.h b/src/core/hle/service/am/service/library_applet_accessor.h new file mode 100644 index 000000000..97d3b6c8a --- /dev/null +++ b/src/core/hle/service/am/service/library_applet_accessor.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service::AM { | ||
| 10 | |||
| 11 | class AppletDataBroker; | ||
| 12 | struct Applet; | ||
| 13 | class IStorage; | ||
| 14 | |||
| 15 | class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> { | ||
| 16 | public: | ||
| 17 | explicit ILibraryAppletAccessor(Core::System& system_, std::shared_ptr<AppletDataBroker> broker, | ||
| 18 | std::shared_ptr<Applet> applet); | ||
| 19 | ~ILibraryAppletAccessor(); | ||
| 20 | |||
| 21 | private: | ||
| 22 | Result GetAppletStateChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 23 | Result IsCompleted(Out<bool> out_is_completed); | ||
| 24 | Result GetResult(Out<Result> out_result); | ||
| 25 | Result PresetLibraryAppletGpuTimeSliceZero(); | ||
| 26 | Result Start(); | ||
| 27 | Result RequestExit(); | ||
| 28 | Result Terminate(); | ||
| 29 | Result PushInData(SharedPointer<IStorage> storage); | ||
| 30 | Result PopOutData(Out<SharedPointer<IStorage>> out_storage); | ||
| 31 | Result PushInteractiveInData(SharedPointer<IStorage> storage); | ||
| 32 | Result PopInteractiveOutData(Out<SharedPointer<IStorage>> out_storage); | ||
| 33 | Result GetPopOutDataEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 34 | Result GetPopInteractiveOutDataEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 35 | Result GetIndirectLayerConsumerHandle(Out<u64> out_handle); | ||
| 36 | |||
| 37 | void FrontendExecute(); | ||
| 38 | void FrontendExecuteInteractive(); | ||
| 39 | void FrontendRequestExit(); | ||
| 40 | |||
| 41 | const std::shared_ptr<AppletDataBroker> m_broker; | ||
| 42 | const std::shared_ptr<Applet> m_applet; | ||
| 43 | }; | ||
| 44 | |||
| 45 | } // namespace Service::AM | ||