diff options
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/fs/archive.cpp | 21 | ||||
-rw-r--r-- | src/core/hle/service/fs/archive.h | 9 | ||||
-rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 64 | ||||
-rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 26 |
4 files changed, 110 insertions, 10 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index d92444160..e2a59a069 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -7,6 +7,7 @@ #include "common/common_types.h" #include "common/file_util.h" +#include "common/make_unique.h" #include "common/math_util.h" #include "core/file_sys/archive_savedata.h" @@ -260,7 +261,7 @@ ResultCode CloseArchive(ArchiveHandle handle) { // TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in // http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22 ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, ArchiveIdCode id_code) { - auto result = id_code_map.emplace(id_code, std::make_unique<Archive>(std::move(backend), id_code)); + auto result = id_code_map.emplace(id_code, Common::make_unique<Archive>(std::move(backend), id_code)); bool inserted = result.second; _dbg_assert_msg_(Service_FS, inserted, "Tried to register more than one archive with same id code"); @@ -281,7 +282,7 @@ ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy ErrorSummary::NotFound, ErrorLevel::Status); } - auto file = std::make_unique<File>(std::move(backend), path); + auto file = Common::make_unique<File>(std::move(backend), path); Handle handle = Kernel::g_object_pool.Create(file.release()); return MakeResult<Handle>(handle); } @@ -329,6 +330,14 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy ErrorSummary::Canceled, ErrorLevel::Status); } +ResultCode CreateFileInArchive(Handle archive_handle, const FileSys::Path& path, u32 file_size) { + Archive* archive = GetArchive(archive_handle); + if (archive == nullptr) + return InvalidHandle(ErrorModule::FS); + + return archive->backend->CreateFile(path, file_size); +} + ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) @@ -378,7 +387,7 @@ ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const F ErrorSummary::NotFound, ErrorLevel::Permanent); } - auto directory = std::make_unique<Directory>(std::move(backend), path); + auto directory = Common::make_unique<Directory>(std::move(backend), path); Handle handle = Kernel::g_object_pool.Create(directory.release()); return MakeResult<Handle>(handle); } @@ -392,7 +401,7 @@ ResultCode FormatSaveData() { // Create the SaveData archive std::string savedata_directory = FileUtil::GetUserPath(D_SAVEDATA_IDX); - auto savedata_archive = std::make_unique<FileSys::Archive_SaveData>(savedata_directory, + auto savedata_archive = Common::make_unique<FileSys::Archive_SaveData>(savedata_directory, Kernel::g_program_id); if (savedata_archive->Initialize()) { @@ -414,14 +423,14 @@ void ArchiveInit() { // archive type is SDMC, so it is the only one getting exposed. std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX); - auto sdmc_archive = std::make_unique<FileSys::Archive_SDMC>(sdmc_directory); + auto sdmc_archive = Common::make_unique<FileSys::Archive_SDMC>(sdmc_directory); if (sdmc_archive->Initialize()) CreateArchive(std::move(sdmc_archive), ArchiveIdCode::SDMC); else LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); std::string systemsavedata_directory = FileUtil::GetUserPath(D_SYSSAVEDATA_IDX); - auto systemsavedata_archive = std::make_unique<FileSys::Archive_SDMC>(systemsavedata_directory); + auto systemsavedata_archive = Common::make_unique<FileSys::Archive_SDMC>(systemsavedata_directory); if (systemsavedata_archive->Initialize()) { CreateArchive(std::move(systemsavedata_archive), ArchiveIdCode::SystemSaveData); } else { diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index df04bdb6b..b39bc41b6 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -83,6 +83,15 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); /** + * Create a File in an Archive + * @param archive_handle Handle to an open Archive object + * @param path Path to the File inside of the Archive + * @param file_size The size of the new file, filled with zeroes + * @return File creation result code + */ +ResultCode CreateFileInArchive(Handle archive_handle, const FileSys::Path& path, u32 file_size); + +/** * Create a Directory from an Archive * @param archive_handle Handle to an open Archive object * @param path Path to the Directory inside of the Archive diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 8d11e64b5..5e9b85cc7 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -226,6 +226,35 @@ static void DeleteDirectory(Service::Interface* self) { } /* + * FS_User::CreateFile service function + * Inputs: + * 0 : Command header 0x08080202 + * 2 : Archive handle lower word + * 3 : Archive handle upper word + * 4 : File path string type + * 5 : File path string size + * 7 : File size (filled with zeroes) + * 10: File path string data + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +static void CreateFile(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]); + auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); + u32 filename_size = cmd_buff[5]; + u32 file_size = cmd_buff[7]; + u32 filename_ptr = cmd_buff[10]; + + FileSys::Path file_path(filename_type, filename_size, filename_ptr); + + LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", filename_type, filename_size, file_path.DebugStr().c_str()); + + cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw; +} + +/* * FS_User::CreateDirectory service function * Inputs: * 2 : Archive handle lower word @@ -397,16 +426,44 @@ static void IsSdmcDetected(Service::Interface* self) { } /** - * FS_User::FormatSaveData service function + * FS_User::FormatSaveData service function, + * formats the SaveData specified by the input path. * Inputs: + * 0 : 0x084C0242 + * 1 : Archive ID + * 2 : Archive low path type + * 3 : Archive low path size + * 10 : (LowPathSize << 14) | 2 + * 11 : Archive low path * Outputs: * 1 : Result of function, 0 on success, otherwise error code */ static void FormatSaveData(Service::Interface* self) { + // TODO(Subv): Find out what the other inputs and outputs of this function are u32* cmd_buff = Kernel::GetCommandBuffer(); LOG_DEBUG(Service_FS, "(STUBBED)"); - // TODO(Subv): Find out what the inputs and outputs of this function are + auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]); + auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]); + u32 archivename_size = cmd_buff[3]; + u32 archivename_ptr = cmd_buff[11]; + FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr); + + LOG_DEBUG(Service_FS, "archive_path=%s", archive_path.DebugStr().c_str()); + + if (archive_id != FS::ArchiveIdCode::SaveData) { + // TODO(Subv): What should happen if somebody attempts to format a different archive? + LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u", cmd_buff[1]); + cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw; + return; + } + + if (archive_path.GetType() != FileSys::LowPathType::Empty) { + // TODO(Subv): Implement formatting the SaveData of other games + LOG_ERROR(Service_FS, "archive LowPath type other than empty is currently unsupported"); + cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw; + return; + } cmd_buff[1] = FormatSaveData().raw; } @@ -414,6 +471,7 @@ static void FormatSaveData(Service::Interface* self) { /** * FS_User::FormatThisUserSaveData service function * Inputs: + * 0: 0x080F0180 * Outputs: * 1 : Result of function, 0 on success, otherwise error code */ @@ -436,7 +494,7 @@ const FSUserInterface::FunctionInfo FunctionTable[] = { {0x08050244, RenameFile, "RenameFile"}, {0x08060142, DeleteDirectory, "DeleteDirectory"}, {0x08070142, nullptr, "DeleteDirectoryRecursively"}, - {0x08080202, nullptr, "CreateFile"}, + {0x08080202, CreateFile, "CreateFile"}, {0x08090182, CreateDirectory, "CreateDirectory"}, {0x080A0244, RenameDirectory, "RenameDirectory"}, {0x080B0102, OpenDirectory, "OpenDirectory"}, diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 10c157ba6..1f841078a 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -145,6 +145,30 @@ static void SetBufferSwap(Service::Interface* self) { } /** + * GSP_GPU::FlushDataCache service function + * + * This Function is a no-op, We aren't emulating the CPU cache any time soon. + * + * Inputs: + * 1 : Address + * 2 : Size + * 3 : Value 0, some descriptor for the KProcess Handle + * 4 : KProcess handle + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +static void FlushDataCache(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + u32 address = cmd_buff[1]; + u32 size = cmd_buff[2]; + u32 process = cmd_buff[4]; + + // TODO(purpasmart96): Verify return header on HW + + cmd_buff[1] = RESULT_SUCCESS.raw; // No error +} + +/** * GSP_GPU::RegisterInterruptRelayQueue service function * Inputs: * 1 : "Flags" field, purpose is unknown @@ -335,7 +359,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00050200, SetBufferSwap, "SetBufferSwap"}, {0x00060082, nullptr, "SetCommandList"}, {0x000700C2, nullptr, "RequestDma"}, - {0x00080082, nullptr, "FlushDataCache"}, + {0x00080082, FlushDataCache, "FlushDataCache"}, {0x00090082, nullptr, "InvalidateDataCache"}, {0x000A0044, nullptr, "RegisterInterruptEvents"}, {0x000B0040, nullptr, "SetLcdForceBlack"}, |