summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-06-19 00:11:45 -0400
committerGravatar bunnei2014-06-24 19:30:06 -0400
commita8c46485203d3ab00ef478bbf9daa7450df14dfd (patch)
tree0f30ad4e7442a13e2e4e9aa68e687b677375c4d0 /src
parentNCCH: Fixes reduce unnecessary logging and load logo/banner/etc. sections cor... (diff)
downloadyuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.gz
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.xz
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.zip
NCCH: Added RomFS loading.
Diffstat (limited to 'src')
-rw-r--r--src/core/loader/ncch.cpp29
-rw-r--r--src/core/loader/ncch.h8
2 files changed, 36 insertions, 1 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 4cf805ba0..6423da8f9 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -179,6 +179,32 @@ const ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const ch
179} 179}
180 180
181/** 181/**
182 * Reads RomFS of an NCCH file into AppLoader
183 * @param file Handle to file to read from
184 * @return ResultStatus result of function
185 */
186const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
187 // Check if the NCCH has a RomFS...
188 if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
189 u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
190 u32 romfs_size = (ncch_header.romfs_size * kBlockSize) - 0x1000;
191
192 INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset);
193 INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size);
194
195 romfs.resize(romfs_size);
196
197 file.Seek(romfs_offset, 0);
198 file.ReadBytes(&romfs[0], romfs_size);
199
200 return ResultStatus::Success;
201 } else {
202 NOTICE_LOG(LOADER, "RomFS unused");
203 }
204 return ResultStatus::ErrorNotUsed;
205}
206
207/**
182 * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) 208 * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
183 * @param error_string Pointer to string to put error message if an error has occurred 209 * @param error_string Pointer to string to put error message if an error has occurred
184 * @todo Move NCSD parsing out of here and create a separate function for loading these 210 * @todo Move NCSD parsing out of here and create a separate function for loading these
@@ -193,7 +219,6 @@ const ResultStatus AppLoader_NCCH::Load() {
193 File::IOFile file(filename, "rb"); 219 File::IOFile file(filename, "rb");
194 220
195 if (file.IsOpen()) { 221 if (file.IsOpen()) {
196 NCCH_Header ncch_header;
197 file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); 222 file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
198 223
199 // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... 224 // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)...
@@ -237,6 +262,8 @@ const ResultStatus AppLoader_NCCH::Load() {
237 LoadSectionExeFS(file, "icon", icon); 262 LoadSectionExeFS(file, "icon", icon);
238 LoadSectionExeFS(file, "logo", logo); 263 LoadSectionExeFS(file, "logo", logo);
239 264
265 LoadRomFS(file);
266
240 is_loaded = true; // Set state to loaded 267 is_loaded = true; // Set state to loaded
241 268
242 LoadExec(); // Load the executable into memory for booting 269 LoadExec(); // Load the executable into memory for booting
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 525a5aef5..939b144a6 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -169,6 +169,13 @@ private:
169 std::vector<u8>& buffer); 169 std::vector<u8>& buffer);
170 170
171 /** 171 /**
172 * Reads RomFS of an NCCH file into AppLoader
173 * @param file Handle to file to read from
174 * @return ResultStatus result of function
175 */
176 const ResultStatus LoadRomFS(File::IOFile& file);
177
178 /**
172 * Loads .code section into memory for booting 179 * Loads .code section into memory for booting
173 * @return ResultStatus result of function 180 * @return ResultStatus result of function
174 */ 181 */
@@ -182,6 +189,7 @@ private:
182 u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header 189 u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header
183 u32 exefs_offset; 190 u32 exefs_offset;
184 191
192 NCCH_Header ncch_header;
185 ExeFs_Header exefs_header; 193 ExeFs_Header exefs_header;
186 ExHeader_Header exheader_header; 194 ExHeader_Header exheader_header;
187}; 195};