diff options
| author | 2016-11-27 17:04:11 -0800 | |
|---|---|---|
| committer | 2016-11-27 17:04:11 -0800 | |
| commit | 3174bfd50c69dfa523671b96448113996a0bc42c (patch) | |
| tree | 89575620a506d18c6fea2f8570c09bc0e9864263 /src/core/loader | |
| parent | Merge pull request #2222 from linkmauve/die-frameskip-die (diff) | |
| parent | Kernel/Loader: Grab the system mode from the NCCH ExHeader. (diff) | |
| download | yuzu-3174bfd50c69dfa523671b96448113996a0bc42c.tar.gz yuzu-3174bfd50c69dfa523671b96448113996a0bc42c.tar.xz yuzu-3174bfd50c69dfa523671b96448113996a0bc42c.zip | |
Merge pull request #2196 from Subv/system_mode
Kernel/Loader: Grab the system mode from the NCCH ExHeader.
Diffstat (limited to 'src/core/loader')
| -rw-r--r-- | src/core/loader/loader.h | 12 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 10 | ||||
| -rw-r--r-- | src/core/loader/ncch.h | 6 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 9652d7ac5..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 | ||
| @@ -96,6 +97,17 @@ public: | |||
| 96 | virtual ResultStatus Load() = 0; | 97 | virtual ResultStatus Load() = 0; |
| 97 | 98 | ||
| 98 | /** | 99 | /** |
| 100 | * Loads the system mode that this application needs. | ||
| 101 | * This function defaults to 2 (96MB allocated to the application) if it can't read the | ||
| 102 | * information. | ||
| 103 | * @returns Optional with the kernel system mode | ||
| 104 | */ | ||
| 105 | virtual boost::optional<u32> LoadKernelSystemMode() { | ||
| 106 | // 96MB allocated to the application. | ||
| 107 | return 2; | ||
| 108 | } | ||
| 109 | |||
| 110 | /** | ||
| 99 | * Get the code (typically .code section) of the application | 111 | * Get the code (typically .code section) of the application |
| 100 | * @param buffer Reference to buffer to store data | 112 | * @param buffer Reference to buffer to store data |
| 101 | * @return ResultStatus result of function | 113 | * @return ResultStatus result of function |
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index fadd7b16b..d4be61e0e 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 | ||
| 120 | boost::optional<u32> AppLoader_NCCH::LoadKernelSystemMode() { | ||
| 121 | if (!is_loaded) { | ||
| 122 | if (LoadExeFS() != ResultStatus::Success) | ||
| 123 | return boost::none; | ||
| 124 | } | ||
| 125 | return exheader_header.arm11_system_local_caps.system_mode.Value(); | ||
| 126 | } | ||
| 127 | |||
| 120 | ResultStatus AppLoader_NCCH::LoadExec() { | 128 | ResultStatus AppLoader_NCCH::LoadExec() { |
| 121 | using Kernel::SharedPtr; | 129 | using Kernel::SharedPtr; |
| 122 | using Kernel::CodeSet; | 130 | using Kernel::CodeSet; |
| @@ -277,6 +285,8 @@ 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", | ||
| 289 | exheader_header.arm11_system_local_caps.system_mode); | ||
| 280 | 290 | ||
| 281 | 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) { |
| 282 | 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 f8718d063..bcf3ae6e3 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h | |||
| @@ -186,6 +186,12 @@ 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 | * @return Optional with the kernel system mode | ||
| 191 | */ | ||
| 192 | boost::optional<u32> LoadKernelSystemMode(); | ||
| 193 | |||
| 194 | /** | ||
| 189 | * Get the code (typically .code section) of the application | 195 | * Get the code (typically .code section) of the application |
| 190 | * @param buffer Reference to buffer to store data | 196 | * @param buffer Reference to buffer to store data |
| 191 | * @return ResultStatus result of function | 197 | * @return ResultStatus result of function |