mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-23 01:55:45 +01:00
am: rewrite ILibraryAppletCreator
This commit is contained in:
parent
f9bba8007d
commit
1c797a8048
@ -429,8 +429,6 @@ add_library(core STATIC
|
|||||||
hle/service/am/hid_registration.h
|
hle/service/am/hid_registration.h
|
||||||
hle/service/am/idle.cpp
|
hle/service/am/idle.cpp
|
||||||
hle/service/am/idle.h
|
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.cpp
|
||||||
hle/service/am/library_applet_self_accessor.h
|
hle/service/am/library_applet_self_accessor.h
|
||||||
hle/service/am/library_applet_storage.cpp
|
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/home_menu_functions.h
|
||||||
hle/service/am/service/library_applet_accessor.cpp
|
hle/service/am/service/library_applet_accessor.cpp
|
||||||
hle/service/am/service/library_applet_accessor.h
|
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.cpp
|
||||||
hle/service/am/service/library_applet_proxy.h
|
hle/service/am/service/library_applet_proxy.h
|
||||||
hle/service/am/service/system_applet_proxy.cpp
|
hle/service/am/service/system_applet_proxy.cpp
|
||||||
|
@ -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
|
|
@ -1,7 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// 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/library_applet_self_accessor.h"
|
||||||
#include "core/hle/service/am/process_winding_controller.h"
|
#include "core/hle/service/am/process_winding_controller.h"
|
||||||
#include "core/hle/service/am/self_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/common_state_getter.h"
|
||||||
#include "core/hle/service/am/service/debug_functions.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/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/am/window_controller.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
#include "core/hle/service/am/applet_data_broker.h"
|
#include "core/hle/service/am/applet_data_broker.h"
|
||||||
#include "core/hle/service/am/applet_manager.h"
|
#include "core/hle/service/am/applet_manager.h"
|
||||||
#include "core/hle/service/am/frontend/applets.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/library_applet_storage.h"
|
||||||
#include "core/hle/service/am/service/library_applet_accessor.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/am/storage.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
@ -172,139 +172,97 @@ std::shared_ptr<ILibraryAppletAccessor> CreateFrontendApplet(Core::System& syste
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_, std::shared_ptr<Applet> applet_)
|
ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_, std::shared_ptr<Applet> applet)
|
||||||
: ServiceFramework{system_, "ILibraryAppletCreator"}, applet{std::move(applet_)} {
|
: ServiceFramework{system_, "ILibraryAppletCreator"}, m_applet{std::move(applet)} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
|
{0, D<&ILibraryAppletCreator::CreateLibraryApplet>, "CreateLibraryApplet"},
|
||||||
{1, nullptr, "TerminateAllLibraryApplets"},
|
{1, nullptr, "TerminateAllLibraryApplets"},
|
||||||
{2, nullptr, "AreAnyLibraryAppletsLeft"},
|
{2, nullptr, "AreAnyLibraryAppletsLeft"},
|
||||||
{10, &ILibraryAppletCreator::CreateStorage, "CreateStorage"},
|
{10, D<&ILibraryAppletCreator::CreateStorage>, "CreateStorage"},
|
||||||
{11, &ILibraryAppletCreator::CreateTransferMemoryStorage, "CreateTransferMemoryStorage"},
|
{11, D<&ILibraryAppletCreator::CreateTransferMemoryStorage>, "CreateTransferMemoryStorage"},
|
||||||
{12, &ILibraryAppletCreator::CreateHandleStorage, "CreateHandleStorage"},
|
{12, D<&ILibraryAppletCreator::CreateHandleStorage>, "CreateHandleStorage"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
ILibraryAppletCreator::~ILibraryAppletCreator() = default;
|
ILibraryAppletCreator::~ILibraryAppletCreator() = default;
|
||||||
|
|
||||||
void ILibraryAppletCreator::CreateLibraryApplet(HLERequestContext& ctx) {
|
Result ILibraryAppletCreator::CreateLibraryApplet(
|
||||||
IPC::RequestParser rp{ctx};
|
Out<SharedPointer<ILibraryAppletAccessor>> out_library_applet_accessor, AppletId applet_id,
|
||||||
|
LibraryAppletMode library_applet_mode) {
|
||||||
const auto applet_id = rp.PopRaw<AppletId>();
|
LOG_DEBUG(Service_AM, "called with applet_id={} applet_mode={}", applet_id,
|
||||||
const auto applet_mode = rp.PopRaw<LibraryAppletMode>();
|
library_applet_mode);
|
||||||
|
|
||||||
LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}", applet_id,
|
|
||||||
applet_mode);
|
|
||||||
|
|
||||||
std::shared_ptr<ILibraryAppletAccessor> library_applet;
|
std::shared_ptr<ILibraryAppletAccessor> library_applet;
|
||||||
if (ShouldCreateGuestApplet(applet_id)) {
|
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) {
|
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) {
|
if (!library_applet) {
|
||||||
LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", applet_id);
|
LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", applet_id);
|
||||||
|
R_THROW(ResultUnknown);
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultUnknown);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Applet is created, can now be launched.
|
// Applet is created, can now be launched.
|
||||||
applet->library_applet_launchable_event.Signal();
|
m_applet->library_applet_launchable_event.Signal();
|
||||||
|
*out_library_applet_accessor = library_applet;
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushIpcInterface<ILibraryAppletAccessor>(library_applet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ILibraryAppletCreator::CreateStorage(HLERequestContext& ctx) {
|
Result ILibraryAppletCreator::CreateStorage(Out<SharedPointer<IStorage>> out_storage, s64 size) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
|
|
||||||
const s64 size{rp.Pop<s64>()};
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_AM, "called, size={}", size);
|
LOG_DEBUG(Service_AM, "called, size={}", size);
|
||||||
|
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
LOG_ERROR(Service_AM, "size is less than or equal to 0");
|
LOG_ERROR(Service_AM, "size is less than or equal to 0");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_THROW(ResultUnknown);
|
||||||
rb.Push(ResultUnknown);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> data(size);
|
*out_storage = std::make_shared<IStorage>(system, AM::CreateStorage(std::vector<u8>(size)));
|
||||||
|
R_SUCCEED();
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushIpcInterface<IStorage>(system, AM::CreateStorage(std::move(data)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ILibraryAppletCreator::CreateTransferMemoryStorage(HLERequestContext& ctx) {
|
Result ILibraryAppletCreator::CreateTransferMemoryStorage(
|
||||||
IPC::RequestParser rp{ctx};
|
Out<SharedPointer<IStorage>> out_storage, bool is_writable, s64 size,
|
||||||
|
InCopyHandle<Kernel::KTransferMemory> transfer_memory_handle) {
|
||||||
struct Parameters {
|
LOG_DEBUG(Service_AM, "called, is_writable={} size={}", is_writable, size);
|
||||||
bool is_writable;
|
|
||||||
s64 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) {
|
|
||||||
LOG_ERROR(Service_AM, "size is less than or equal to 0");
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultUnknown);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
LOG_ERROR(Service_AM, "size is less than or equal to 0");
|
LOG_ERROR(Service_AM, "size is less than or equal to 0");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_THROW(ResultUnknown);
|
||||||
rb.Push(ResultUnknown);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto transfer_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(handle);
|
if (!transfer_memory_handle) {
|
||||||
|
LOG_ERROR(Service_AM, "transfer_memory_handle is null");
|
||||||
if (transfer_mem.IsNull()) {
|
R_THROW(ResultUnknown);
|
||||||
LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultUnknown);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
*out_storage = std::make_shared<IStorage>(
|
||||||
rb.Push(ResultSuccess);
|
system, AM::CreateTransferMemoryStorage(transfer_memory_handle->GetOwner()->GetMemory(),
|
||||||
rb.PushIpcInterface<IStorage>(
|
transfer_memory_handle.Get(), is_writable, size));
|
||||||
system, AM::CreateHandleStorage(ctx.GetMemory(), transfer_mem.GetPointerUnsafe(), size));
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
R_THROW(ResultUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!transfer_memory_handle) {
|
||||||
|
LOG_ERROR(Service_AM, "transfer_memory_handle is null");
|
||||||
|
R_THROW(ResultUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_storage = std::make_shared<IStorage>(
|
||||||
|
system, AM::CreateHandleStorage(transfer_memory_handle->GetOwner()->GetMemory(),
|
||||||
|
transfer_memory_handle.Get(), size));
|
||||||
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
35
src/core/hle/service/am/service/library_applet_creator.h
Normal file
35
src/core/hle/service/am/service/library_applet_creator.h
Normal file
@ -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
|
@ -1,7 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// 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/library_applet_self_accessor.h"
|
||||||
#include "core/hle/service/am/process_winding_controller.h"
|
#include "core/hle/service/am/process_winding_controller.h"
|
||||||
#include "core/hle/service/am/self_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/display_controller.h"
|
||||||
#include "core/hle/service/am/service/global_state_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/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/service/library_applet_proxy.h"
|
||||||
#include "core/hle/service/am/window_controller.h"
|
#include "core/hle/service/am/window_controller.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/hle/service/am/application_creator.h"
|
#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/library_applet_self_accessor.h"
|
||||||
#include "core/hle/service/am/process_winding_controller.h"
|
#include "core/hle/service/am/process_winding_controller.h"
|
||||||
#include "core/hle/service/am/self_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/display_controller.h"
|
||||||
#include "core/hle/service/am/service/global_state_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/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/service/system_applet_proxy.h"
|
||||||
#include "core/hle/service/am/window_controller.h"
|
#include "core/hle/service/am/window_controller.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user