diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/archive_extsavedata.cpp | 21 | ||||
| -rw-r--r-- | src/core/file_sys/archive_extsavedata.h | 10 | ||||
| -rw-r--r-- | src/core/file_sys/archive_systemsavedata.cpp | 22 | ||||
| -rw-r--r-- | src/core/file_sys/archive_systemsavedata.h | 25 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 74 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 34 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 105 |
7 files changed, 265 insertions, 26 deletions
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index 0363c9771..3076fa263 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp | |||
| @@ -34,6 +34,27 @@ std::string GetExtDataContainerPath(const std::string& mount_point, bool shared) | |||
| 34 | SYSTEM_ID.c_str(), SDCARD_ID.c_str()); | 34 | SYSTEM_ID.c_str(), SDCARD_ID.c_str()); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low) { | ||
| 38 | std::vector<u8> binary_path; | ||
| 39 | binary_path.reserve(12); | ||
| 40 | |||
| 41 | // Append each word byte by byte | ||
| 42 | |||
| 43 | // The first word is the media type | ||
| 44 | for (unsigned i = 0; i < 4; ++i) | ||
| 45 | binary_path.push_back((media_type >> (8 * i)) & 0xFF); | ||
| 46 | |||
| 47 | // Next is the low word | ||
| 48 | for (unsigned i = 0; i < 4; ++i) | ||
| 49 | binary_path.push_back((low >> (8 * i)) & 0xFF); | ||
| 50 | |||
| 51 | // Next is the high word | ||
| 52 | for (unsigned i = 0; i < 4; ++i) | ||
| 53 | binary_path.push_back((high >> (8 * i)) & 0xFF); | ||
| 54 | |||
| 55 | return { binary_path }; | ||
| 56 | } | ||
| 57 | |||
| 37 | ArchiveFactory_ExtSaveData::ArchiveFactory_ExtSaveData(const std::string& mount_location, bool shared) | 58 | ArchiveFactory_ExtSaveData::ArchiveFactory_ExtSaveData(const std::string& mount_location, bool shared) |
| 38 | : mount_point(GetExtDataContainerPath(mount_location, shared)) { | 59 | : mount_point(GetExtDataContainerPath(mount_location, shared)) { |
| 39 | LOG_INFO(Service_FS, "Directory %s set as base for ExtSaveData.", mount_point.c_str()); | 60 | LOG_INFO(Service_FS, "Directory %s set as base for ExtSaveData.", mount_point.c_str()); |
diff --git a/src/core/file_sys/archive_extsavedata.h b/src/core/file_sys/archive_extsavedata.h index 83c6b0291..c77c04e44 100644 --- a/src/core/file_sys/archive_extsavedata.h +++ b/src/core/file_sys/archive_extsavedata.h | |||
| @@ -58,4 +58,14 @@ std::string GetExtSaveDataPath(const std::string& mount_point, const Path& path) | |||
| 58 | */ | 58 | */ |
| 59 | std::string GetExtDataContainerPath(const std::string& mount_point, bool shared); | 59 | std::string GetExtDataContainerPath(const std::string& mount_point, bool shared); |
| 60 | 60 | ||
| 61 | /** | ||
| 62 | * Constructs a FileSys::Path object that refers to the ExtData archive identified by | ||
| 63 | * the specified media type, high save id and low save id. | ||
| 64 | * @param media_type The media type where the archive is located (NAND / SDMC) | ||
| 65 | * @param high The high word of the save id for the archive | ||
| 66 | * @param low The low word of the save id for the archive | ||
| 67 | * @returns A FileSys::Path to the wanted archive | ||
| 68 | */ | ||
| 69 | Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low); | ||
| 70 | |||
| 61 | } // namespace FileSys | 71 | } // namespace FileSys |
diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp index 25c94cd26..4fe785c97 100644 --- a/src/core/file_sys/archive_systemsavedata.cpp +++ b/src/core/file_sys/archive_systemsavedata.cpp | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | namespace FileSys { | 18 | namespace FileSys { |
| 19 | 19 | ||
| 20 | static std::string GetSystemSaveDataPath(const std::string& mount_point, const Path& path) { | 20 | std::string GetSystemSaveDataPath(const std::string& mount_point, const Path& path) { |
| 21 | std::vector<u8> vec_data = path.AsBinary(); | 21 | std::vector<u8> vec_data = path.AsBinary(); |
| 22 | const u32* data = reinterpret_cast<const u32*>(vec_data.data()); | 22 | const u32* data = reinterpret_cast<const u32*>(vec_data.data()); |
| 23 | u32 save_low = data[1]; | 23 | u32 save_low = data[1]; |
| @@ -25,10 +25,27 @@ static std::string GetSystemSaveDataPath(const std::string& mount_point, const P | |||
| 25 | return Common::StringFromFormat("%s%08X/%08X/", mount_point.c_str(), save_low, save_high); | 25 | return Common::StringFromFormat("%s%08X/%08X/", mount_point.c_str(), save_low, save_high); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | static std::string GetSystemSaveDataContainerPath(const std::string& mount_point) { | 28 | std::string GetSystemSaveDataContainerPath(const std::string& mount_point) { |
| 29 | return Common::StringFromFormat("%sdata/%s/sysdata/", mount_point.c_str(), SYSTEM_ID.c_str()); | 29 | return Common::StringFromFormat("%sdata/%s/sysdata/", mount_point.c_str(), SYSTEM_ID.c_str()); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low) { | ||
| 33 | std::vector<u8> binary_path; | ||
| 34 | binary_path.reserve(8); | ||
| 35 | |||
| 36 | // Append each word byte by byte | ||
| 37 | |||
| 38 | // First is the high word | ||
| 39 | for (unsigned i = 0; i < 4; ++i) | ||
| 40 | binary_path.push_back((high >> (8 * i)) & 0xFF); | ||
| 41 | |||
| 42 | // Next is the low word | ||
| 43 | for (unsigned i = 0; i < 4; ++i) | ||
| 44 | binary_path.push_back((low >> (8 * i)) & 0xFF); | ||
| 45 | |||
| 46 | return { binary_path }; | ||
| 47 | } | ||
| 48 | |||
| 32 | ArchiveFactory_SystemSaveData::ArchiveFactory_SystemSaveData(const std::string& nand_path) | 49 | ArchiveFactory_SystemSaveData::ArchiveFactory_SystemSaveData(const std::string& nand_path) |
| 33 | : base_path(GetSystemSaveDataContainerPath(nand_path)) { | 50 | : base_path(GetSystemSaveDataContainerPath(nand_path)) { |
| 34 | } | 51 | } |
| @@ -46,6 +63,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c | |||
| 46 | 63 | ||
| 47 | ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path) { | 64 | ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path) { |
| 48 | std::string fullpath = GetSystemSaveDataPath(base_path, path); | 65 | std::string fullpath = GetSystemSaveDataPath(base_path, path); |
| 66 | FileUtil::DeleteDirRecursively(fullpath); | ||
| 49 | FileUtil::CreateFullPath(fullpath); | 67 | FileUtil::CreateFullPath(fullpath); |
| 50 | return RESULT_SUCCESS; | 68 | return RESULT_SUCCESS; |
| 51 | } | 69 | } |
diff --git a/src/core/file_sys/archive_systemsavedata.h b/src/core/file_sys/archive_systemsavedata.h index 556a2a488..3431fed88 100644 --- a/src/core/file_sys/archive_systemsavedata.h +++ b/src/core/file_sys/archive_systemsavedata.h | |||
| @@ -28,4 +28,29 @@ private: | |||
| 28 | std::string base_path; | 28 | std::string base_path; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | /** | ||
| 32 | * Constructs a path to the concrete SystemSaveData archive in the host filesystem based on the | ||
| 33 | * input Path and base mount point. | ||
| 34 | * @param mount_point The base mount point of the SystemSaveData archives. | ||
| 35 | * @param path The path that identifies the requested concrete SystemSaveData archive. | ||
| 36 | * @returns The complete path to the specified SystemSaveData archive in the host filesystem | ||
| 37 | */ | ||
| 38 | std::string GetSystemSaveDataPath(const std::string& mount_point, const Path& path); | ||
| 39 | |||
| 40 | /** | ||
| 41 | * Constructs a path to the base folder to hold concrete SystemSaveData archives in the host file system. | ||
| 42 | * @param mount_point The base folder where this folder resides, ie. SDMC or NAND. | ||
| 43 | * @returns The path to the base SystemSaveData archives' folder in the host file system | ||
| 44 | */ | ||
| 45 | std::string GetSystemSaveDataContainerPath(const std::string& mount_point); | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Constructs a FileSys::Path object that refers to the SystemSaveData archive identified by | ||
| 49 | * the specified high save id and low save id. | ||
| 50 | * @param high The high word of the save id for the archive | ||
| 51 | * @param low The low word of the save id for the archive | ||
| 52 | * @returns A FileSys::Path to the wanted archive | ||
| 53 | */ | ||
| 54 | Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low); | ||
| 55 | |||
| 31 | } // namespace FileSys | 56 | } // namespace FileSys |
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 9da2e7aa2..b0fd834c7 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -395,28 +395,72 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) { | |||
| 395 | return archive_itr->second->Format(path); | 395 | return archive_itr->second->Format(path); |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | ResultCode CreateExtSaveData(u32 high, u32 low) { | 398 | ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low) { |
| 399 | // Construct the binary path to the archive first | 399 | // Construct the binary path to the archive first |
| 400 | std::vector<u8> binary_path; | 400 | FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low); |
| 401 | binary_path.reserve(12); | 401 | |
| 402 | // The first word is all zero to specify a NAND archive | 402 | std::string media_type_directory; |
| 403 | for (unsigned i = 0; i < 4; ++i) | 403 | if (media_type == MediaType::NAND) { |
| 404 | binary_path.push_back(0); | 404 | media_type_directory = FileUtil::GetUserPath(D_NAND_IDX); |
| 405 | // Next is the low word | 405 | } else if (media_type == MediaType::SDMC) { |
| 406 | for (unsigned i = 0; i < 4; ++i) | 406 | media_type_directory = FileUtil::GetUserPath(D_SDMC_IDX); |
| 407 | binary_path.push_back((low >> (8 * i)) & 0xFF); | 407 | } else { |
| 408 | // Next is the high word | 408 | LOG_ERROR(Service_FS, "Unsupported media type %u", media_type); |
| 409 | for (unsigned i = 0; i < 4; ++i) | 409 | return ResultCode(-1); // TODO(Subv): Find the right error code |
| 410 | binary_path.push_back((high >> i) & 0xFF); | 410 | } |
| 411 | FileSys::Path path(binary_path); | 411 | |
| 412 | std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); | 412 | std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); |
| 413 | std::string base_path = FileSys::GetExtDataContainerPath(nand_directory, true); | ||
| 414 | std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); | 413 | std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); |
| 415 | if (!FileUtil::CreateFullPath(extsavedata_path)) | 414 | if (!FileUtil::CreateFullPath(extsavedata_path)) |
| 416 | return ResultCode(-1); // TODO(Subv): Find the right error code | 415 | return ResultCode(-1); // TODO(Subv): Find the right error code |
| 417 | return RESULT_SUCCESS; | 416 | return RESULT_SUCCESS; |
| 418 | } | 417 | } |
| 419 | 418 | ||
| 419 | ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) { | ||
| 420 | // Construct the binary path to the archive first | ||
| 421 | FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low); | ||
| 422 | |||
| 423 | std::string media_type_directory; | ||
| 424 | if (media_type == MediaType::NAND) { | ||
| 425 | media_type_directory = FileUtil::GetUserPath(D_NAND_IDX); | ||
| 426 | } else if (media_type == MediaType::SDMC) { | ||
| 427 | media_type_directory = FileUtil::GetUserPath(D_SDMC_IDX); | ||
| 428 | } else { | ||
| 429 | LOG_ERROR(Service_FS, "Unsupported media type %u", media_type); | ||
| 430 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 431 | } | ||
| 432 | |||
| 433 | std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); | ||
| 434 | std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); | ||
| 435 | if (!FileUtil::DeleteDirRecursively(extsavedata_path)) | ||
| 436 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 437 | return RESULT_SUCCESS; | ||
| 438 | } | ||
| 439 | |||
| 440 | ResultCode DeleteSystemSaveData(u32 high, u32 low) { | ||
| 441 | // Construct the binary path to the archive first | ||
| 442 | FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); | ||
| 443 | |||
| 444 | std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); | ||
| 445 | std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); | ||
| 446 | std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); | ||
| 447 | if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) | ||
| 448 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 449 | return RESULT_SUCCESS; | ||
| 450 | } | ||
| 451 | |||
| 452 | ResultCode CreateSystemSaveData(u32 high, u32 low) { | ||
| 453 | // Construct the binary path to the archive first | ||
| 454 | FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); | ||
| 455 | |||
| 456 | std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); | ||
| 457 | std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); | ||
| 458 | std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); | ||
| 459 | if (!FileUtil::CreateFullPath(systemsavedata_path)) | ||
| 460 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 461 | return RESULT_SUCCESS; | ||
| 462 | } | ||
| 463 | |||
| 420 | /// Initialize archives | 464 | /// Initialize archives |
| 421 | void ArchiveInit() { | 465 | void ArchiveInit() { |
| 422 | next_handle = 1; | 466 | next_handle = 1; |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index c490327d0..b00f0fd60 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -35,6 +35,12 @@ enum class ArchiveIdCode : u32 { | |||
| 35 | SaveDataCheck = 0x2345678A, | 35 | SaveDataCheck = 0x2345678A, |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | /// Media types for the archives | ||
| 39 | enum class MediaType : u32 { | ||
| 40 | NAND = 0, | ||
| 41 | SDMC = 1 | ||
| 42 | }; | ||
| 43 | |||
| 38 | typedef u64 ArchiveHandle; | 44 | typedef u64 ArchiveHandle; |
| 39 | 45 | ||
| 40 | class File : public Kernel::Session { | 46 | class File : public Kernel::Session { |
| @@ -172,11 +178,37 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path = File | |||
| 172 | 178 | ||
| 173 | /** | 179 | /** |
| 174 | * Creates a blank SharedExtSaveData archive for the specified extdata ID | 180 | * Creates a blank SharedExtSaveData archive for the specified extdata ID |
| 181 | * @param media_type The media type of the archive to create (NAND / SDMC) | ||
| 175 | * @param high The high word of the extdata id to create | 182 | * @param high The high word of the extdata id to create |
| 176 | * @param low The low word of the extdata id to create | 183 | * @param low The low word of the extdata id to create |
| 177 | * @return ResultCode 0 on success or the corresponding code on error | 184 | * @return ResultCode 0 on success or the corresponding code on error |
| 178 | */ | 185 | */ |
| 179 | ResultCode CreateExtSaveData(u32 high, u32 low); | 186 | ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low); |
| 187 | |||
| 188 | /** | ||
| 189 | * Deletes the SharedExtSaveData archive for the specified extdata ID | ||
| 190 | * @param media_type The media type of the archive to delete (NAND / SDMC) | ||
| 191 | * @param high The high word of the extdata id to delete | ||
| 192 | * @param low The low word of the extdata id to delete | ||
| 193 | * @return ResultCode 0 on success or the corresponding code on error | ||
| 194 | */ | ||
| 195 | ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low); | ||
| 196 | |||
| 197 | /** | ||
| 198 | * Deletes the SystemSaveData archive folder for the specified save data id | ||
| 199 | * @param high The high word of the SystemSaveData archive to delete | ||
| 200 | * @param low The low word of the SystemSaveData archive to delete | ||
| 201 | * @return ResultCode 0 on success or the corresponding code on error | ||
| 202 | */ | ||
| 203 | ResultCode DeleteSystemSaveData(u32 high, u32 low); | ||
| 204 | |||
| 205 | /** | ||
| 206 | * Creates the SystemSaveData archive folder for the specified save data id | ||
| 207 | * @param high The high word of the SystemSaveData archive to create | ||
| 208 | * @param low The low word of the SystemSaveData archive to create | ||
| 209 | * @return ResultCode 0 on success or the corresponding code on error | ||
| 210 | */ | ||
| 211 | ResultCode CreateSystemSaveData(u32 high, u32 low); | ||
| 180 | 212 | ||
| 181 | /// Initialize archives | 213 | /// Initialize archives |
| 182 | void ArchiveInit(); | 214 | void ArchiveInit(); |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index eb312496e..d8d1d5547 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -490,25 +490,65 @@ static void FormatThisUserSaveData(Service::Interface* self) { | |||
| 490 | /** | 490 | /** |
| 491 | * FS_User::CreateExtSaveData service function | 491 | * FS_User::CreateExtSaveData service function |
| 492 | * Inputs: | 492 | * Inputs: |
| 493 | * 0: 0x08510242 | 493 | * 0 : 0x08510242 |
| 494 | * 1: High word of the saveid to create | 494 | * 1 : Media type (NAND / SDMC) |
| 495 | * 2: Low word of the saveid to create | 495 | * 2 : Low word of the saveid to create |
| 496 | * 3 : High word of the saveid to create | ||
| 497 | * 4 : Unknown | ||
| 498 | * 5 : Unknown | ||
| 499 | * 6 : Unknown | ||
| 500 | * 7 : Unknown | ||
| 501 | * 8 : Unknown | ||
| 502 | * 9 : Unknown | ||
| 503 | * 10: Unknown | ||
| 504 | * 11: Unknown | ||
| 496 | * Outputs: | 505 | * Outputs: |
| 497 | * 1 : Result of function, 0 on success, otherwise error code | 506 | * 1 : Result of function, 0 on success, otherwise error code |
| 498 | */ | 507 | */ |
| 499 | static void CreateExtSaveData(Service::Interface* self) { | 508 | static void CreateExtSaveData(Service::Interface* self) { |
| 500 | // TODO(Subv): Figure out the other parameters. | 509 | // TODO(Subv): Figure out the other parameters. |
| 501 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 510 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 502 | u32 save_high = cmd_buff[1]; | 511 | MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF); |
| 503 | u32 save_low = cmd_buff[2]; | 512 | u32 save_low = cmd_buff[2]; |
| 504 | // TODO(Subv): For now it is assumed that only SharedExtSaveData can be created like this | 513 | u32 save_high = cmd_buff[3]; |
| 505 | cmd_buff[1] = CreateExtSaveData(save_high, save_low).raw; | 514 | |
| 515 | LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X " | ||
| 516 | "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X " | ||
| 517 | "cmd_buff[9]=%08X cmd_buff[10]=%08X cmd_buff[11]=%08X", save_high, save_low, | ||
| 518 | cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9], | ||
| 519 | cmd_buff[10], cmd_buff[11]); | ||
| 520 | |||
| 521 | cmd_buff[1] = CreateExtSaveData(media_type, save_high, save_low).raw; | ||
| 522 | } | ||
| 523 | |||
| 524 | /** | ||
| 525 | * FS_User::DeleteExtSaveData service function | ||
| 526 | * Inputs: | ||
| 527 | * 0 : 0x08520100 | ||
| 528 | * 1 : Media type (NAND / SDMC) | ||
| 529 | * 2 : Low word of the saveid to create | ||
| 530 | * 3 : High word of the saveid to create | ||
| 531 | * 4 : Unknown | ||
| 532 | * Outputs: | ||
| 533 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 534 | */ | ||
| 535 | static void DeleteExtSaveData(Service::Interface* self) { | ||
| 536 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 537 | MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF); | ||
| 538 | u32 save_low = cmd_buff[2]; | ||
| 539 | u32 save_high = cmd_buff[3]; | ||
| 540 | u32 unknown = cmd_buff[4]; // TODO(Subv): Figure out what this is | ||
| 541 | |||
| 542 | LOG_WARNING(Service_FS, "(STUBBED) save_low=%08X save_high=%08X media_type=%08X unknown=%08X", | ||
| 543 | save_low, save_high, cmd_buff[1] & 0xFF, unknown); | ||
| 544 | |||
| 545 | cmd_buff[1] = DeleteExtSaveData(media_type, save_high, save_low).raw; | ||
| 506 | } | 546 | } |
| 507 | 547 | ||
| 508 | /** | 548 | /** |
| 509 | * FS_User::CardSlotIsInserted service function. | 549 | * FS_User::CardSlotIsInserted service function. |
| 510 | * Inputs: | 550 | * Inputs: |
| 511 | * 0: 0x08210000 | 551 | * 0 : 0x08210000 |
| 512 | * Outputs: | 552 | * Outputs: |
| 513 | * 1 : Result of function, 0 on success, otherwise error code | 553 | * 1 : Result of function, 0 on success, otherwise error code |
| 514 | * 2 : Whether there is a game card inserted into the slot or not. | 554 | * 2 : Whether there is a game card inserted into the slot or not. |
| @@ -520,6 +560,53 @@ static void CardSlotIsInserted(Service::Interface* self) { | |||
| 520 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 560 | LOG_WARNING(Service_FS, "(STUBBED) called"); |
| 521 | } | 561 | } |
| 522 | 562 | ||
| 563 | /** | ||
| 564 | * FS_User::DeleteSystemSaveData service function. | ||
| 565 | * Inputs: | ||
| 566 | * 0 : 0x08570080 | ||
| 567 | * 1 : High word of the SystemSaveData id to delete | ||
| 568 | * 2 : Low word of the SystemSaveData id to delete | ||
| 569 | * Outputs: | ||
| 570 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 571 | */ | ||
| 572 | static void DeleteSystemSaveData(Service::Interface* self) { | ||
| 573 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 574 | u32 savedata_high = cmd_buff[1]; | ||
| 575 | u32 savedata_low = cmd_buff[2]; | ||
| 576 | |||
| 577 | cmd_buff[1] = DeleteSystemSaveData(savedata_high, savedata_low).raw; | ||
| 578 | } | ||
| 579 | |||
| 580 | /** | ||
| 581 | * FS_User::CreateSystemSaveData service function. | ||
| 582 | * Inputs: | ||
| 583 | * 0 : 0x08560240 | ||
| 584 | * 1 : High word of the SystemSaveData id to create | ||
| 585 | * 2 : Low word of the SystemSaveData id to create | ||
| 586 | * 3 : Unknown | ||
| 587 | * 4 : Unknown | ||
| 588 | * 5 : Unknown | ||
| 589 | * 6 : Unknown | ||
| 590 | * 7 : Unknown | ||
| 591 | * 8 : Unknown | ||
| 592 | * 9 : Unknown (Memory address) | ||
| 593 | * Outputs: | ||
| 594 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 595 | */ | ||
| 596 | static void CreateSystemSaveData(Service::Interface* self) { | ||
| 597 | // TODO(Subv): Figure out the other parameters. | ||
| 598 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 599 | u32 savedata_high = cmd_buff[1]; | ||
| 600 | u32 savedata_low = cmd_buff[2]; | ||
| 601 | |||
| 602 | LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X " | ||
| 603 | "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X " | ||
| 604 | "cmd_buff[9]=%08X", savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], | ||
| 605 | cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9]); | ||
| 606 | |||
| 607 | cmd_buff[1] = CreateSystemSaveData(savedata_high, savedata_low).raw; | ||
| 608 | } | ||
| 609 | |||
| 523 | const Interface::FunctionInfo FunctionTable[] = { | 610 | const Interface::FunctionInfo FunctionTable[] = { |
| 524 | {0x000100C6, nullptr, "Dummy1"}, | 611 | {0x000100C6, nullptr, "Dummy1"}, |
| 525 | {0x040100C4, nullptr, "Control"}, | 612 | {0x040100C4, nullptr, "Control"}, |
| @@ -604,7 +691,9 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 604 | {0x084F0102, nullptr, "ReadSpecialFile"}, | 691 | {0x084F0102, nullptr, "ReadSpecialFile"}, |
| 605 | {0x08500040, nullptr, "GetSpecialFileSize"}, | 692 | {0x08500040, nullptr, "GetSpecialFileSize"}, |
| 606 | {0x08510242, CreateExtSaveData, "CreateExtSaveData"}, | 693 | {0x08510242, CreateExtSaveData, "CreateExtSaveData"}, |
| 607 | {0x08520100, nullptr, "DeleteExtSaveData"}, | 694 | {0x08520100, DeleteExtSaveData, "DeleteExtSaveData"}, |
| 695 | {0x08560240, CreateSystemSaveData, "CreateSystemSaveData"}, | ||
| 696 | {0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"}, | ||
| 608 | {0x08580000, nullptr, "GetMovableSedHashedKeyYRandomData"}, | 697 | {0x08580000, nullptr, "GetMovableSedHashedKeyYRandomData"}, |
| 609 | {0x08610042, nullptr, "InitializeWithSdkVersion"}, | 698 | {0x08610042, nullptr, "InitializeWithSdkVersion"}, |
| 610 | {0x08620040, nullptr, "SetPriority"}, | 699 | {0x08620040, nullptr, "SetPriority"}, |