VERY experimental Nintendo Switch 2 emulator
C++
am: rewrite IStorage
Liam0485f9a2e92f
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex c2c08c2e93..bd483816b7 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -477,14 +477,14 @@ add_library(core STATIChle/service/am/service/self_controller.hhle/service/am/service/storage_accessor.cpphle/service/am/service/storage_accessor.h+ hle/service/am/service/storage.cpp+ hle/service/am/service/storage.hhle/service/am/service/system_applet_proxy.cpphle/service/am/service/system_applet_proxy.hhle/service/am/system_buffer_manager.cpphle/service/am/system_buffer_manager.hhle/service/am/spsm.cpphle/service/am/spsm.h- hle/service/am/storage.cpp- hle/service/am/storage.hhle/service/am/window_controller.cpphle/service/am/window_controller.hhle/service/aoc/aoc_u.cppdiff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.hindex 6c593ab1ac..4f34d48114 100644--- a/src/core/hle/service/am/applet.h+++ b/src/core/hle/service/am/applet.h@@ -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 {diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cppindex b35d97bc7b..4c7266f899 100644--- a/src/core/hle/service/am/applet_manager.cpp+++ b/src/core/hle/service/am/applet_manager.cpp@@ -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 {diff --git a/src/core/hle/service/am/frontend/applet_cabinet.cpp b/src/core/hle/service/am/frontend/applet_cabinet.cppindex 0862c81b67..4cbc80d639 100644--- a/src/core/hle/service/am/frontend/applet_cabinet.cpp+++ b/src/core/hle/service/am/frontend/applet_cabinet.cpp@@ -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"diff --git a/src/core/hle/service/am/frontend/applet_controller.cpp b/src/core/hle/service/am/frontend/applet_controller.cppindex bd3e49fc4d..66f52686d7 100644--- a/src/core/hle/service/am/frontend/applet_controller.cpp+++ b/src/core/hle/service/am/frontend/applet_controller.cpp@@ -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"diff --git a/src/core/hle/service/am/frontend/applet_error.cpp b/src/core/hle/service/am/frontend/applet_error.cppindex b97a5f3ea3..34ec7013b5 100644--- a/src/core/hle/service/am/frontend/applet_error.cpp+++ b/src/core/hle/service/am/frontend/applet_error.cpp@@ -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 {diff --git a/src/core/hle/service/am/frontend/applet_general.cpp b/src/core/hle/service/am/frontend/applet_general.cppindex 3c091a602f..d2cabb7b59 100644--- a/src/core/hle/service/am/frontend/applet_general.cpp+++ b/src/core/hle/service/am/frontend/applet_general.cpp@@ -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 {diff --git a/src/core/hle/service/am/frontend/applet_mii_edit.cpp b/src/core/hle/service/am/frontend/applet_mii_edit.cppindex e3d19fb3d0..0180ab761a 100644--- a/src/core/hle/service/am/frontend/applet_mii_edit.cpp+++ b/src/core/hle/service/am/frontend/applet_mii_edit.cpp@@ -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"diff --git a/src/core/hle/service/am/frontend/applet_profile_select.cpp b/src/core/hle/service/am/frontend/applet_profile_select.cppindex efb4053b85..89b5a1eabe 100644--- a/src/core/hle/service/am/frontend/applet_profile_select.cpp+++ b/src/core/hle/service/am/frontend/applet_profile_select.cpp@@ -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 {diff --git a/src/core/hle/service/am/frontend/applet_software_keyboard.cpp b/src/core/hle/service/am/frontend/applet_software_keyboard.cppindex 034c62f327..d1bc030182 100644--- a/src/core/hle/service/am/frontend/applet_software_keyboard.cpp+++ b/src/core/hle/service/am/frontend/applet_software_keyboard.cpp@@ -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 {diff --git a/src/core/hle/service/am/frontend/applet_web_browser.cpp b/src/core/hle/service/am/frontend/applet_web_browser.cppindex 6ee4caf34c..bb60260b4f 100644--- a/src/core/hle/service/am/frontend/applet_web_browser.cpp+++ b/src/core/hle/service/am/frontend/applet_web_browser.cpp@@ -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"diff --git a/src/core/hle/service/am/frontend/applets.cpp b/src/core/hle/service/am/frontend/applets.cppindex 944d8b1055..e662c6cd63 100644--- a/src/core/hle/service/am/frontend/applets.cpp+++ b/src/core/hle/service/am/frontend/applets.cpp@@ -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 {diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cppindex 346ab42ab7..b788fddd47 100644--- a/src/core/hle/service/am/service/application_functions.cpp+++ b/src/core/hle/service/am/service/application_functions.cpp@@ -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"diff --git a/src/core/hle/service/am/service/library_applet_accessor.cpp b/src/core/hle/service/am/service/library_applet_accessor.cppindex aac875ef48..0c2426d4ba 100644--- a/src/core/hle/service/am/service/library_applet_accessor.cpp+++ b/src/core/hle/service/am/service/library_applet_accessor.cpp@@ -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 {diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cppindex 4d905549cf..166637d603 100644--- a/src/core/hle/service/am/service/library_applet_creator.cpp+++ b/src/core/hle/service/am/service/library_applet_creator.cpp@@ -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"diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.cpp b/src/core/hle/service/am/service/library_applet_self_accessor.cppindex a432a79ba2..7a3a86e88b 100644--- a/src/core/hle/service/am/service/library_applet_self_accessor.cpp+++ b/src/core/hle/service/am/service/library_applet_self_accessor.cpp@@ -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"diff --git a/src/core/hle/service/am/service/storage.cpp b/src/core/hle/service/am/service/storage.cppnew file mode 100644index 0000000000..25ee0afbdb--- /dev/null+++ b/src/core/hle/service/am/service/storage.cpp@@ -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::AMdiff --git a/src/core/hle/service/am/storage.h b/src/core/hle/service/am/service/storage.hsimilarity index 60%rename from src/core/hle/service/am/storage.hrename to src/core/hle/service/am/service/storage.hindex 10d00b1419..cde2ed0ead 100644--- a/src/core/hle/service/am/storage.h+++ b/src/core/hle/service/am/service/storage.h@@ -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::AMdiff --git a/src/core/hle/service/am/storage.cpp b/src/core/hle/service/am/storage.cppdeleted file mode 100644index 12d95eebde..0000000000--- a/src/core/hle/service/am/storage.cpp+++ /dev/null@@ -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