diff options
| author | 2024-02-19 02:58:25 +0100 | |
|---|---|---|
| committer | 2024-02-19 19:06:31 +0100 | |
| commit | 4c71bf3d907efaeb97bc2b0461bece520a91d198 (patch) | |
| tree | 97ac18bc658aaae2264198e5de3c62dc4fcb3b1b | |
| parent | fsp-srv: Migrate to use cmif serialization (diff) | |
| download | yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.gz yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.xz yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.zip | |
fsp: Migrate remaining interfaces to cmif serialization
6 files changed, 48 insertions, 62 deletions
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp index 054bf5054..13914b5e1 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp | |||
| @@ -1,34 +1,32 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 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/cmif_serialization.h" | ||
| 4 | #include "core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h" | 5 | #include "core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h" |
| 5 | #include "core/hle/service/ipc_helpers.h" | ||
| 6 | 6 | ||
| 7 | namespace Service::FileSystem { | 7 | namespace Service::FileSystem { |
| 8 | 8 | ||
| 9 | IMultiCommitManager::IMultiCommitManager(Core::System& system_) | 9 | IMultiCommitManager::IMultiCommitManager(Core::System& system_) |
| 10 | : ServiceFramework{system_, "IMultiCommitManager"} { | 10 | : ServiceFramework{system_, "IMultiCommitManager"} { |
| 11 | static const FunctionInfo functions[] = { | 11 | static const FunctionInfo functions[] = { |
| 12 | {1, &IMultiCommitManager::Add, "Add"}, | 12 | {1, D<&IMultiCommitManager::Add>, "Add"}, |
| 13 | {2, &IMultiCommitManager::Commit, "Commit"}, | 13 | {2, D<&IMultiCommitManager::Commit>, "Commit"}, |
| 14 | }; | 14 | }; |
| 15 | RegisterHandlers(functions); | 15 | RegisterHandlers(functions); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | IMultiCommitManager::~IMultiCommitManager() = default; | 18 | IMultiCommitManager::~IMultiCommitManager() = default; |
| 19 | 19 | ||
| 20 | void IMultiCommitManager::Add(HLERequestContext& ctx) { | 20 | Result IMultiCommitManager::Add() { |
| 21 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 21 | LOG_WARNING(Service_FS, "(STUBBED) called"); |
| 22 | 22 | ||
| 23 | IPC::ResponseBuilder rb{ctx, 2}; | 23 | R_SUCCEED(); |
| 24 | rb.Push(ResultSuccess); | ||
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | void IMultiCommitManager::Commit(HLERequestContext& ctx) { | 26 | Result IMultiCommitManager::Commit() { |
| 28 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 27 | LOG_WARNING(Service_FS, "(STUBBED) called"); |
| 29 | 28 | ||
| 30 | IPC::ResponseBuilder rb{ctx, 2}; | 29 | R_SUCCEED(); |
| 31 | rb.Push(ResultSuccess); | ||
| 32 | } | 30 | } |
| 33 | 31 | ||
| 34 | } // namespace Service::FileSystem | 32 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h index 6124873b3..274ef0513 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h | |||
| @@ -14,8 +14,8 @@ public: | |||
| 14 | ~IMultiCommitManager() override; | 14 | ~IMultiCommitManager() override; |
| 15 | 15 | ||
| 16 | private: | 16 | private: |
| 17 | void Add(HLERequestContext& ctx); | 17 | Result Add(); |
| 18 | void Commit(HLERequestContext& ctx); | 18 | Result Commit(); |
| 19 | 19 | ||
| 20 | FileSys::VirtualFile backend; | 20 | FileSys::VirtualFile backend; |
| 21 | }; | 21 | }; |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp index 872377d03..0d9b0dcaf 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp | |||
| @@ -3,19 +3,19 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/hex_util.h" | 4 | #include "common/hex_util.h" |
| 5 | #include "core/file_sys/savedata_factory.h" | 5 | #include "core/file_sys/savedata_factory.h" |
| 6 | #include "core/hle/service/cmif_serialization.h" | ||
| 6 | #include "core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h" | 7 | #include "core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h" |
| 7 | #include "core/hle/service/filesystem/save_data_controller.h" | 8 | #include "core/hle/service/filesystem/save_data_controller.h" |
| 8 | #include "core/hle/service/ipc_helpers.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::FileSystem { | 10 | namespace Service::FileSystem { |
| 11 | 11 | ||
| 12 | ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_, | 12 | ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_, |
| 13 | std::shared_ptr<SaveDataController> save_data_controller_, | 13 | std::shared_ptr<SaveDataController> save_data_controller_, |
| 14 | FileSys::SaveDataSpaceId space) | 14 | FileSys::SaveDataSpaceId space) |
| 15 | : ServiceFramework{system_, "ISaveDataInfoReader"}, | 15 | : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{ |
| 16 | save_data_controller{save_data_controller_} { | 16 | save_data_controller_} { |
| 17 | static const FunctionInfo functions[] = { | 17 | static const FunctionInfo functions[] = { |
| 18 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, | 18 | {0, D<&ISaveDataInfoReader::ReadSaveDataInfo>, "ReadSaveDataInfo"}, |
| 19 | }; | 19 | }; |
| 20 | RegisterHandlers(functions); | 20 | RegisterHandlers(functions); |
| 21 | 21 | ||
| @@ -36,11 +36,12 @@ static u64 stoull_be(std::string_view str) { | |||
| 36 | return Common::swap64(out); | 36 | return Common::swap64(out); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | void ISaveDataInfoReader::ReadSaveDataInfo(HLERequestContext& ctx) { | 39 | Result ISaveDataInfoReader::ReadSaveDataInfo( |
| 40 | Out<u64> out_count, OutArray<SaveDataInfo, BufferAttr_HipcMapAlias> out_entries) { | ||
| 40 | LOG_DEBUG(Service_FS, "called"); | 41 | LOG_DEBUG(Service_FS, "called"); |
| 41 | 42 | ||
| 42 | // Calculate how many entries we can fit in the output buffer | 43 | // Calculate how many entries we can fit in the output buffer |
| 43 | const u64 count_entries = ctx.GetWriteBufferNumElements<SaveDataInfo>(); | 44 | const u64 count_entries = out_entries.size(); |
| 44 | 45 | ||
| 45 | // Cap at total number of entries. | 46 | // Cap at total number of entries. |
| 46 | const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index); | 47 | const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index); |
| @@ -53,11 +54,10 @@ void ISaveDataInfoReader::ReadSaveDataInfo(HLERequestContext& ctx) { | |||
| 53 | next_entry_index += actual_entries; | 54 | next_entry_index += actual_entries; |
| 54 | 55 | ||
| 55 | // Write the data to memory | 56 | // Write the data to memory |
| 56 | ctx.WriteBuffer(begin, range_size); | 57 | std::memcpy(out_entries.data(), begin, range_size); |
| 58 | *out_count = actual_entries; | ||
| 57 | 59 | ||
| 58 | IPC::ResponseBuilder rb{ctx, 4}; | 60 | R_SUCCEED(); |
| 59 | rb.Push(ResultSuccess); | ||
| 60 | rb.Push<u64>(actual_entries); | ||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | void ISaveDataInfoReader::FindAllSaves(FileSys::SaveDataSpaceId space) { | 63 | void ISaveDataInfoReader::FindAllSaves(FileSys::SaveDataSpaceId space) { |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h index 86e09973b..7b21b029b 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/hle/service/cmif_types.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| 10 | namespace Service::FileSystem { | 11 | namespace Service::FileSystem { |
| @@ -18,13 +19,6 @@ public: | |||
| 18 | FileSys::SaveDataSpaceId space); | 19 | FileSys::SaveDataSpaceId space); |
| 19 | ~ISaveDataInfoReader() override; | 20 | ~ISaveDataInfoReader() override; |
| 20 | 21 | ||
| 21 | void ReadSaveDataInfo(HLERequestContext& ctx); | ||
| 22 | |||
| 23 | private: | ||
| 24 | void FindAllSaves(FileSys::SaveDataSpaceId space); | ||
| 25 | void FindNormalSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type); | ||
| 26 | void FindTemporaryStorageSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type); | ||
| 27 | |||
| 28 | struct SaveDataInfo { | 22 | struct SaveDataInfo { |
| 29 | u64_le save_id_unknown; | 23 | u64_le save_id_unknown; |
| 30 | FileSys::SaveDataSpaceId space; | 24 | FileSys::SaveDataSpaceId space; |
| @@ -40,6 +34,14 @@ private: | |||
| 40 | }; | 34 | }; |
| 41 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); | 35 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); |
| 42 | 36 | ||
| 37 | Result ReadSaveDataInfo(Out<u64> out_count, | ||
| 38 | OutArray<SaveDataInfo, BufferAttr_HipcMapAlias> out_entries); | ||
| 39 | |||
| 40 | private: | ||
| 41 | void FindAllSaves(FileSys::SaveDataSpaceId space); | ||
| 42 | void FindNormalSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type); | ||
| 43 | void FindTemporaryStorageSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type); | ||
| 44 | |||
| 43 | std::shared_ptr<SaveDataController> save_data_controller; | 45 | std::shared_ptr<SaveDataController> save_data_controller; |
| 44 | std::vector<SaveDataInfo> info; | 46 | std::vector<SaveDataInfo> info; |
| 45 | u64 next_entry_index = 0; | 47 | u64 next_entry_index = 0; |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp b/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp index 98223c1f9..213f19808 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp | |||
| @@ -2,61 +2,44 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/file_sys/errors.h" | 4 | #include "core/file_sys/errors.h" |
| 5 | #include "core/hle/service/cmif_serialization.h" | ||
| 5 | #include "core/hle/service/filesystem/fsp/fs_i_storage.h" | 6 | #include "core/hle/service/filesystem/fsp/fs_i_storage.h" |
| 6 | #include "core/hle/service/ipc_helpers.h" | ||
| 7 | 7 | ||
| 8 | namespace Service::FileSystem { | 8 | namespace Service::FileSystem { |
| 9 | 9 | ||
| 10 | IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_) | 10 | IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_) |
| 11 | : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) { | 11 | : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) { |
| 12 | static const FunctionInfo functions[] = { | 12 | static const FunctionInfo functions[] = { |
| 13 | {0, &IStorage::Read, "Read"}, | 13 | {0, D<&IStorage::Read>, "Read"}, |
| 14 | {1, nullptr, "Write"}, | 14 | {1, nullptr, "Write"}, |
| 15 | {2, nullptr, "Flush"}, | 15 | {2, nullptr, "Flush"}, |
| 16 | {3, nullptr, "SetSize"}, | 16 | {3, nullptr, "SetSize"}, |
| 17 | {4, &IStorage::GetSize, "GetSize"}, | 17 | {4, D<&IStorage::GetSize>, "GetSize"}, |
| 18 | {5, nullptr, "OperateRange"}, | 18 | {5, nullptr, "OperateRange"}, |
| 19 | }; | 19 | }; |
| 20 | RegisterHandlers(functions); | 20 | RegisterHandlers(functions); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | void IStorage::Read(HLERequestContext& ctx) { | 23 | Result IStorage::Read( |
| 24 | IPC::RequestParser rp{ctx}; | 24 | OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes, |
| 25 | const s64 offset = rp.Pop<s64>(); | 25 | s64 offset, s64 length) { |
| 26 | const s64 length = rp.Pop<s64>(); | ||
| 27 | |||
| 28 | LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length); | 26 | LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length); |
| 29 | 27 | ||
| 30 | // Error checking | 28 | R_UNLESS(length >= 0, FileSys::ResultInvalidSize); |
| 31 | if (length < 0) { | 29 | R_UNLESS(offset >= 0, FileSys::ResultInvalidOffset); |
| 32 | LOG_ERROR(Service_FS, "Length is less than 0, length={}", length); | ||
| 33 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 34 | rb.Push(FileSys::ResultInvalidSize); | ||
| 35 | return; | ||
| 36 | } | ||
| 37 | if (offset < 0) { | ||
| 38 | LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset); | ||
| 39 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 40 | rb.Push(FileSys::ResultInvalidOffset); | ||
| 41 | return; | ||
| 42 | } | ||
| 43 | 30 | ||
| 44 | // Read the data from the Storage backend | 31 | // Read the data from the Storage backend |
| 45 | std::vector<u8> output = backend->ReadBytes(length, offset); | 32 | backend->Read(out_bytes.data(), length, offset); |
| 46 | // Write the data to memory | ||
| 47 | ctx.WriteBuffer(output); | ||
| 48 | 33 | ||
| 49 | IPC::ResponseBuilder rb{ctx, 2}; | 34 | R_SUCCEED(); |
| 50 | rb.Push(ResultSuccess); | ||
| 51 | } | 35 | } |
| 52 | 36 | ||
| 53 | void IStorage::GetSize(HLERequestContext& ctx) { | 37 | Result IStorage::GetSize(Out<u64> out_size) { |
| 54 | const u64 size = backend->GetSize(); | 38 | *out_size = backend->GetSize(); |
| 55 | LOG_DEBUG(Service_FS, "called, size={}", size); | 39 | |
| 40 | LOG_DEBUG(Service_FS, "called, size={}", *out_size); | ||
| 56 | 41 | ||
| 57 | IPC::ResponseBuilder rb{ctx, 4}; | 42 | R_SUCCEED(); |
| 58 | rb.Push(ResultSuccess); | ||
| 59 | rb.Push<u64>(size); | ||
| 60 | } | 43 | } |
| 61 | 44 | ||
| 62 | } // namespace Service::FileSystem | 45 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_storage.h b/src/core/hle/service/filesystem/fsp/fs_i_storage.h index cb5bebcc9..74d879386 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_storage.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_storage.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/file_sys/vfs/vfs.h" | 6 | #include "core/file_sys/vfs/vfs.h" |
| 7 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/filesystem/filesystem.h" | 8 | #include "core/hle/service/filesystem/filesystem.h" |
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| @@ -16,8 +17,10 @@ public: | |||
| 16 | private: | 17 | private: |
| 17 | FileSys::VirtualFile backend; | 18 | FileSys::VirtualFile backend; |
| 18 | 19 | ||
| 19 | void Read(HLERequestContext& ctx); | 20 | Result Read( |
| 20 | void GetSize(HLERequestContext& ctx); | 21 | OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes, |
| 22 | s64 offset, s64 length); | ||
| 23 | Result GetSize(Out<u64> out_size); | ||
| 21 | }; | 24 | }; |
| 22 | 25 | ||
| 23 | } // namespace Service::FileSystem | 26 | } // namespace Service::FileSystem |