core: Add support for N3DS memory mappings (#5103)

* core: Add support for N3DS memory mappings

* Address review comments
This commit is contained in:
Tobias 2020-02-29 19:48:27 +01:00 committed by GitHub
parent ab8cb17ab7
commit 6d3d9f7a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 69 additions and 22 deletions

View file

@ -105,13 +105,22 @@ public:
* Loads the system mode that this application needs.
* This function defaults to 2 (96MB allocated to the application) if it can't read the
* information.
* @returns A pair with the optional system mode, and and the status.
* @returns A pair with the optional system mode, and the status.
*/
virtual std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() {
// 96MB allocated to the application.
return std::make_pair(2, ResultStatus::Success);
}
/**
* Loads the N3ds mode that this application uses.
* It defaults to 0 (O3DS default) if it can't read the information.
* @returns A pair with the optional N3ds mode, and the status.
*/
virtual std::pair<std::optional<u8>, ResultStatus> LoadKernelN3dsMode() {
return std::make_pair(0, ResultStatus::Success);
}
/**
* Get whether this application is executable.
* @param out_executable Reference to store the executable flag into.

View file

@ -61,6 +61,19 @@ std::pair<std::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode
ResultStatus::Success);
}
std::pair<std::optional<u8>, ResultStatus> AppLoader_NCCH::LoadKernelN3dsMode() {
if (!is_loaded) {
ResultStatus res = base_ncch.Load();
if (res != ResultStatus::Success) {
return std::make_pair(std::optional<u8>{}, res);
}
}
// Set the system mode as the one from the exheader.
return std::make_pair(overlay_ncch->exheader_header.arm11_system_local_caps.n3ds_mode,
ResultStatus::Success);
}
ResultStatus AppLoader_NCCH::LoadExec(std::shared_ptr<Kernel::Process>& process) {
using Kernel::CodeSet;

View file

@ -41,6 +41,8 @@ public:
*/
std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
std::pair<std::optional<u8>, ResultStatus> LoadKernelN3dsMode() override;
ResultStatus IsExecutable(bool& out_executable) override;
ResultStatus ReadCode(std::vector<u8>& buffer) override;