summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/filesystem/fsp
diff options
context:
space:
mode:
authorFearlessTobi <thm.frey@gmail.com>2024-02-19 02:58:25 +0100
committerFearlessTobi <thm.frey@gmail.com>2024-02-19 19:06:31 +0100
commit4c71bf3d907efaeb97bc2b0461bece520a91d198 (patch)
tree97ac18bc658aaae2264198e5de3c62dc4fcb3b1b /src/core/hle/service/filesystem/fsp
parentfsp-srv: Migrate to use cmif serialization (diff)
downloadyuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar
yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.gz
yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.bz2
yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.lz
yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.xz
yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.tar.zst
yuzu-4c71bf3d907efaeb97bc2b0461bece520a91d198.zip
Diffstat (limited to 'src/core/hle/service/filesystem/fsp')
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp16
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h4
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp20
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h16
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_storage.cpp47
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_storage.h7
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 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h"
-#include "core/hle/service/ipc_helpers.h"
namespace Service::FileSystem {
IMultiCommitManager::IMultiCommitManager(Core::System& system_)
: ServiceFramework{system_, "IMultiCommitManager"} {
static const FunctionInfo functions[] = {
- {1, &IMultiCommitManager::Add, "Add"},
- {2, &IMultiCommitManager::Commit, "Commit"},
+ {1, D<&IMultiCommitManager::Add>, "Add"},
+ {2, D<&IMultiCommitManager::Commit>, "Commit"},
};
RegisterHandlers(functions);
}
IMultiCommitManager::~IMultiCommitManager() = default;
-void IMultiCommitManager::Add(HLERequestContext& ctx) {
+Result IMultiCommitManager::Add() {
LOG_WARNING(Service_FS, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ R_SUCCEED();
}
-void IMultiCommitManager::Commit(HLERequestContext& ctx) {
+Result IMultiCommitManager::Commit() {
LOG_WARNING(Service_FS, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ R_SUCCEED();
}
} // 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:
~IMultiCommitManager() override;
private:
- void Add(HLERequestContext& ctx);
- void Commit(HLERequestContext& ctx);
+ Result Add();
+ Result Commit();
FileSys::VirtualFile backend;
};
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 @@
#include "common/hex_util.h"
#include "core/file_sys/savedata_factory.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h"
#include "core/hle/service/filesystem/save_data_controller.h"
-#include "core/hle/service/ipc_helpers.h"
namespace Service::FileSystem {
ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_,
std::shared_ptr<SaveDataController> save_data_controller_,
FileSys::SaveDataSpaceId space)
- : ServiceFramework{system_, "ISaveDataInfoReader"},
- save_data_controller{save_data_controller_} {
+ : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{
+ save_data_controller_} {
static const FunctionInfo functions[] = {
- {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"},
+ {0, D<&ISaveDataInfoReader::ReadSaveDataInfo>, "ReadSaveDataInfo"},
};
RegisterHandlers(functions);
@@ -36,11 +36,12 @@ static u64 stoull_be(std::string_view str) {
return Common::swap64(out);
}
-void ISaveDataInfoReader::ReadSaveDataInfo(HLERequestContext& ctx) {
+Result ISaveDataInfoReader::ReadSaveDataInfo(
+ Out<u64> out_count, OutArray<SaveDataInfo, BufferAttr_HipcMapAlias> out_entries) {
LOG_DEBUG(Service_FS, "called");
// Calculate how many entries we can fit in the output buffer
- const u64 count_entries = ctx.GetWriteBufferNumElements<SaveDataInfo>();
+ const u64 count_entries = out_entries.size();
// Cap at total number of entries.
const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index);
@@ -53,11 +54,10 @@ void ISaveDataInfoReader::ReadSaveDataInfo(HLERequestContext& ctx) {
next_entry_index += actual_entries;
// Write the data to memory
- ctx.WriteBuffer(begin, range_size);
+ std::memcpy(out_entries.data(), begin, range_size);
+ *out_count = actual_entries;
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(ResultSuccess);
- rb.Push<u64>(actual_entries);
+ R_SUCCEED();
}
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 @@
#include <vector>
#include "common/common_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Service::FileSystem {
@@ -18,13 +19,6 @@ public:
FileSys::SaveDataSpaceId space);
~ISaveDataInfoReader() override;
- void ReadSaveDataInfo(HLERequestContext& ctx);
-
-private:
- void FindAllSaves(FileSys::SaveDataSpaceId space);
- void FindNormalSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type);
- void FindTemporaryStorageSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type);
-
struct SaveDataInfo {
u64_le save_id_unknown;
FileSys::SaveDataSpaceId space;
@@ -40,6 +34,14 @@ private:
};
static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size.");
+ Result ReadSaveDataInfo(Out<u64> out_count,
+ OutArray<SaveDataInfo, BufferAttr_HipcMapAlias> out_entries);
+
+private:
+ void FindAllSaves(FileSys::SaveDataSpaceId space);
+ void FindNormalSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type);
+ void FindTemporaryStorageSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type);
+
std::shared_ptr<SaveDataController> save_data_controller;
std::vector<SaveDataInfo> info;
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 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/file_sys/errors.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/filesystem/fsp/fs_i_storage.h"
-#include "core/hle/service/ipc_helpers.h"
namespace Service::FileSystem {
IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_)
: ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) {
static const FunctionInfo functions[] = {
- {0, &IStorage::Read, "Read"},
+ {0, D<&IStorage::Read>, "Read"},
{1, nullptr, "Write"},
{2, nullptr, "Flush"},
{3, nullptr, "SetSize"},
- {4, &IStorage::GetSize, "GetSize"},
+ {4, D<&IStorage::GetSize>, "GetSize"},
{5, nullptr, "OperateRange"},
};
RegisterHandlers(functions);
}
-void IStorage::Read(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const s64 offset = rp.Pop<s64>();
- const s64 length = rp.Pop<s64>();
-
+Result IStorage::Read(
+ OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes,
+ s64 offset, s64 length) {
LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length);
- // Error checking
- if (length < 0) {
- LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(FileSys::ResultInvalidSize);
- return;
- }
- if (offset < 0) {
- LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(FileSys::ResultInvalidOffset);
- return;
- }
+ R_UNLESS(length >= 0, FileSys::ResultInvalidSize);
+ R_UNLESS(offset >= 0, FileSys::ResultInvalidOffset);
// Read the data from the Storage backend
- std::vector<u8> output = backend->ReadBytes(length, offset);
- // Write the data to memory
- ctx.WriteBuffer(output);
+ backend->Read(out_bytes.data(), length, offset);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ R_SUCCEED();
}
-void IStorage::GetSize(HLERequestContext& ctx) {
- const u64 size = backend->GetSize();
- LOG_DEBUG(Service_FS, "called, size={}", size);
+Result IStorage::GetSize(Out<u64> out_size) {
+ *out_size = backend->GetSize();
+
+ LOG_DEBUG(Service_FS, "called, size={}", *out_size);
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(ResultSuccess);
- rb.Push<u64>(size);
+ R_SUCCEED();
}
} // 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 @@
#pragma once
#include "core/file_sys/vfs/vfs.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/service.h"
@@ -16,8 +17,10 @@ public:
private:
FileSys::VirtualFile backend;
- void Read(HLERequestContext& ctx);
- void GetSize(HLERequestContext& ctx);
+ Result Read(
+ OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes,
+ s64 offset, s64 length);
+ Result GetSize(Out<u64> out_size);
};
} // namespace Service::FileSystem