summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/filesystem/fsp/fs_i_file.cpp')
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_file.cpp78
1 files changed, 28 insertions, 50 deletions
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_file.cpp b/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
index 8fb8620de..a355d46ae 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
+++ b/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
@@ -2,86 +2,64 @@
// 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_file.h"
-#include "core/hle/service/ipc_helpers.h"
namespace Service::FileSystem {
IFile::IFile(Core::System& system_, FileSys::VirtualFile file_)
: ServiceFramework{system_, "IFile"}, backend{std::make_unique<FileSys::Fsa::IFile>(file_)} {
+ // clang-format off
static const FunctionInfo functions[] = {
- {0, &IFile::Read, "Read"},
- {1, &IFile::Write, "Write"},
- {2, &IFile::Flush, "Flush"},
- {3, &IFile::SetSize, "SetSize"},
- {4, &IFile::GetSize, "GetSize"},
+ {0, D<&IFile::Read>, "Read"},
+ {1, D<&IFile::Write>, "Write"},
+ {2, D<&IFile::Flush>, "Flush"},
+ {3, D<&IFile::SetSize>, "SetSize"},
+ {4, D<&IFile::GetSize>, "GetSize"},
{5, nullptr, "OperateRange"},
{6, nullptr, "OperateRangeWithBuffer"},
};
+ // clang-format on
RegisterHandlers(functions);
}
-void IFile::Read(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const u64 option = rp.Pop<u64>();
- const s64 offset = rp.Pop<s64>();
- const s64 length = rp.Pop<s64>();
-
- LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option, offset, length);
+Result IFile::Read(
+ FileSys::ReadOption option, Out<s64> out_size, s64 offset,
+ const OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_buffer,
+ s64 size) {
+ LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option.value, offset,
+ size);
// Read the data from the Storage backend
- std::vector<u8> output(length);
- std::size_t bytes_read;
- const auto result = backend->Read(&bytes_read, offset, output.data(), length);
-
- // Write the data to memory
- ctx.WriteBuffer(output);
-
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push(static_cast<u64>(bytes_read));
+ R_RETURN(
+ backend->Read(reinterpret_cast<size_t*>(out_size.Get()), offset, out_buffer.data(), size));
}
-void IFile::Write(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto option = rp.PopRaw<FileSys::WriteOption>();
- [[maybe_unused]] const u32 unused = rp.Pop<u32>();
- const s64 offset = rp.Pop<s64>();
- const s64 length = rp.Pop<s64>();
-
+Result IFile::Write(
+ const InBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> buffer,
+ FileSys::WriteOption option, s64 offset, s64 size) {
LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option.value, offset,
- length);
-
- const auto data = ctx.ReadBuffer();
+ size);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(backend->Write(offset, data.data(), length, option));
+ R_RETURN(backend->Write(offset, buffer.data(), size, option));
}
-void IFile::Flush(HLERequestContext& ctx) {
+Result IFile::Flush() {
LOG_DEBUG(Service_FS, "called");
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(backend->Flush());
+ R_RETURN(backend->Flush());
}
-void IFile::SetSize(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const u64 size = rp.Pop<u64>();
+Result IFile::SetSize(s64 size) {
LOG_DEBUG(Service_FS, "called, size={}", size);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(backend->SetSize(size));
+ R_RETURN(backend->SetSize(size));
}
-void IFile::GetSize(HLERequestContext& ctx) {
- s64 size;
- const auto result = backend->GetSize(&size);
- LOG_DEBUG(Service_FS, "called, size={}", size);
+Result IFile::GetSize(Out<s64> out_size) {
+ LOG_DEBUG(Service_FS, "called");
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(size);
+ R_RETURN(backend->GetSize(out_size));
}
} // namespace Service::FileSystem