summaryrefslogtreecommitdiff
path: root/src/core/loader
diff options
context:
space:
mode:
authorGravatar Subv2016-11-19 20:40:04 -0500
committerGravatar Subv2016-11-19 20:40:04 -0500
commit1323ab2f5f1627b39e48b6f970ad8208fa7af71e (patch)
tree6b3257864d76a4cdd3d8bb9847e55a2a51ff7573 /src/core/loader
parentMerge pull request #2172 from jroweboy/fix-mingw (diff)
downloadyuzu-1323ab2f5f1627b39e48b6f970ad8208fa7af71e.tar.gz
yuzu-1323ab2f5f1627b39e48b6f970ad8208fa7af71e.tar.xz
yuzu-1323ab2f5f1627b39e48b6f970ad8208fa7af71e.zip
Kernel/Loader: Grab the system mode from the NCCH ExHeader.
3dsx and elf files default to system mode 2 (96MB allocated to the application). This allows Home Menu to boot without modifications. Closes #1849
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/loader.h11
-rw-r--r--src/core/loader/ncch.cpp9
-rw-r--r--src/core/loader/ncch.h7
3 files changed, 27 insertions, 0 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 9652d7ac5..e62f77b9c 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -96,6 +96,17 @@ public:
96 virtual ResultStatus Load() = 0; 96 virtual ResultStatus Load() = 0;
97 97
98 /** 98 /**
99 * Loads the system mode that this application needs.
100 * This function defaults to 2 (96MB allocated to the application) if it can't read the information.
101 * @param system_mode Out variable where the system mode will be stored.
102 * @returns ResultStatus result of the operation
103 */
104 virtual ResultStatus LoadKernelSystemMode(u32& system_mode) {
105 system_mode = 2; // 96MB allocated to the application.
106 return ResultStatus::Success;
107 }
108
109 /**
99 * Get the code (typically .code section) of the application 110 * Get the code (typically .code section) of the application
100 * @param buffer Reference to buffer to store data 111 * @param buffer Reference to buffer to store data
101 * @return ResultStatus result of function 112 * @return ResultStatus result of function
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index fadd7b16b..6fbaf4036 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -117,6 +117,14 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) {
117 return FileType::Error; 117 return FileType::Error;
118} 118}
119 119
120ResultStatus AppLoader_NCCH::LoadKernelSystemMode(u32& memory_type) {
121 ResultStatus result = LoadExeFS();
122 if (result != ResultStatus::Success)
123 return result;
124 memory_type = exheader_header.arm11_system_local_caps.system_mode;
125 return ResultStatus::Success;
126}
127
120ResultStatus AppLoader_NCCH::LoadExec() { 128ResultStatus AppLoader_NCCH::LoadExec() {
121 using Kernel::SharedPtr; 129 using Kernel::SharedPtr;
122 using Kernel::CodeSet; 130 using Kernel::CodeSet;
@@ -277,6 +285,7 @@ ResultStatus AppLoader_NCCH::LoadExeFS() {
277 LOG_DEBUG(Loader, "Core version: %d", core_version); 285 LOG_DEBUG(Loader, "Core version: %d", core_version);
278 LOG_DEBUG(Loader, "Thread priority: 0x%X", priority); 286 LOG_DEBUG(Loader, "Thread priority: 0x%X", priority);
279 LOG_DEBUG(Loader, "Resource limit category: %d", resource_limit_category); 287 LOG_DEBUG(Loader, "Resource limit category: %d", resource_limit_category);
288 LOG_DEBUG(Loader, "System Mode: %d", exheader_header.arm11_system_local_caps.system_mode);
280 289
281 if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) { 290 if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) {
282 LOG_ERROR(Loader, "ExHeader Program ID mismatch: the ROM is probably encrypted."); 291 LOG_ERROR(Loader, "ExHeader Program ID mismatch: the ROM is probably encrypted.");
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index f8718d063..63947c28e 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -186,6 +186,13 @@ public:
186 ResultStatus Load() override; 186 ResultStatus Load() override;
187 187
188 /** 188 /**
189 * Loads the Exheader and returns the system mode for this application.
190 * @param system_mode Out variable where the system mode will be stored.
191 * @return ResultStatus result of the operation
192 */
193 ResultStatus LoadKernelSystemMode(u32& system_mode);
194
195 /**
189 * Get the code (typically .code section) of the application 196 * Get the code (typically .code section) of the application
190 * @param buffer Reference to buffer to store data 197 * @param buffer Reference to buffer to store data
191 * @return ResultStatus result of function 198 * @return ResultStatus result of function