summaryrefslogtreecommitdiff
path: root/src/core/loader
diff options
context:
space:
mode:
authorGravatar Subv2016-11-26 23:13:40 -0500
committerGravatar Subv2016-11-27 18:03:48 -0500
commitd171409f29ce3d8bcf7ed6ce16392b4b4ec97c4b (patch)
tree25b4b0c9fd1f316812c3eb74310b9a31f872a4f5 /src/core/loader
parentKernel/Loader: Grab the system mode from the NCCH ExHeader. (diff)
downloadyuzu-d171409f29ce3d8bcf7ed6ce16392b4b4ec97c4b.tar.gz
yuzu-d171409f29ce3d8bcf7ed6ce16392b4b4ec97c4b.tar.xz
yuzu-d171409f29ce3d8bcf7ed6ce16392b4b4ec97c4b.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.h13
-rw-r--r--src/core/loader/ncch.cpp15
-rw-r--r--src/core/loader/ncch.h5
3 files changed, 17 insertions, 16 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index e62f77b9c..5e3d46638 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -9,6 +9,7 @@
9#include <memory> 9#include <memory>
10#include <string> 10#include <string>
11#include <vector> 11#include <vector>
12#include <boost/optional.hpp>
12#include "common/common_types.h" 13#include "common/common_types.h"
13#include "common/file_util.h" 14#include "common/file_util.h"
14 15
@@ -97,13 +98,13 @@ public:
97 98
98 /** 99 /**
99 * Loads the system mode that this application needs. 100 * 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 * This function defaults to 2 (96MB allocated to the application) if it can't read the
101 * @param system_mode Out variable where the system mode will be stored. 102 * information.
102 * @returns ResultStatus result of the operation 103 * @returns Optional with the kernel system mode
103 */ 104 */
104 virtual ResultStatus LoadKernelSystemMode(u32& system_mode) { 105 virtual boost::optional<u32> LoadKernelSystemMode() {
105 system_mode = 2; // 96MB allocated to the application. 106 // 96MB allocated to the application.
106 return ResultStatus::Success; 107 return 2;
107 } 108 }
108 109
109 /** 110 /**
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 6fbaf4036..d4be61e0e 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -117,12 +117,12 @@ 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) { 120boost::optional<u32> AppLoader_NCCH::LoadKernelSystemMode() {
121 ResultStatus result = LoadExeFS(); 121 if (!is_loaded) {
122 if (result != ResultStatus::Success) 122 if (LoadExeFS() != ResultStatus::Success)
123 return result; 123 return boost::none;
124 memory_type = exheader_header.arm11_system_local_caps.system_mode; 124 }
125 return ResultStatus::Success; 125 return exheader_header.arm11_system_local_caps.system_mode.Value();
126} 126}
127 127
128ResultStatus AppLoader_NCCH::LoadExec() { 128ResultStatus AppLoader_NCCH::LoadExec() {
@@ -285,7 +285,8 @@ ResultStatus AppLoader_NCCH::LoadExeFS() {
285 LOG_DEBUG(Loader, "Core version: %d", core_version); 285 LOG_DEBUG(Loader, "Core version: %d", core_version);
286 LOG_DEBUG(Loader, "Thread priority: 0x%X", priority); 286 LOG_DEBUG(Loader, "Thread priority: 0x%X", priority);
287 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); 288 LOG_DEBUG(Loader, "System Mode: %d",
289 exheader_header.arm11_system_local_caps.system_mode);
289 290
290 if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) { 291 if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) {
291 LOG_ERROR(Loader, "ExHeader Program ID mismatch: the ROM is probably encrypted."); 292 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 63947c28e..bcf3ae6e3 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -187,10 +187,9 @@ public:
187 187
188 /** 188 /**
189 * Loads the Exheader and returns the system mode for this application. 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. 190 * @return Optional with the kernel system mode
191 * @return ResultStatus result of the operation
192 */ 191 */
193 ResultStatus LoadKernelSystemMode(u32& system_mode); 192 boost::optional<u32> LoadKernelSystemMode();
194 193
195 /** 194 /**
196 * Get the code (typically .code section) of the application 195 * Get the code (typically .code section) of the application