diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 4 | ||||
| -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 | ||||
| -rw-r--r-- | src/core/system.cpp | 4 | ||||
| -rw-r--r-- | src/core/system.h | 2 |
7 files changed, 35 insertions, 9 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 9e1795927..0c8752670 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -124,13 +124,11 @@ void HandleTable::Clear() { | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | /// Initialize the kernel | 126 | /// Initialize the kernel |
| 127 | void Init() { | 127 | void Init(u32 system_mode) { |
| 128 | ConfigMem::Init(); | 128 | ConfigMem::Init(); |
| 129 | SharedPage::Init(); | 129 | SharedPage::Init(); |
| 130 | 130 | ||
| 131 | // TODO(yuriks): The memory type parameter needs to be determined by the ExHeader field instead | 131 | Kernel::MemoryInit(system_mode); |
| 132 | // For now it defaults to the one with a largest allocation to the app | ||
| 133 | Kernel::MemoryInit(2); // Allocates 96MB to the application | ||
| 134 | 132 | ||
| 135 | Kernel::ResourceLimitsInit(); | 133 | Kernel::ResourceLimitsInit(); |
| 136 | Kernel::ThreadingInit(); | 134 | Kernel::ThreadingInit(); |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 6b8dbecff..231cf7b75 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -286,8 +286,8 @@ private: | |||
| 286 | 286 | ||
| 287 | extern HandleTable g_handle_table; | 287 | extern HandleTable g_handle_table; |
| 288 | 288 | ||
| 289 | /// Initialize the kernel | 289 | /// Initialize the kernel with the specified system mode. |
| 290 | void Init(); | 290 | void Init(u32 system_mode); |
| 291 | 291 | ||
| 292 | /// Shutdown the kernel | 292 | /// Shutdown the kernel |
| 293 | void Shutdown(); | 293 | void Shutdown(); |
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 |
diff --git a/src/core/system.cpp b/src/core/system.cpp index 7d54811a0..a5f763805 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp | |||
| @@ -17,12 +17,12 @@ namespace System { | |||
| 17 | 17 | ||
| 18 | static bool is_powered_on{false}; | 18 | static bool is_powered_on{false}; |
| 19 | 19 | ||
| 20 | Result Init(EmuWindow* emu_window) { | 20 | Result Init(EmuWindow* emu_window, u32 system_mode) { |
| 21 | Core::Init(); | 21 | Core::Init(); |
| 22 | CoreTiming::Init(); | 22 | CoreTiming::Init(); |
| 23 | Memory::Init(); | 23 | Memory::Init(); |
| 24 | HW::Init(); | 24 | HW::Init(); |
| 25 | Kernel::Init(); | 25 | Kernel::Init(system_mode); |
| 26 | HLE::Init(); | 26 | HLE::Init(); |
| 27 | if (!VideoCore::Init(emu_window)) { | 27 | if (!VideoCore::Init(emu_window)) { |
| 28 | return Result::ErrorInitVideoCore; | 28 | return Result::ErrorInitVideoCore; |
diff --git a/src/core/system.h b/src/core/system.h index 6d672b1b5..b41fc088a 100644 --- a/src/core/system.h +++ b/src/core/system.h | |||
| @@ -15,7 +15,7 @@ enum class Result { | |||
| 15 | ErrorInitVideoCore, ///< Something went wrong during video core init | 15 | ErrorInitVideoCore, ///< Something went wrong during video core init |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | Result Init(EmuWindow* emu_window); | 18 | Result Init(EmuWindow* emu_window, u32 system_mode); |
| 19 | bool IsPoweredOn(); | 19 | bool IsPoweredOn(); |
| 20 | void Shutdown(); | 20 | void Shutdown(); |
| 21 | } | 21 | } |