yuzu-emu
/
yuzu
Archived
1
0
Fork 0

am: rewrite IStorage

This commit is contained in:
Liam 2024-02-11 20:34:27 -05:00
parent 2e614ce08f
commit 203d213529
19 changed files with 73 additions and 81 deletions

View File

@ -477,14 +477,14 @@ add_library(core STATIC
hle/service/am/service/self_controller.h
hle/service/am/service/storage_accessor.cpp
hle/service/am/service/storage_accessor.h
hle/service/am/service/storage.cpp
hle/service/am/service/storage.h
hle/service/am/service/system_applet_proxy.cpp
hle/service/am/service/system_applet_proxy.h
hle/service/am/system_buffer_manager.cpp
hle/service/am/system_buffer_manager.h
hle/service/am/spsm.cpp
hle/service/am/spsm.h
hle/service/am/storage.cpp
hle/service/am/storage.h
hle/service/am/window_controller.cpp
hle/service/am/window_controller.h
hle/service/aoc/aoc_u.cpp

View File

@ -3,7 +3,6 @@
#pragma once
#include <list>
#include <mutex>
#include "common/math_util.h"
@ -18,7 +17,6 @@
#include "core/hle/service/am/hid_registration.h"
#include "core/hle/service/am/managed_layer_holder.h"
#include "core/hle/service/am/process.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/system_buffer_manager.h"
namespace Service::AM {

View File

@ -12,6 +12,7 @@
#include "core/hle/service/am/frontend/applet_controller.h"
#include "core/hle/service/am/frontend/applet_mii_edit_types.h"
#include "core/hle/service/am/frontend/applet_software_keyboard_types.h"
#include "core/hle/service/am/service/storage.h"
#include "hid_core/hid_types.h"
namespace Service::AM {

View File

@ -9,7 +9,7 @@
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_cabinet.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/mii/mii_manager.h"
#include "core/hle/service/nfc/common/device.h"
#include "hid_core/hid_core.h"

View File

@ -12,7 +12,7 @@
#include "core/hle/result.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_controller.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "hid_core/frontend/emulated_controller.h"
#include "hid_core/hid_core.h"
#include "hid_core/hid_types.h"

View File

@ -10,7 +10,7 @@
#include "core/frontend/applets/error.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_error.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/reporter.h"
namespace Service::AM::Frontend {

View File

@ -10,7 +10,7 @@
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applet_data_broker.h"
#include "core/hle/service/am/frontend/applet_general.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/reporter.h"
namespace Service::AM::Frontend {

View File

@ -7,7 +7,7 @@
#include "core/frontend/applets/mii_edit.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_mii_edit.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/mii/mii.h"
#include "core/hle/service/mii/mii_manager.h"
#include "core/hle/service/sm/sm.h"

View File

@ -10,7 +10,7 @@
#include "core/hle/service/acc/errors.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_profile_select.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
namespace Service::AM::Frontend {

View File

@ -6,7 +6,7 @@
#include "core/frontend/applets/software_keyboard.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_software_keyboard.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
namespace Service::AM::Frontend {

View File

@ -20,7 +20,7 @@
#include "core/hle/result.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/frontend/applet_web_browser.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/ns/iplatform_service_manager.h"
#include "core/loader/loader.h"

View File

@ -26,7 +26,7 @@
#include "core/hle/service/am/frontend/applet_software_keyboard.h"
#include "core/hle/service/am/frontend/applet_web_browser.h"
#include "core/hle/service/am/frontend/applets.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/sm/sm.h"
namespace Service::AM::Frontend {

View File

@ -11,7 +11,7 @@
#include "core/hle/service/am/am_results.h"
#include "core/hle/service/am/applet.h"
#include "core/hle/service/am/service/application_functions.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/filesystem/save_data_controller.h"

View File

@ -5,7 +5,7 @@
#include "core/hle/service/am/applet_manager.h"
#include "core/hle/service/am/frontend/applets.h"
#include "core/hle/service/am/service/library_applet_accessor.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/cmif_serialization.h"
namespace Service::AM {

View File

@ -9,7 +9,7 @@
#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/am/service/storage.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/sm/sm.h"

View File

@ -10,7 +10,7 @@
#include "core/hle/service/am/applet_manager.h"
#include "core/hle/service/am/frontend/applets.h"
#include "core/hle/service/am/service/library_applet_self_accessor.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/glue/glue_manager.h"

View File

@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/am_results.h"
#include "core/hle/service/am/library_applet_storage.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/am/service/storage_accessor.h"
#include "core/hle/service/cmif_serialization.h"
namespace Service::AM {
IStorage::IStorage(Core::System& system_, std::shared_ptr<LibraryAppletStorage> impl)
: ServiceFramework{system_, "IStorage"}, m_impl{std::move(impl)} {
static const FunctionInfo functions[] = {
{0, D<&IStorage::Open>, "Open"},
{1, D<&IStorage::OpenTransferStorage>, "OpenTransferStorage"},
};
RegisterHandlers(functions);
}
IStorage::IStorage(Core::System& system_, std::vector<u8>&& data)
: IStorage(system_, CreateStorage(std::move(data))) {}
IStorage::~IStorage() = default;
Result IStorage::Open(Out<SharedPointer<IStorageAccessor>> out_storage_accessor) {
LOG_DEBUG(Service_AM, "called");
R_UNLESS(m_impl->GetHandle() == nullptr, AM::ResultInvalidStorageType);
*out_storage_accessor = std::make_shared<IStorageAccessor>(system, m_impl);
R_SUCCEED();
}
Result IStorage::OpenTransferStorage(
Out<SharedPointer<ITransferStorageAccessor>> out_transfer_storage_accessor) {
R_UNLESS(m_impl->GetHandle() != nullptr, AM::ResultInvalidStorageType);
*out_transfer_storage_accessor = std::make_shared<ITransferStorageAccessor>(system, m_impl);
R_SUCCEED();
}
std::vector<u8> IStorage::GetData() const {
return m_impl->GetData();
}
} // namespace Service::AM

View File

@ -3,29 +3,33 @@
#pragma once
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Service::AM {
class LibraryAppletStorage;
class IStorageAccessor;
class ITransferStorageAccessor;
class IStorage final : public ServiceFramework<IStorage> {
public:
explicit IStorage(Core::System& system_, std::shared_ptr<LibraryAppletStorage> impl_);
explicit IStorage(Core::System& system_, std::shared_ptr<LibraryAppletStorage> impl);
explicit IStorage(Core::System& system_, std::vector<u8>&& buffer);
~IStorage() override;
std::shared_ptr<LibraryAppletStorage> GetImpl() const {
return impl;
return m_impl;
}
std::vector<u8> GetData() const;
private:
void Open(HLERequestContext& ctx);
void OpenTransferStorage(HLERequestContext& ctx);
Result Open(Out<SharedPointer<IStorageAccessor>> out_storage_accessor);
Result OpenTransferStorage(
Out<SharedPointer<ITransferStorageAccessor>> out_transfer_storage_accessor);
const std::shared_ptr<LibraryAppletStorage> impl;
const std::shared_ptr<LibraryAppletStorage> m_impl;
};
} // namespace Service::AM

View File

@ -1,59 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/am_results.h"
#include "core/hle/service/am/library_applet_storage.h"
#include "core/hle/service/am/service/storage_accessor.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::AM {
IStorage::IStorage(Core::System& system_, std::shared_ptr<LibraryAppletStorage> impl_)
: ServiceFramework{system_, "IStorage"}, impl{std::move(impl_)} {
static const FunctionInfo functions[] = {
{0, &IStorage::Open, "Open"},
{1, &IStorage::OpenTransferStorage, "OpenTransferStorage"},
};
RegisterHandlers(functions);
}
IStorage::IStorage(Core::System& system_, std::vector<u8>&& data)
: IStorage(system_, CreateStorage(std::move(data))) {}
IStorage::~IStorage() = default;
void IStorage::Open(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
if (impl->GetHandle() != nullptr) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(AM::ResultInvalidStorageType);
return;
}
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<IStorageAccessor>(system, impl);
}
void IStorage::OpenTransferStorage(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
if (impl->GetHandle() == nullptr) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(AM::ResultInvalidStorageType);
return;
}
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ITransferStorageAccessor>(system, impl);
}
std::vector<u8> IStorage::GetData() const {
return impl->GetData();
}
} // namespace Service::AM