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 | 11 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 9 | ||||
| -rw-r--r-- | src/core/loader/ncch.h | 7 | ||||
| -rw-r--r-- | src/core/system.cpp | 4 | ||||
| -rw-r--r-- | src/core/system.h | 2 |
7 files changed, 34 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..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 | ||
| 120 | ResultStatus 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 | |||
| 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,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 |
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 | } |