mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-23 09:11:22 -08:00
fsp: Migrate remaining interfaces to cmif serialization
This commit is contained in:
parent
fdf4a5bc90
commit
4c71bf3d90
@ -1,34 +1,32 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// 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/filesystem/fsp/fs_i_multi_commit_manager.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
|
||||||
|
|
||||||
namespace Service::FileSystem {
|
namespace Service::FileSystem {
|
||||||
|
|
||||||
IMultiCommitManager::IMultiCommitManager(Core::System& system_)
|
IMultiCommitManager::IMultiCommitManager(Core::System& system_)
|
||||||
: ServiceFramework{system_, "IMultiCommitManager"} {
|
: ServiceFramework{system_, "IMultiCommitManager"} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{1, &IMultiCommitManager::Add, "Add"},
|
{1, D<&IMultiCommitManager::Add>, "Add"},
|
||||||
{2, &IMultiCommitManager::Commit, "Commit"},
|
{2, D<&IMultiCommitManager::Commit>, "Commit"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMultiCommitManager::~IMultiCommitManager() = default;
|
IMultiCommitManager::~IMultiCommitManager() = default;
|
||||||
|
|
||||||
void IMultiCommitManager::Add(HLERequestContext& ctx) {
|
Result IMultiCommitManager::Add() {
|
||||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
LOG_WARNING(Service_FS, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMultiCommitManager::Commit(HLERequestContext& ctx) {
|
Result IMultiCommitManager::Commit() {
|
||||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
LOG_WARNING(Service_FS, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::FileSystem
|
} // namespace Service::FileSystem
|
||||||
|
@ -14,8 +14,8 @@ public:
|
|||||||
~IMultiCommitManager() override;
|
~IMultiCommitManager() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Add(HLERequestContext& ctx);
|
Result Add();
|
||||||
void Commit(HLERequestContext& ctx);
|
Result Commit();
|
||||||
|
|
||||||
FileSys::VirtualFile backend;
|
FileSys::VirtualFile backend;
|
||||||
};
|
};
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
|
|
||||||
#include "common/hex_util.h"
|
#include "common/hex_util.h"
|
||||||
#include "core/file_sys/savedata_factory.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/fsp/fs_i_save_data_info_reader.h"
|
||||||
#include "core/hle/service/filesystem/save_data_controller.h"
|
#include "core/hle/service/filesystem/save_data_controller.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
|
||||||
|
|
||||||
namespace Service::FileSystem {
|
namespace Service::FileSystem {
|
||||||
|
|
||||||
ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_,
|
ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_,
|
||||||
std::shared_ptr<SaveDataController> save_data_controller_,
|
std::shared_ptr<SaveDataController> save_data_controller_,
|
||||||
FileSys::SaveDataSpaceId space)
|
FileSys::SaveDataSpaceId space)
|
||||||
: ServiceFramework{system_, "ISaveDataInfoReader"},
|
: ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{
|
||||||
save_data_controller{save_data_controller_} {
|
save_data_controller_} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"},
|
{0, D<&ISaveDataInfoReader::ReadSaveDataInfo>, "ReadSaveDataInfo"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
@ -36,11 +36,12 @@ static u64 stoull_be(std::string_view str) {
|
|||||||
return Common::swap64(out);
|
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");
|
LOG_DEBUG(Service_FS, "called");
|
||||||
|
|
||||||
// Calculate how many entries we can fit in the output buffer
|
// 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.
|
// Cap at total number of entries.
|
||||||
const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index);
|
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;
|
next_entry_index += actual_entries;
|
||||||
|
|
||||||
// Write the data to memory
|
// 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};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u64>(actual_entries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISaveDataInfoReader::FindAllSaves(FileSys::SaveDataSpaceId space) {
|
void ISaveDataInfoReader::FindAllSaves(FileSys::SaveDataSpaceId space) {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/service/cmif_types.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Service::FileSystem {
|
namespace Service::FileSystem {
|
||||||
@ -18,13 +19,6 @@ public:
|
|||||||
FileSys::SaveDataSpaceId space);
|
FileSys::SaveDataSpaceId space);
|
||||||
~ISaveDataInfoReader() override;
|
~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 {
|
struct SaveDataInfo {
|
||||||
u64_le save_id_unknown;
|
u64_le save_id_unknown;
|
||||||
FileSys::SaveDataSpaceId space;
|
FileSys::SaveDataSpaceId space;
|
||||||
@ -40,6 +34,14 @@ private:
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size.");
|
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::shared_ptr<SaveDataController> save_data_controller;
|
||||||
std::vector<SaveDataInfo> info;
|
std::vector<SaveDataInfo> info;
|
||||||
u64 next_entry_index = 0;
|
u64 next_entry_index = 0;
|
||||||
|
@ -2,61 +2,44 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/file_sys/errors.h"
|
#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/filesystem/fsp/fs_i_storage.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
|
||||||
|
|
||||||
namespace Service::FileSystem {
|
namespace Service::FileSystem {
|
||||||
|
|
||||||
IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_)
|
IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_)
|
||||||
: ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) {
|
: ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IStorage::Read, "Read"},
|
{0, D<&IStorage::Read>, "Read"},
|
||||||
{1, nullptr, "Write"},
|
{1, nullptr, "Write"},
|
||||||
{2, nullptr, "Flush"},
|
{2, nullptr, "Flush"},
|
||||||
{3, nullptr, "SetSize"},
|
{3, nullptr, "SetSize"},
|
||||||
{4, &IStorage::GetSize, "GetSize"},
|
{4, D<&IStorage::GetSize>, "GetSize"},
|
||||||
{5, nullptr, "OperateRange"},
|
{5, nullptr, "OperateRange"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IStorage::Read(HLERequestContext& ctx) {
|
Result IStorage::Read(
|
||||||
IPC::RequestParser rp{ctx};
|
OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes,
|
||||||
const s64 offset = rp.Pop<s64>();
|
s64 offset, s64 length) {
|
||||||
const s64 length = rp.Pop<s64>();
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length);
|
LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length);
|
||||||
|
|
||||||
// Error checking
|
R_UNLESS(length >= 0, FileSys::ResultInvalidSize);
|
||||||
if (length < 0) {
|
R_UNLESS(offset >= 0, FileSys::ResultInvalidOffset);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the data from the Storage backend
|
// Read the data from the Storage backend
|
||||||
std::vector<u8> output = backend->ReadBytes(length, offset);
|
backend->Read(out_bytes.data(), length, offset);
|
||||||
// Write the data to memory
|
|
||||||
ctx.WriteBuffer(output);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IStorage::GetSize(HLERequestContext& ctx) {
|
Result IStorage::GetSize(Out<u64> out_size) {
|
||||||
const u64 size = backend->GetSize();
|
*out_size = backend->GetSize();
|
||||||
LOG_DEBUG(Service_FS, "called, size={}", size);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
LOG_DEBUG(Service_FS, "called, size={}", *out_size);
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u64>(size);
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::FileSystem
|
} // namespace Service::FileSystem
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/file_sys/vfs/vfs.h"
|
#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/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
@ -16,8 +17,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
FileSys::VirtualFile backend;
|
FileSys::VirtualFile backend;
|
||||||
|
|
||||||
void Read(HLERequestContext& ctx);
|
Result Read(
|
||||||
void GetSize(HLERequestContext& ctx);
|
OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes,
|
||||||
|
s64 offset, s64 length);
|
||||||
|
Result GetSize(Out<u64> out_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::FileSystem
|
} // namespace Service::FileSystem
|
||||||
|
Loading…
Reference in New Issue
Block a user