diff options
-rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/core/hle/service/am/library_applet_creator.h | 26 | ||||
-rw-r--r-- | src/core/hle/service/am/service/application_proxy.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/am/service/library_applet_creator.cpp (renamed from src/core/hle/service/am/library_applet_creator.cpp) | 138 | ||||
-rw-r--r-- | src/core/hle/service/am/service/library_applet_creator.h | 35 | ||||
-rw-r--r-- | src/core/hle/service/am/service/library_applet_proxy.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/am/service/system_applet_proxy.cpp | 2 |
7 files changed, 88 insertions, 121 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d763663e6..4f31e9c17 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -429,8 +429,6 @@ add_library(core STATIC hle/service/am/hid_registration.h hle/service/am/idle.cpp hle/service/am/idle.h - hle/service/am/library_applet_creator.cpp - hle/service/am/library_applet_creator.h hle/service/am/library_applet_self_accessor.cpp hle/service/am/library_applet_self_accessor.h hle/service/am/library_applet_storage.cpp @@ -473,6 +471,8 @@ add_library(core STATIC hle/service/am/service/home_menu_functions.h hle/service/am/service/library_applet_accessor.cpp hle/service/am/service/library_applet_accessor.h + hle/service/am/service/library_applet_creator.cpp + hle/service/am/service/library_applet_creator.h hle/service/am/service/library_applet_proxy.cpp hle/service/am/service/library_applet_proxy.h hle/service/am/service/system_applet_proxy.cpp diff --git a/src/core/hle/service/am/library_applet_creator.h b/src/core/hle/service/am/library_applet_creator.h deleted file mode 100644 index 551f287bd..000000000 --- a/src/core/hle/service/am/library_applet_creator.h +++ /dev/null @@ -1,26 +0,0 @@ -// 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 { - -struct Applet; - -class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> { -public: - explicit ILibraryAppletCreator(Core::System& system_, std::shared_ptr<Applet> applet_); - ~ILibraryAppletCreator() override; - -private: - void CreateLibraryApplet(HLERequestContext& ctx); - void CreateStorage(HLERequestContext& ctx); - void CreateTransferMemoryStorage(HLERequestContext& ctx); - void CreateHandleStorage(HLERequestContext& ctx); - - const std::shared_ptr<Applet> applet; -}; - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp index 445f9b158..26a818f14 100644 --- a/src/core/hle/service/am/service/application_proxy.cpp +++ b/src/core/hle/service/am/service/application_proxy.cpp @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#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" @@ -12,6 +11,7 @@ #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/library_applet_creator.h" #include "core/hle/service/am/window_controller.h" #include "core/hle/service/cmif_serialization.h" diff --git a/src/core/hle/service/am/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index bc2e18e38..4d905549c 100644 --- a/src/core/hle/service/am/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -6,11 +6,11 @@ #include "core/hle/service/am/applet_data_broker.h" #include "core/hle/service/am/applet_manager.h" #include "core/hle/service/am/frontend/applets.h" -#include "core/hle/service/am/library_applet_creator.h" #include "core/hle/service/am/library_applet_storage.h" #include "core/hle/service/am/service/library_applet_accessor.h" +#include "core/hle/service/am/service/library_applet_creator.h" #include "core/hle/service/am/storage.h" -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/sm/sm.h" namespace Service::AM { @@ -172,139 +172,97 @@ std::shared_ptr<ILibraryAppletAccessor> CreateFrontendApplet(Core::System& syste } // namespace -ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_, std::shared_ptr<Applet> applet_) - : ServiceFramework{system_, "ILibraryAppletCreator"}, applet{std::move(applet_)} { +ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_, std::shared_ptr<Applet> applet) + : ServiceFramework{system_, "ILibraryAppletCreator"}, m_applet{std::move(applet)} { static const FunctionInfo functions[] = { - {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"}, + {0, D<&ILibraryAppletCreator::CreateLibraryApplet>, "CreateLibraryApplet"}, {1, nullptr, "TerminateAllLibraryApplets"}, {2, nullptr, "AreAnyLibraryAppletsLeft"}, - {10, &ILibraryAppletCreator::CreateStorage, "CreateStorage"}, - {11, &ILibraryAppletCreator::CreateTransferMemoryStorage, "CreateTransferMemoryStorage"}, - {12, &ILibraryAppletCreator::CreateHandleStorage, "CreateHandleStorage"}, + {10, D<&ILibraryAppletCreator::CreateStorage>, "CreateStorage"}, + {11, D<&ILibraryAppletCreator::CreateTransferMemoryStorage>, "CreateTransferMemoryStorage"}, + {12, D<&ILibraryAppletCreator::CreateHandleStorage>, "CreateHandleStorage"}, }; RegisterHandlers(functions); } ILibraryAppletCreator::~ILibraryAppletCreator() = default; -void ILibraryAppletCreator::CreateLibraryApplet(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - const auto applet_id = rp.PopRaw<AppletId>(); - const auto applet_mode = rp.PopRaw<LibraryAppletMode>(); - - LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}", applet_id, - applet_mode); +Result ILibraryAppletCreator::CreateLibraryApplet( + Out<SharedPointer<ILibraryAppletAccessor>> out_library_applet_accessor, AppletId applet_id, + LibraryAppletMode library_applet_mode) { + LOG_DEBUG(Service_AM, "called with applet_id={} applet_mode={}", applet_id, + library_applet_mode); std::shared_ptr<ILibraryAppletAccessor> library_applet; if (ShouldCreateGuestApplet(applet_id)) { - library_applet = CreateGuestApplet(system, applet, applet_id, applet_mode); + library_applet = CreateGuestApplet(system, m_applet, applet_id, library_applet_mode); } if (!library_applet) { - library_applet = CreateFrontendApplet(system, applet, applet_id, applet_mode); + library_applet = CreateFrontendApplet(system, m_applet, applet_id, library_applet_mode); } if (!library_applet) { LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", applet_id); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - return; + R_THROW(ResultUnknown); } // Applet is created, can now be launched. - applet->library_applet_launchable_event.Signal(); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<ILibraryAppletAccessor>(library_applet); + m_applet->library_applet_launchable_event.Signal(); + *out_library_applet_accessor = library_applet; + R_SUCCEED(); } -void ILibraryAppletCreator::CreateStorage(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - const s64 size{rp.Pop<s64>()}; - +Result ILibraryAppletCreator::CreateStorage(Out<SharedPointer<IStorage>> out_storage, s64 size) { LOG_DEBUG(Service_AM, "called, size={}", size); if (size <= 0) { LOG_ERROR(Service_AM, "size is less than or equal to 0"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - return; + R_THROW(ResultUnknown); } - std::vector<u8> data(size); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<IStorage>(system, AM::CreateStorage(std::move(data))); + *out_storage = std::make_shared<IStorage>(system, AM::CreateStorage(std::vector<u8>(size))); + R_SUCCEED(); } -void ILibraryAppletCreator::CreateTransferMemoryStorage(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - struct Parameters { - bool is_writable; - s64 size; - }; +Result ILibraryAppletCreator::CreateTransferMemoryStorage( + Out<SharedPointer<IStorage>> out_storage, bool is_writable, s64 size, + InCopyHandle<Kernel::KTransferMemory> transfer_memory_handle) { + LOG_DEBUG(Service_AM, "called, is_writable={} size={}", is_writable, size); - const auto params{rp.PopRaw<Parameters>()}; - const auto handle{ctx.GetCopyHandle(0)}; - - LOG_DEBUG(Service_AM, "called, is_writable={}, size={}, handle={:08X}", params.is_writable, - params.size, handle); - - if (params.size <= 0) { + if (size <= 0) { LOG_ERROR(Service_AM, "size is less than or equal to 0"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - return; + R_THROW(ResultUnknown); } - auto transfer_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(handle); - - if (transfer_mem.IsNull()) { - LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - return; + if (!transfer_memory_handle) { + LOG_ERROR(Service_AM, "transfer_memory_handle is null"); + R_THROW(ResultUnknown); } - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<IStorage>( - system, AM::CreateTransferMemoryStorage(ctx.GetMemory(), transfer_mem.GetPointerUnsafe(), - params.is_writable, params.size)); + *out_storage = std::make_shared<IStorage>( + system, AM::CreateTransferMemoryStorage(transfer_memory_handle->GetOwner()->GetMemory(), + transfer_memory_handle.Get(), is_writable, size)); + R_SUCCEED(); } -void ILibraryAppletCreator::CreateHandleStorage(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - const s64 size{rp.Pop<s64>()}; - const auto handle{ctx.GetCopyHandle(0)}; - - LOG_DEBUG(Service_AM, "called, size={}, handle={:08X}", size, handle); +Result ILibraryAppletCreator::CreateHandleStorage( + Out<SharedPointer<IStorage>> out_storage, s64 size, + InCopyHandle<Kernel::KTransferMemory> transfer_memory_handle) { + LOG_DEBUG(Service_AM, "called, size={}", size); if (size <= 0) { LOG_ERROR(Service_AM, "size is less than or equal to 0"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - return; + R_THROW(ResultUnknown); } - auto transfer_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(handle); - - if (transfer_mem.IsNull()) { - LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultUnknown); - return; + if (!transfer_memory_handle) { + LOG_ERROR(Service_AM, "transfer_memory_handle is null"); + R_THROW(ResultUnknown); } - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<IStorage>( - system, AM::CreateHandleStorage(ctx.GetMemory(), transfer_mem.GetPointerUnsafe(), size)); + *out_storage = std::make_shared<IStorage>( + system, AM::CreateHandleStorage(transfer_memory_handle->GetOwner()->GetMemory(), + transfer_memory_handle.Get(), size)); + R_SUCCEED(); } } // namespace Service::AM diff --git a/src/core/hle/service/am/service/library_applet_creator.h b/src/core/hle/service/am/service/library_applet_creator.h new file mode 100644 index 000000000..fe6d40eb3 --- /dev/null +++ b/src/core/hle/service/am/service/library_applet_creator.h @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/service/am/am_types.h" +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Service::AM { + +struct Applet; +class ILibraryAppletAccessor; +class IStorage; + +class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> { +public: + explicit ILibraryAppletCreator(Core::System& system_, std::shared_ptr<Applet> applet); + ~ILibraryAppletCreator() override; + +private: + Result CreateLibraryApplet( + Out<SharedPointer<ILibraryAppletAccessor>> out_library_applet_accessor, AppletId applet_id, + LibraryAppletMode library_applet_mode); + Result CreateStorage(Out<SharedPointer<IStorage>> out_storage, s64 size); + Result CreateTransferMemoryStorage( + Out<SharedPointer<IStorage>> out_storage, bool is_writable, s64 size, + InCopyHandle<Kernel::KTransferMemory> transfer_memory_handle); + Result CreateHandleStorage(Out<SharedPointer<IStorage>> out_storage, s64 size, + InCopyHandle<Kernel::KTransferMemory> transfer_memory_handle); + + const std::shared_ptr<Applet> m_applet; +}; + +} // namespace Service::AM diff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cpp index cf1a34db2..f1a13a331 100644 --- a/src/core/hle/service/am/service/library_applet_proxy.cpp +++ b/src/core/hle/service/am/service/library_applet_proxy.cpp @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#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" @@ -12,6 +11,7 @@ #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" +#include "core/hle/service/am/service/library_applet_creator.h" #include "core/hle/service/am/service/library_applet_proxy.h" #include "core/hle/service/am/window_controller.h" #include "core/hle/service/cmif_serialization.h" diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp index 8fa852cfa..59d5b2a23 100644 --- a/src/core/hle/service/am/service/system_applet_proxy.cpp +++ b/src/core/hle/service/am/service/system_applet_proxy.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/am/application_creator.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" @@ -13,6 +12,7 @@ #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" +#include "core/hle/service/am/service/library_applet_creator.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" |