Implement plugin loader Mode3 mem strategy (#7)
This commit is contained in:
@@ -117,6 +117,14 @@ public:
|
||||
return std::make_pair(0x2, ResultStatus::Success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the application memory mode to the specified value,
|
||||
* overriding the memory mode specified in the metadata.
|
||||
*/
|
||||
void SetKernelMemoryModeOverride(Kernel::MemoryMode mem_override) {
|
||||
memory_mode_override = mem_override;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the memory mode that this application needs.
|
||||
* This function defaults to Dev1 (96MB allocated to the application) if it can't read the
|
||||
@@ -124,6 +132,9 @@ public:
|
||||
* @returns A pair with the optional memory mode, and the status.
|
||||
*/
|
||||
virtual std::pair<std::optional<Kernel::MemoryMode>, ResultStatus> LoadKernelMemoryMode() {
|
||||
if (memory_mode_override.has_value()) {
|
||||
return std::make_pair(*memory_mode_override, ResultStatus::Success);
|
||||
}
|
||||
// 96MB allocated to the application.
|
||||
return std::make_pair(Kernel::MemoryMode::Dev1, ResultStatus::Success);
|
||||
}
|
||||
@@ -257,6 +268,7 @@ protected:
|
||||
Core::System& system;
|
||||
FileUtil::IOFile file;
|
||||
bool is_loaded = false;
|
||||
std::optional<Kernel::MemoryMode> memory_mode_override = std::nullopt;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,6 +69,9 @@ std::pair<std::optional<Kernel::MemoryMode>, ResultStatus> AppLoader_NCCH::LoadK
|
||||
return std::make_pair(std::nullopt, res);
|
||||
}
|
||||
}
|
||||
if (memory_mode_override.has_value()) {
|
||||
return std::make_pair(memory_mode_override, ResultStatus::Success);
|
||||
}
|
||||
|
||||
// Provide the memory mode from the exheader.
|
||||
auto& ncch_caps = overlay_ncch->exheader_header.arm11_system_local_caps;
|
||||
@@ -159,7 +162,7 @@ ResultStatus AppLoader_NCCH::LoadExec(std::shared_ptr<Kernel::Process>& process)
|
||||
// APPLICATION. See:
|
||||
// https://github.com/LumaTeam/Luma3DS/blob/e2778a45/sysmodules/pm/source/launch.c#L237
|
||||
auto& ncch_caps = overlay_ncch->exheader_header.arm11_system_local_caps;
|
||||
const auto o3ds_mode = static_cast<Kernel::MemoryMode>(ncch_caps.system_mode.Value());
|
||||
const auto o3ds_mode = *LoadKernelMemoryMode().first;
|
||||
const auto n3ds_mode = static_cast<Kernel::New3dsMemoryMode>(ncch_caps.n3ds_mode);
|
||||
const bool is_new_3ds = Settings::values.is_new_3ds.GetValue();
|
||||
if (is_new_3ds && n3ds_mode == Kernel::New3dsMemoryMode::Legacy &&
|
||||
|
||||
Reference in New Issue
Block a user