summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-06 23:58:24 -0400
committerGravatar GitHub2018-10-06 23:58:24 -0400
commit6e4d2e672d1083f29186ea0ddcb33cd634e360e3 (patch)
treecbd20aab8705f8efac340c509ca71b08865a1417 /src/core/file_sys
parentMerge pull request #1446 from bunnei/fast_fermi_copy (diff)
parentromfs_factory: Extract packed update setter to new function (diff)
downloadyuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.gz
yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.xz
yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.zip
Merge pull request #1396 from DarkLordZach/packed-updates
loader: Add support for packed updates
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/patch_manager.cpp16
-rw-r--r--src/core/file_sys/patch_manager.h6
-rw-r--r--src/core/file_sys/romfs_factory.cpp7
-rw-r--r--src/core/file_sys/romfs_factory.h2
-rw-r--r--src/core/file_sys/submission_package.cpp5
5 files changed, 29 insertions, 7 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 539698f6e..1ac00ebb0 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -184,8 +184,8 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t
184 romfs = std::move(packed); 184 romfs = std::move(packed);
185} 185}
186 186
187VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, 187VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, ContentRecordType type,
188 ContentRecordType type) const { 188 VirtualFile update_raw) const {
189 LOG_INFO(Loader, "Patching RomFS for title_id={:016X}, type={:02X}", title_id, 189 LOG_INFO(Loader, "Patching RomFS for title_id={:016X}, type={:02X}", title_id,
190 static_cast<u8>(type)); 190 static_cast<u8>(type));
191 191
@@ -205,6 +205,13 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset,
205 FormatTitleVersion(installed->GetEntryVersion(update_tid).get_value_or(0))); 205 FormatTitleVersion(installed->GetEntryVersion(update_tid).get_value_or(0)));
206 romfs = new_nca->GetRomFS(); 206 romfs = new_nca->GetRomFS();
207 } 207 }
208 } else if (update_raw != nullptr) {
209 const auto new_nca = std::make_shared<NCA>(update_raw, romfs, ivfc_offset);
210 if (new_nca->GetStatus() == Loader::ResultStatus::Success &&
211 new_nca->GetRomFS() != nullptr) {
212 LOG_INFO(Loader, " RomFS: Update (PACKED) applied successfully");
213 romfs = new_nca->GetRomFS();
214 }
208 } 215 }
209 216
210 // LayeredFS 217 // LayeredFS
@@ -224,7 +231,8 @@ static bool IsDirValidAndNonEmpty(const VirtualDir& dir) {
224 return dir != nullptr && (!dir->GetFiles().empty() || !dir->GetSubdirectories().empty()); 231 return dir != nullptr && (!dir->GetFiles().empty() || !dir->GetSubdirectories().empty());
225} 232}
226 233
227std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames() const { 234std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames(
235 VirtualFile update_raw) const {
228 std::map<std::string, std::string, std::less<>> out; 236 std::map<std::string, std::string, std::less<>> out;
229 const auto installed = Service::FileSystem::GetUnionContents(); 237 const auto installed = Service::FileSystem::GetUnionContents();
230 238
@@ -245,6 +253,8 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
245 "Update", 253 "Update",
246 FormatTitleVersion(meta_ver.get(), TitleVersionFormat::ThreeElements)); 254 FormatTitleVersion(meta_ver.get(), TitleVersionFormat::ThreeElements));
247 } 255 }
256 } else if (update_raw != nullptr) {
257 out.insert_or_assign("Update", "PACKED");
248 } 258 }
249 } 259 }
250 260
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h
index 6a864ec43..2ae9322a1 100644
--- a/src/core/file_sys/patch_manager.h
+++ b/src/core/file_sys/patch_manager.h
@@ -46,11 +46,13 @@ public:
46 // - Game Updates 46 // - Game Updates
47 // - LayeredFS 47 // - LayeredFS
48 VirtualFile PatchRomFS(VirtualFile base, u64 ivfc_offset, 48 VirtualFile PatchRomFS(VirtualFile base, u64 ivfc_offset,
49 ContentRecordType type = ContentRecordType::Program) const; 49 ContentRecordType type = ContentRecordType::Program,
50 VirtualFile update_raw = nullptr) const;
50 51
51 // Returns a vector of pairs between patch names and patch versions. 52 // Returns a vector of pairs between patch names and patch versions.
52 // i.e. Update 3.2.2 will return {"Update", "3.2.2"} 53 // i.e. Update 3.2.2 will return {"Update", "3.2.2"}
53 std::map<std::string, std::string, std::less<>> GetPatchVersionNames() const; 54 std::map<std::string, std::string, std::less<>> GetPatchVersionNames(
55 VirtualFile update_raw = nullptr) const;
54 56
55 // Given title_id of the program, attempts to get the control data of the update and parse it, 57 // Given title_id of the program, attempts to get the control data of the update and parse it,
56 // falling back to the base control data. 58 // falling back to the base control data.
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 4994c2532..0b645b106 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -30,12 +30,17 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) {
30 30
31RomFSFactory::~RomFSFactory() = default; 31RomFSFactory::~RomFSFactory() = default;
32 32
33void RomFSFactory::SetPackedUpdate(VirtualFile update_raw) {
34 this->update_raw = std::move(update_raw);
35}
36
33ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { 37ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
34 if (!updatable) 38 if (!updatable)
35 return MakeResult<VirtualFile>(file); 39 return MakeResult<VirtualFile>(file);
36 40
37 const PatchManager patch_manager(Core::CurrentProcess()->GetTitleID()); 41 const PatchManager patch_manager(Core::CurrentProcess()->GetTitleID());
38 return MakeResult<VirtualFile>(patch_manager.PatchRomFS(file, ivfc_offset)); 42 return MakeResult<VirtualFile>(
43 patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw));
39} 44}
40 45
41ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) { 46ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) {
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h
index 2cace8180..7724c0b23 100644
--- a/src/core/file_sys/romfs_factory.h
+++ b/src/core/file_sys/romfs_factory.h
@@ -32,11 +32,13 @@ public:
32 explicit RomFSFactory(Loader::AppLoader& app_loader); 32 explicit RomFSFactory(Loader::AppLoader& app_loader);
33 ~RomFSFactory(); 33 ~RomFSFactory();
34 34
35 void SetPackedUpdate(VirtualFile update_raw);
35 ResultVal<VirtualFile> OpenCurrentProcess(); 36 ResultVal<VirtualFile> OpenCurrentProcess();
36 ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type); 37 ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);
37 38
38private: 39private:
39 VirtualFile file; 40 VirtualFile file;
41 VirtualFile update_raw;
40 bool updatable; 42 bool updatable;
41 u64 ivfc_offset; 43 u64 ivfc_offset;
42}; 44};
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp
index 09bf077cd..ab5dc900c 100644
--- a/src/core/file_sys/submission_package.cpp
+++ b/src/core/file_sys/submission_package.cpp
@@ -259,8 +259,11 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
259 auto next_nca = std::make_shared<NCA>(next_file); 259 auto next_nca = std::make_shared<NCA>(next_file);
260 if (next_nca->GetType() == NCAContentType::Program) 260 if (next_nca->GetType() == NCAContentType::Program)
261 program_status[cnmt.GetTitleID()] = next_nca->GetStatus(); 261 program_status[cnmt.GetTitleID()] = next_nca->GetStatus();
262 if (next_nca->GetStatus() == Loader::ResultStatus::Success) 262 if (next_nca->GetStatus() == Loader::ResultStatus::Success ||
263 (next_nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS &&
264 (cnmt.GetTitleID() & 0x800) != 0)) {
263 ncas_title[rec.type] = std::move(next_nca); 265 ncas_title[rec.type] = std::move(next_nca);
266 }
264 } 267 }
265 268
266 break; 269 break;