diff options
| author | 2017-02-13 09:18:23 -0800 | |
|---|---|---|
| committer | 2017-02-13 09:18:23 -0800 | |
| commit | d60767d393b0fd163d2676f649e3c209537ef884 (patch) | |
| tree | fc8db322e44cb699e17081e7ed6d4f484eb4f75e | |
| parent | video_core/shader: Document sanitized MUL operation (diff) | |
| parent | loader: use self NCCH archive (diff) | |
| download | yuzu-d60767d393b0fd163d2676f649e3c209537ef884.tar.gz yuzu-d60767d393b0fd163d2676f649e3c209537ef884.tar.xz yuzu-d60767d393b0fd163d2676f649e3c209537ef884.zip | |
Merge pull request #2561 from wwylele/fs-rom
file_sys: change RomFS archive to Self NCCH archive
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 43 | ||||
| -rw-r--r-- | src/core/file_sys/archive_selfncch.cpp | 257 | ||||
| -rw-r--r-- | src/core/file_sys/archive_selfncch.h (renamed from src/core/file_sys/archive_romfs.h) | 23 | ||||
| -rw-r--r-- | src/core/file_sys/errors.h | 10 | ||||
| -rw-r--r-- | src/core/hle/result.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 2 | ||||
| -rw-r--r-- | src/core/loader/3dsx.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 6 |
9 files changed, 295 insertions, 60 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b178914dd..8c2438831 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -20,10 +20,10 @@ set(SRCS | |||
| 20 | file_sys/archive_extsavedata.cpp | 20 | file_sys/archive_extsavedata.cpp |
| 21 | file_sys/archive_ncch.cpp | 21 | file_sys/archive_ncch.cpp |
| 22 | file_sys/archive_other_savedata.cpp | 22 | file_sys/archive_other_savedata.cpp |
| 23 | file_sys/archive_romfs.cpp | ||
| 24 | file_sys/archive_savedata.cpp | 23 | file_sys/archive_savedata.cpp |
| 25 | file_sys/archive_sdmc.cpp | 24 | file_sys/archive_sdmc.cpp |
| 26 | file_sys/archive_sdmcwriteonly.cpp | 25 | file_sys/archive_sdmcwriteonly.cpp |
| 26 | file_sys/archive_selfncch.cpp | ||
| 27 | file_sys/archive_source_sd_savedata.cpp | 27 | file_sys/archive_source_sd_savedata.cpp |
| 28 | file_sys/archive_systemsavedata.cpp | 28 | file_sys/archive_systemsavedata.cpp |
| 29 | file_sys/disk_archive.cpp | 29 | file_sys/disk_archive.cpp |
| @@ -197,10 +197,10 @@ set(HEADERS | |||
| 197 | file_sys/archive_extsavedata.h | 197 | file_sys/archive_extsavedata.h |
| 198 | file_sys/archive_ncch.h | 198 | file_sys/archive_ncch.h |
| 199 | file_sys/archive_other_savedata.h | 199 | file_sys/archive_other_savedata.h |
| 200 | file_sys/archive_romfs.h | ||
| 201 | file_sys/archive_savedata.h | 200 | file_sys/archive_savedata.h |
| 202 | file_sys/archive_sdmc.h | 201 | file_sys/archive_sdmc.h |
| 203 | file_sys/archive_sdmcwriteonly.h | 202 | file_sys/archive_sdmcwriteonly.h |
| 203 | file_sys/archive_selfncch.h | ||
| 204 | file_sys/archive_source_sd_savedata.h | 204 | file_sys/archive_source_sd_savedata.h |
| 205 | file_sys/archive_systemsavedata.h | 205 | file_sys/archive_systemsavedata.h |
| 206 | file_sys/directory_backend.h | 206 | file_sys/directory_backend.h |
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp deleted file mode 100644 index 6c99ca5b4..000000000 --- a/src/core/file_sys/archive_romfs.cpp +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <memory> | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "core/file_sys/archive_romfs.h" | ||
| 10 | #include "core/file_sys/ivfc_archive.h" | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 13 | // FileSys namespace | ||
| 14 | |||
| 15 | namespace FileSys { | ||
| 16 | |||
| 17 | ArchiveFactory_RomFS::ArchiveFactory_RomFS(Loader::AppLoader& app_loader) { | ||
| 18 | // Load the RomFS from the app | ||
| 19 | if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { | ||
| 20 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | |||
| 24 | ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) { | ||
| 25 | auto archive = std::make_unique<IVFCArchive>(romfs_file, data_offset, data_size); | ||
| 26 | return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); | ||
| 27 | } | ||
| 28 | |||
| 29 | ResultCode ArchiveFactory_RomFS::Format(const Path& path, | ||
| 30 | const FileSys::ArchiveFormatInfo& format_info) { | ||
| 31 | LOG_ERROR(Service_FS, "Attempted to format a RomFS archive."); | ||
| 32 | // TODO: Verify error code | ||
| 33 | return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, | ||
| 34 | ErrorLevel::Permanent); | ||
| 35 | } | ||
| 36 | |||
| 37 | ResultVal<ArchiveFormatInfo> ArchiveFactory_RomFS::GetFormatInfo(const Path& path) const { | ||
| 38 | // TODO(Subv): Implement | ||
| 39 | LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); | ||
| 40 | return ResultCode(-1); | ||
| 41 | } | ||
| 42 | |||
| 43 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/archive_selfncch.cpp b/src/core/file_sys/archive_selfncch.cpp new file mode 100644 index 000000000..298a37a44 --- /dev/null +++ b/src/core/file_sys/archive_selfncch.cpp | |||
| @@ -0,0 +1,257 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <array> | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "common/logging/log.h" | ||
| 8 | #include "common/swap.h" | ||
| 9 | #include "core/file_sys/archive_selfncch.h" | ||
| 10 | #include "core/file_sys/errors.h" | ||
| 11 | #include "core/file_sys/ivfc_archive.h" | ||
| 12 | |||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 14 | // FileSys namespace | ||
| 15 | |||
| 16 | namespace FileSys { | ||
| 17 | |||
| 18 | enum class SelfNCCHFilePathType : u32 { | ||
| 19 | RomFS = 0, | ||
| 20 | Code = 1, // This is not supported by SelfNCCHArchive but by archive 0x2345678E | ||
| 21 | ExeFS = 2, | ||
| 22 | UpdateRomFS = 5, // This is presumably for accessing the RomFS of the update patch. | ||
| 23 | }; | ||
| 24 | |||
| 25 | struct SelfNCCHFilePath { | ||
| 26 | u32_le type; | ||
| 27 | std::array<char, 8> exefs_filename; | ||
| 28 | }; | ||
| 29 | static_assert(sizeof(SelfNCCHFilePath) == 12, "NCCHFilePath has wrong size!"); | ||
| 30 | |||
| 31 | // A read-only file created from a block of data. It only allows you to read the entire file at | ||
| 32 | // once, in a single read operation. | ||
| 33 | class ExeFSSectionFile final : public FileBackend { | ||
| 34 | public: | ||
| 35 | explicit ExeFSSectionFile(std::shared_ptr<std::vector<u8>> data_) : data(std::move(data_)) {} | ||
| 36 | |||
| 37 | ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override { | ||
| 38 | if (offset != 0) { | ||
| 39 | LOG_ERROR(Service_FS, "offset must be zero!"); | ||
| 40 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 41 | } | ||
| 42 | |||
| 43 | if (length != data->size()) { | ||
| 44 | LOG_ERROR(Service_FS, "size must match the file size!"); | ||
| 45 | return ERROR_INCORRECT_EXEFS_READ_SIZE; | ||
| 46 | } | ||
| 47 | |||
| 48 | std::memcpy(buffer, data->data(), data->size()); | ||
| 49 | return MakeResult<size_t>(data->size()); | ||
| 50 | } | ||
| 51 | |||
| 52 | ResultVal<size_t> Write(u64 offset, size_t length, bool flush, | ||
| 53 | const u8* buffer) const override { | ||
| 54 | LOG_ERROR(Service_FS, "The file is read-only!"); | ||
| 55 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 56 | } | ||
| 57 | |||
| 58 | u64 GetSize() const override { | ||
| 59 | return data->size(); | ||
| 60 | } | ||
| 61 | |||
| 62 | bool SetSize(u64 size) const override { | ||
| 63 | return false; | ||
| 64 | } | ||
| 65 | |||
| 66 | bool Close() const override { | ||
| 67 | return true; | ||
| 68 | } | ||
| 69 | |||
| 70 | void Flush() const override {} | ||
| 71 | |||
| 72 | private: | ||
| 73 | std::shared_ptr<std::vector<u8>> data; | ||
| 74 | }; | ||
| 75 | |||
| 76 | // SelfNCCHArchive represents the running application itself. From this archive the application can | ||
| 77 | // open RomFS and ExeFS, excluding the .code section. | ||
| 78 | class SelfNCCHArchive final : public ArchiveBackend { | ||
| 79 | public: | ||
| 80 | explicit SelfNCCHArchive(const NCCHData& ncch_data_) : ncch_data(ncch_data_) {} | ||
| 81 | |||
| 82 | std::string GetName() const override { | ||
| 83 | return "SelfNCCHArchive"; | ||
| 84 | } | ||
| 85 | |||
| 86 | ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, const Mode&) const override { | ||
| 87 | // Note: SelfNCCHArchive doesn't check the open mode. | ||
| 88 | |||
| 89 | if (path.GetType() != LowPathType::Binary) { | ||
| 90 | LOG_ERROR(Service_FS, "Path need to be Binary"); | ||
| 91 | return ERROR_INVALID_PATH; | ||
| 92 | } | ||
| 93 | |||
| 94 | std::vector<u8> binary = path.AsBinary(); | ||
| 95 | if (binary.size() != sizeof(SelfNCCHFilePath)) { | ||
| 96 | LOG_ERROR(Service_FS, "Wrong path size %zu", binary.size()); | ||
| 97 | return ERROR_INVALID_PATH; | ||
| 98 | } | ||
| 99 | |||
| 100 | SelfNCCHFilePath file_path; | ||
| 101 | std::memcpy(&file_path, binary.data(), sizeof(SelfNCCHFilePath)); | ||
| 102 | |||
| 103 | switch (static_cast<SelfNCCHFilePathType>(file_path.type)) { | ||
| 104 | case SelfNCCHFilePathType::UpdateRomFS: | ||
| 105 | LOG_WARNING(Service_FS, "(STUBBED) open update RomFS"); | ||
| 106 | return OpenRomFS(); | ||
| 107 | |||
| 108 | case SelfNCCHFilePathType::RomFS: | ||
| 109 | return OpenRomFS(); | ||
| 110 | |||
| 111 | case SelfNCCHFilePathType::Code: | ||
| 112 | LOG_ERROR(Service_FS, "Reading the code section is not supported!"); | ||
| 113 | return ERROR_COMMAND_NOT_ALLOWED; | ||
| 114 | |||
| 115 | case SelfNCCHFilePathType::ExeFS: { | ||
| 116 | const auto& raw = file_path.exefs_filename; | ||
| 117 | auto end = std::find(raw.begin(), raw.end(), '\0'); | ||
| 118 | std::string filename(raw.begin(), end); | ||
| 119 | return OpenExeFS(filename); | ||
| 120 | } | ||
| 121 | default: | ||
| 122 | LOG_ERROR(Service_FS, "Unknown file type %u!", static_cast<u32>(file_path.type)); | ||
| 123 | return ERROR_INVALID_PATH; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | ResultCode DeleteFile(const Path& path) const override { | ||
| 128 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 129 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 130 | } | ||
| 131 | |||
| 132 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override { | ||
| 133 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 134 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 135 | } | ||
| 136 | |||
| 137 | ResultCode DeleteDirectory(const Path& path) const override { | ||
| 138 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 139 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 140 | } | ||
| 141 | |||
| 142 | ResultCode DeleteDirectoryRecursively(const Path& path) const override { | ||
| 143 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 144 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 145 | } | ||
| 146 | |||
| 147 | ResultCode CreateFile(const Path& path, u64 size) const override { | ||
| 148 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 149 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 150 | } | ||
| 151 | |||
| 152 | ResultCode CreateDirectory(const Path& path) const override { | ||
| 153 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 154 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 155 | } | ||
| 156 | |||
| 157 | ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override { | ||
| 158 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 159 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 160 | } | ||
| 161 | |||
| 162 | ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override { | ||
| 163 | LOG_ERROR(Service_FS, "Unsupported"); | ||
| 164 | return ERROR_UNSUPPORTED_OPEN_FLAGS; | ||
| 165 | } | ||
| 166 | |||
| 167 | u64 GetFreeBytes() const override { | ||
| 168 | return 0; | ||
| 169 | } | ||
| 170 | |||
| 171 | private: | ||
| 172 | ResultVal<std::unique_ptr<FileBackend>> OpenRomFS() const { | ||
| 173 | if (ncch_data.romfs_file) { | ||
| 174 | return MakeResult<std::unique_ptr<FileBackend>>(std::make_unique<IVFCFile>( | ||
| 175 | ncch_data.romfs_file, ncch_data.romfs_offset, ncch_data.romfs_size)); | ||
| 176 | } else { | ||
| 177 | LOG_INFO(Service_FS, "Unable to read RomFS"); | ||
| 178 | return ERROR_ROMFS_NOT_FOUND; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 182 | ResultVal<std::unique_ptr<FileBackend>> OpenExeFS(const std::string& filename) const { | ||
| 183 | if (filename == "icon") { | ||
| 184 | if (ncch_data.icon) { | ||
| 185 | return MakeResult<std::unique_ptr<FileBackend>>( | ||
| 186 | std::make_unique<ExeFSSectionFile>(ncch_data.icon)); | ||
| 187 | } | ||
| 188 | |||
| 189 | LOG_WARNING(Service_FS, "Unable to read icon"); | ||
| 190 | return ERROR_EXEFS_SECTION_NOT_FOUND; | ||
| 191 | } | ||
| 192 | |||
| 193 | if (filename == "logo") { | ||
| 194 | if (ncch_data.logo) { | ||
| 195 | return MakeResult<std::unique_ptr<FileBackend>>( | ||
| 196 | std::make_unique<ExeFSSectionFile>(ncch_data.logo)); | ||
| 197 | } | ||
| 198 | |||
| 199 | LOG_WARNING(Service_FS, "Unable to read logo"); | ||
| 200 | return ERROR_EXEFS_SECTION_NOT_FOUND; | ||
| 201 | } | ||
| 202 | |||
| 203 | if (filename == "banner") { | ||
| 204 | if (ncch_data.banner) { | ||
| 205 | return MakeResult<std::unique_ptr<FileBackend>>( | ||
| 206 | std::make_unique<ExeFSSectionFile>(ncch_data.banner)); | ||
| 207 | } | ||
| 208 | |||
| 209 | LOG_WARNING(Service_FS, "Unable to read banner"); | ||
| 210 | return ERROR_EXEFS_SECTION_NOT_FOUND; | ||
| 211 | } | ||
| 212 | |||
| 213 | LOG_ERROR(Service_FS, "Unknown ExeFS section %s!", filename.c_str()); | ||
| 214 | return ERROR_INVALID_PATH; | ||
| 215 | } | ||
| 216 | |||
| 217 | NCCHData ncch_data; | ||
| 218 | }; | ||
| 219 | |||
| 220 | ArchiveFactory_SelfNCCH::ArchiveFactory_SelfNCCH(Loader::AppLoader& app_loader) { | ||
| 221 | std::shared_ptr<FileUtil::IOFile> romfs_file_; | ||
| 222 | if (Loader::ResultStatus::Success == | ||
| 223 | app_loader.ReadRomFS(romfs_file_, ncch_data.romfs_offset, ncch_data.romfs_size)) { | ||
| 224 | |||
| 225 | ncch_data.romfs_file = std::move(romfs_file_); | ||
| 226 | } | ||
| 227 | |||
| 228 | std::vector<u8> buffer; | ||
| 229 | |||
| 230 | if (Loader::ResultStatus::Success == app_loader.ReadIcon(buffer)) | ||
| 231 | ncch_data.icon = std::make_shared<std::vector<u8>>(std::move(buffer)); | ||
| 232 | |||
| 233 | buffer.clear(); | ||
| 234 | if (Loader::ResultStatus::Success == app_loader.ReadLogo(buffer)) | ||
| 235 | ncch_data.logo = std::make_shared<std::vector<u8>>(std::move(buffer)); | ||
| 236 | |||
| 237 | buffer.clear(); | ||
| 238 | if (Loader::ResultStatus::Success == app_loader.ReadBanner(buffer)) | ||
| 239 | ncch_data.banner = std::make_shared<std::vector<u8>>(std::move(buffer)); | ||
| 240 | } | ||
| 241 | |||
| 242 | ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SelfNCCH::Open(const Path& path) { | ||
| 243 | auto archive = std::make_unique<SelfNCCHArchive>(ncch_data); | ||
| 244 | return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); | ||
| 245 | } | ||
| 246 | |||
| 247 | ResultCode ArchiveFactory_SelfNCCH::Format(const Path&, const FileSys::ArchiveFormatInfo&) { | ||
| 248 | LOG_ERROR(Service_FS, "Attempted to format a SelfNCCH archive."); | ||
| 249 | return ERROR_INVALID_PATH; | ||
| 250 | } | ||
| 251 | |||
| 252 | ResultVal<ArchiveFormatInfo> ArchiveFactory_SelfNCCH::GetFormatInfo(const Path&) const { | ||
| 253 | LOG_ERROR(Service_FS, "Attempted to get format info of a SelfNCCH archive"); | ||
| 254 | return ERROR_INVALID_PATH; | ||
| 255 | } | ||
| 256 | |||
| 257 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_selfncch.h index 1eaf99b54..f1b971296 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_selfncch.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2017 Citra Emulator Project |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| @@ -17,22 +17,29 @@ | |||
| 17 | 17 | ||
| 18 | namespace FileSys { | 18 | namespace FileSys { |
| 19 | 19 | ||
| 20 | /// File system interface to the RomFS archive | 20 | struct NCCHData { |
| 21 | class ArchiveFactory_RomFS final : public ArchiveFactory { | 21 | std::shared_ptr<std::vector<u8>> icon; |
| 22 | std::shared_ptr<std::vector<u8>> logo; | ||
| 23 | std::shared_ptr<std::vector<u8>> banner; | ||
| 24 | std::shared_ptr<FileUtil::IOFile> romfs_file; | ||
| 25 | u64 romfs_offset = 0; | ||
| 26 | u64 romfs_size = 0; | ||
| 27 | }; | ||
| 28 | |||
| 29 | /// File system interface to the SelfNCCH archive | ||
| 30 | class ArchiveFactory_SelfNCCH final : public ArchiveFactory { | ||
| 22 | public: | 31 | public: |
| 23 | explicit ArchiveFactory_RomFS(Loader::AppLoader& app_loader); | 32 | explicit ArchiveFactory_SelfNCCH(Loader::AppLoader& app_loader); |
| 24 | 33 | ||
| 25 | std::string GetName() const override { | 34 | std::string GetName() const override { |
| 26 | return "RomFS"; | 35 | return "SelfNCCH"; |
| 27 | } | 36 | } |
| 28 | ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override; | 37 | ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override; |
| 29 | ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) override; | 38 | ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) override; |
| 30 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; | 39 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; |
| 31 | 40 | ||
| 32 | private: | 41 | private: |
| 33 | std::shared_ptr<FileUtil::IOFile> romfs_file; | 42 | NCCHData ncch_data; |
| 34 | u64 data_offset; | ||
| 35 | u64 data_size; | ||
| 36 | }; | 43 | }; |
| 37 | 44 | ||
| 38 | } // namespace FileSys | 45 | } // namespace FileSys |
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index 4d5f62b08..9fc8d753b 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h | |||
| @@ -39,5 +39,15 @@ const ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrorDescription::FS_DirectoryNotEmpt | |||
| 39 | const ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrorDescription::FS_GameCardNotInserted, | 39 | const ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrorDescription::FS_GameCardNotInserted, |
| 40 | ErrorModule::FS, ErrorSummary::NotFound, | 40 | ErrorModule::FS, ErrorSummary::NotFound, |
| 41 | ErrorLevel::Status); | 41 | ErrorLevel::Status); |
| 42 | const ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrorDescription::FS_IncorrectExeFSReadSize, | ||
| 43 | ErrorModule::FS, ErrorSummary::NotSupported, | ||
| 44 | ErrorLevel::Usage); | ||
| 45 | const ResultCode ERROR_ROMFS_NOT_FOUND(ErrorDescription::FS_RomFSNotFound, ErrorModule::FS, | ||
| 46 | ErrorSummary::NotFound, ErrorLevel::Status); | ||
| 47 | const ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrorDescription::FS_CommandNotAllowed, ErrorModule::FS, | ||
| 48 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 49 | const ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrorDescription::FS_ExeFSSectionNotFound, | ||
| 50 | ErrorModule::FS, ErrorSummary::NotFound, | ||
| 51 | ErrorLevel::Status); | ||
| 42 | 52 | ||
| 43 | } // namespace FileSys | 53 | } // namespace FileSys |
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 53864a3a7..cfefbbc64 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -20,6 +20,7 @@ enum class ErrorDescription : u32 { | |||
| 20 | OS_InvalidBufferDescriptor = 48, | 20 | OS_InvalidBufferDescriptor = 48, |
| 21 | MaxConnectionsReached = 52, | 21 | MaxConnectionsReached = 52, |
| 22 | WrongAddress = 53, | 22 | WrongAddress = 53, |
| 23 | FS_RomFSNotFound = 100, | ||
| 23 | FS_ArchiveNotMounted = 101, | 24 | FS_ArchiveNotMounted = 101, |
| 24 | FS_FileNotFound = 112, | 25 | FS_FileNotFound = 112, |
| 25 | FS_PathNotFound = 113, | 26 | FS_PathNotFound = 113, |
| @@ -35,10 +36,13 @@ enum class ErrorDescription : u32 { | |||
| 35 | OutofRangeOrMisalignedAddress = | 36 | OutofRangeOrMisalignedAddress = |
| 36 | 513, // TODO(purpasmart): Check if this name fits its actual usage | 37 | 513, // TODO(purpasmart): Check if this name fits its actual usage |
| 37 | GPU_FirstInitialization = 519, | 38 | GPU_FirstInitialization = 519, |
| 39 | FS_ExeFSSectionNotFound = 567, | ||
| 40 | FS_CommandNotAllowed = 630, | ||
| 38 | FS_InvalidReadFlag = 700, | 41 | FS_InvalidReadFlag = 700, |
| 39 | FS_InvalidPath = 702, | 42 | FS_InvalidPath = 702, |
| 40 | FS_WriteBeyondEnd = 705, | 43 | FS_WriteBeyondEnd = 705, |
| 41 | FS_UnsupportedOpenFlags = 760, | 44 | FS_UnsupportedOpenFlags = 760, |
| 45 | FS_IncorrectExeFSReadSize = 761, | ||
| 42 | FS_UnexpectedFileOrDirectory = 770, | 46 | FS_UnexpectedFileOrDirectory = 770, |
| 43 | InvalidSection = 1000, | 47 | InvalidSection = 1000, |
| 44 | TooLarge = 1001, | 48 | TooLarge = 1001, |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 519c1f3a9..2ea956e0b 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -26,7 +26,7 @@ namespace FS { | |||
| 26 | 26 | ||
| 27 | /// Supported archive types | 27 | /// Supported archive types |
| 28 | enum class ArchiveIdCode : u32 { | 28 | enum class ArchiveIdCode : u32 { |
| 29 | RomFS = 0x00000003, | 29 | SelfNCCH = 0x00000003, |
| 30 | SaveData = 0x00000004, | 30 | SaveData = 0x00000004, |
| 31 | ExtSaveData = 0x00000006, | 31 | ExtSaveData = 0x00000006, |
| 32 | SharedExtSaveData = 0x00000007, | 32 | SharedExtSaveData = 0x00000007, |
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index 09266e8b0..74e336487 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/file_sys/archive_romfs.h" | 8 | #include "core/file_sys/archive_selfncch.h" |
| 9 | #include "core/hle/kernel/process.h" | 9 | #include "core/hle/kernel/process.h" |
| 10 | #include "core/hle/kernel/resource_limit.h" | 10 | #include "core/hle/kernel/resource_limit.h" |
| 11 | #include "core/hle/service/fs/archive.h" | 11 | #include "core/hle/service/fs/archive.h" |
| @@ -277,8 +277,8 @@ ResultStatus AppLoader_THREEDSX::Load() { | |||
| 277 | 277 | ||
| 278 | Kernel::g_current_process->Run(48, Kernel::DEFAULT_STACK_SIZE); | 278 | Kernel::g_current_process->Run(48, Kernel::DEFAULT_STACK_SIZE); |
| 279 | 279 | ||
| 280 | Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*this), | 280 | Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_SelfNCCH>(*this), |
| 281 | Service::FS::ArchiveIdCode::RomFS); | 281 | Service::FS::ArchiveIdCode::SelfNCCH); |
| 282 | 282 | ||
| 283 | is_loaded = true; | 283 | is_loaded = true; |
| 284 | return ResultStatus::Success; | 284 | return ResultStatus::Success; |
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 5df33f6d2..98b8259d9 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "common/string_util.h" | 9 | #include "common/string_util.h" |
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/file_sys/archive_romfs.h" | 11 | #include "core/file_sys/archive_selfncch.h" |
| 12 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
| 13 | #include "core/hle/kernel/resource_limit.h" | 13 | #include "core/hle/kernel/resource_limit.h" |
| 14 | #include "core/hle/service/cfg/cfg.h" | 14 | #include "core/hle/service/cfg/cfg.h" |
| @@ -342,8 +342,8 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 342 | if (ResultStatus::Success != result) | 342 | if (ResultStatus::Success != result) |
| 343 | return result; | 343 | return result; |
| 344 | 344 | ||
| 345 | Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*this), | 345 | Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_SelfNCCH>(*this), |
| 346 | Service::FS::ArchiveIdCode::RomFS); | 346 | Service::FS::ArchiveIdCode::SelfNCCH); |
| 347 | 347 | ||
| 348 | ParseRegionLockoutInfo(); | 348 | ParseRegionLockoutInfo(); |
| 349 | 349 | ||