mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu-mainline.git
				synced 2025-03-21 01:53:15 +00:00 
			
		
		
		
	Merge pull request #2339 from lioncash/rank
service/fsp_srv: Update SaveDataInfo and SaveDataDescriptor structs
This commit is contained in:
		
						commit
						d6cddffb78
					
				@ -16,8 +16,10 @@ namespace FileSys {
 | 
			
		||||
constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size";
 | 
			
		||||
 | 
			
		||||
std::string SaveDataDescriptor::DebugInfo() const {
 | 
			
		||||
    return fmt::format("[type={:02X}, title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}]",
 | 
			
		||||
                       static_cast<u8>(type), title_id, user_id[1], user_id[0], save_id);
 | 
			
		||||
    return fmt::format("[type={:02X}, title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}, "
 | 
			
		||||
                       "rank={}, index={}]",
 | 
			
		||||
                       static_cast<u8>(type), title_id, user_id[1], user_id[0], save_id,
 | 
			
		||||
                       static_cast<u8>(rank), index);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SaveDataFactory::SaveDataFactory(VirtualDir save_directory) : dir(std::move(save_directory)) {
 | 
			
		||||
@ -28,7 +30,7 @@ SaveDataFactory::SaveDataFactory(VirtualDir save_directory) : dir(std::move(save
 | 
			
		||||
 | 
			
		||||
SaveDataFactory::~SaveDataFactory() = default;
 | 
			
		||||
 | 
			
		||||
ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescriptor meta) {
 | 
			
		||||
ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, const SaveDataDescriptor& meta) {
 | 
			
		||||
    if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) {
 | 
			
		||||
        if (meta.zero_1 != 0) {
 | 
			
		||||
            LOG_WARNING(Service_FS,
 | 
			
		||||
 | 
			
		||||
@ -32,12 +32,19 @@ enum class SaveDataType : u8 {
 | 
			
		||||
    CacheStorage = 5,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum class SaveDataRank : u8 {
 | 
			
		||||
    Primary,
 | 
			
		||||
    Secondary,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct SaveDataDescriptor {
 | 
			
		||||
    u64_le title_id;
 | 
			
		||||
    u128 user_id;
 | 
			
		||||
    u64_le save_id;
 | 
			
		||||
    SaveDataType type;
 | 
			
		||||
    INSERT_PADDING_BYTES(7);
 | 
			
		||||
    SaveDataRank rank;
 | 
			
		||||
    u16_le index;
 | 
			
		||||
    INSERT_PADDING_BYTES(4);
 | 
			
		||||
    u64_le zero_1;
 | 
			
		||||
    u64_le zero_2;
 | 
			
		||||
    u64_le zero_3;
 | 
			
		||||
@ -57,7 +64,7 @@ public:
 | 
			
		||||
    explicit SaveDataFactory(VirtualDir dir);
 | 
			
		||||
    ~SaveDataFactory();
 | 
			
		||||
 | 
			
		||||
    ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta);
 | 
			
		||||
    ResultVal<VirtualDir> Open(SaveDataSpaceId space, const SaveDataDescriptor& meta);
 | 
			
		||||
 | 
			
		||||
    VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space) const;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -322,15 +322,15 @@ ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId stora
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space,
 | 
			
		||||
                                            FileSys::SaveDataDescriptor save_struct) {
 | 
			
		||||
                                            const FileSys::SaveDataDescriptor& descriptor) {
 | 
			
		||||
    LOG_TRACE(Service_FS, "Opening Save Data for space_id={:01X}, save_struct={}",
 | 
			
		||||
              static_cast<u8>(space), save_struct.DebugInfo());
 | 
			
		||||
              static_cast<u8>(space), descriptor.DebugInfo());
 | 
			
		||||
 | 
			
		||||
    if (save_data_factory == nullptr) {
 | 
			
		||||
        return FileSys::ERROR_ENTITY_NOT_FOUND;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return save_data_factory->Open(space, save_struct);
 | 
			
		||||
    return save_data_factory->Open(space, descriptor);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ResultVal<FileSys::VirtualDir> OpenSaveDataSpace(FileSys::SaveDataSpaceId space) {
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess();
 | 
			
		||||
ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
 | 
			
		||||
                                          FileSys::ContentRecordType type);
 | 
			
		||||
ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space,
 | 
			
		||||
                                            FileSys::SaveDataDescriptor save_struct);
 | 
			
		||||
                                            const FileSys::SaveDataDescriptor& descriptor);
 | 
			
		||||
ResultVal<FileSys::VirtualDir> OpenSaveDataSpace(FileSys::SaveDataSpaceId space);
 | 
			
		||||
ResultVal<FileSys::VirtualDir> OpenSDMC();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -604,7 +604,9 @@ private:
 | 
			
		||||
        u64_le save_id;
 | 
			
		||||
        u64_le title_id;
 | 
			
		||||
        u64_le save_image_size;
 | 
			
		||||
        INSERT_PADDING_BYTES(0x28);
 | 
			
		||||
        u16_le index;
 | 
			
		||||
        FileSys::SaveDataRank rank;
 | 
			
		||||
        INSERT_PADDING_BYTES(0x25);
 | 
			
		||||
    };
 | 
			
		||||
    static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size.");
 | 
			
		||||
 | 
			
		||||
@ -767,16 +769,17 @@ void FSP_SRV::CreateSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
 | 
			
		||||
    LOG_INFO(Service_FS, "called.");
 | 
			
		||||
 | 
			
		||||
    struct Parameters {
 | 
			
		||||
        FileSys::SaveDataSpaceId save_data_space_id;
 | 
			
		||||
        FileSys::SaveDataDescriptor descriptor;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    IPC::RequestParser rp{ctx};
 | 
			
		||||
    const auto parameters = rp.PopRaw<Parameters>();
 | 
			
		||||
 | 
			
		||||
    auto space_id = rp.PopRaw<FileSys::SaveDataSpaceId>();
 | 
			
		||||
    auto unk = rp.Pop<u32>();
 | 
			
		||||
    LOG_INFO(Service_FS, "called with unknown={:08X}", unk);
 | 
			
		||||
 | 
			
		||||
    auto save_struct = rp.PopRaw<FileSys::SaveDataDescriptor>();
 | 
			
		||||
 | 
			
		||||
    auto dir = OpenSaveData(space_id, save_struct);
 | 
			
		||||
 | 
			
		||||
    auto dir = OpenSaveData(parameters.save_data_space_id, parameters.descriptor);
 | 
			
		||||
    if (dir.Failed()) {
 | 
			
		||||
        IPC::ResponseBuilder rb{ctx, 2, 0, 0};
 | 
			
		||||
        rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user