From a9e922e68f4fc2a24c449c18a11f61e388d8e55e Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Tue, 17 Jul 2018 22:59:42 +0800 Subject: [PATCH] service/fs: implement obsoleted Create/DeleteExtSaveData (#3948) * service/fs: implement obsoleted Create/DeleteExtSaveData * service/fs: remove the STUBBED warning --- src/core/hle/service/fs/fs_user.cpp | 63 ++++++++++++++++++++++++----- src/core/hle/service/fs/fs_user.h | 28 +++++++++++++ 2 files changed, 80 insertions(+), 11 deletions(-) diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 674db8e3b..62a4bb793 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -436,11 +436,6 @@ void FS_USER::CreateExtSaveData(Kernel::HLERequestContext& ctx) { u32 icon_size = rp.Pop(); auto icon_buffer = rp.PopMappedBuffer(); - LOG_WARNING(Service_FS, - "(STUBBED) savedata_high={:08X} savedata_low={:08X} unknown={:08X} " - "files={:08X} directories={:08X} size_limit={:016x} icon_size={:08X}", - save_high, save_low, unknown, directories, files, size_limit, icon_size); - std::vector icon(icon_size); icon_buffer.Read(icon.data(), 0, icon_size); @@ -453,6 +448,11 @@ void FS_USER::CreateExtSaveData(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(Service::FS::CreateExtSaveData(media_type, save_high, save_low, icon, format_info)); rb.PushMappedBuffer(icon_buffer); + + LOG_DEBUG(Service_FS, + "called, savedata_high={:08X} savedata_low={:08X} unknown={:08X} " + "files={:08X} directories={:08X} size_limit={:016x} icon_size={:08X}", + save_high, save_low, unknown, directories, files, size_limit, icon_size); } void FS_USER::DeleteExtSaveData(Kernel::HLERequestContext& ctx) { @@ -462,12 +462,12 @@ void FS_USER::DeleteExtSaveData(Kernel::HLERequestContext& ctx) { u32 save_high = rp.Pop(); u32 unknown = rp.Pop(); // TODO(Subv): Figure out what this is - LOG_WARNING(Service_FS, - "(STUBBED) save_low={:08X} save_high={:08X} media_type={:08X} unknown={:08X}", - save_low, save_high, static_cast(media_type), unknown); - IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(Service::FS::DeleteExtSaveData(media_type, save_high, save_low)); + + LOG_DEBUG(Service_FS, + "called, save_low={:08X} save_high={:08X} media_type={:08X} unknown={:08X}", save_low, + save_high, static_cast(media_type), unknown); } void FS_USER::CardSlotIsInserted(Kernel::HLERequestContext& ctx) { @@ -644,6 +644,47 @@ void FS_USER::GetProgramLaunchInfo(Kernel::HLERequestContext& ctx) { rb.Push(0); } +void FS_USER::ObsoletedCreateExtSaveData(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x830, 6, 2); + MediaType media_type = static_cast(rp.Pop()); + u32 save_low = rp.Pop(); + u32 save_high = rp.Pop(); + u32 icon_size = rp.Pop(); + u32 directories = rp.Pop(); + u32 files = rp.Pop(); + auto icon_buffer = rp.PopMappedBuffer(); + + std::vector icon(icon_size); + icon_buffer.Read(icon.data(), 0, icon_size); + + FileSys::ArchiveFormatInfo format_info; + format_info.number_directories = directories; + format_info.number_files = files; + format_info.duplicate_data = false; + format_info.total_size = 0; + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); + rb.Push(Service::FS::CreateExtSaveData(media_type, save_high, save_low, icon, format_info)); + rb.PushMappedBuffer(icon_buffer); + + LOG_DEBUG(Service_FS, + "called, savedata_high={:08X} savedata_low={:08X} " + "icon_size={:08X} files={:08X} directories={:08X}", + save_high, save_low, icon_size, directories, files); +} + +void FS_USER::ObsoletedDeleteExtSaveData(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x835, 2, 0); + MediaType media_type = static_cast(rp.Pop()); + u32 save_low = rp.Pop(); + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(Service::FS::DeleteExtSaveData(media_type, 0, save_low)); + + LOG_DEBUG(Service_FS, "called, save_low={:08X} media_type={:08X}", save_low, + static_cast(media_type)); +} + void FS_USER::GetNumSeeds(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x87D, 0, 0); @@ -747,12 +788,12 @@ FS_USER::FS_USER() : ServiceFramework("fs:USER", 30) { {0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"}, {0x082E0040, nullptr, "GetProductInfo"}, {0x082F0040, &FS_USER::GetProgramLaunchInfo, "GetProgramLaunchInfo"}, - {0x08300182, nullptr, "CreateExtSaveData"}, + {0x08300182, &FS_USER::ObsoletedCreateExtSaveData, "Obsoleted_3_0_CreateExtSaveData"}, {0x08310180, nullptr, "CreateSharedExtSaveData"}, {0x08320102, nullptr, "ReadExtSaveDataIcon"}, {0x08330082, nullptr, "EnumerateExtSaveData"}, {0x08340082, nullptr, "EnumerateSharedExtSaveData"}, - {0x08350080, nullptr, "DeleteExtSaveData"}, + {0x08350080, &FS_USER::ObsoletedDeleteExtSaveData, "Obsoleted_3_0_DeleteExtSaveData"}, {0x08360080, nullptr, "DeleteSharedExtSaveData"}, {0x08370040, nullptr, "SetCardSpiBaudRate"}, {0x08380040, nullptr, "SetCardSpiBusMode"}, diff --git a/src/core/hle/service/fs/fs_user.h b/src/core/hle/service/fs/fs_user.h index efe8137b4..275cd9f8e 100644 --- a/src/core/hle/service/fs/fs_user.h +++ b/src/core/hle/service/fs/fs_user.h @@ -447,6 +447,34 @@ private: */ void GetProgramLaunchInfo(Kernel::HLERequestContext& ctx); + /** + * FS_User::Obsoleted_3_0_CreateExtSaveData service function. + * Inputs: + * 0 : 0x08300182 + * 1 : Media type + * 2 : Low word of the saveid to create + * 3 : High word of the saveid to create + * 4 : Size of the SMDH icon + * 5 : Number of directories + * 6 : Number of files + * 7 : (SMDH Size << 4) | 0x0000000A + * 8 : Pointer to the SMDH icon for the new ExtSaveData + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void ObsoletedCreateExtSaveData(Kernel::HLERequestContext& ctx); + + /** + * FS_User::Obsoleted_3_0_DeleteExtSaveData service function. + * Inputs: + * 0 : 0x08350080 + * 1 : Media type + * 2 : Save ID Low (high is always 0x00000000) + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void ObsoletedDeleteExtSaveData(Kernel::HLERequestContext& ctx); + /** * FS_User::GetNumSeeds service function. * Inputs: