memory: Fixes for direct memory allocation. (#615)

* memory: Size direct memory based on requested flexible memory.

* memory: Guard against OrbisProcParam without an OrbisKernelMemParam.

* memory: Account for alignment in direct memory suitability checks and add more debugging.
This commit is contained in:
squidbus 2024-08-28 03:42:53 -07:00 committed by GitHub
parent dcc4762c7e
commit 905d49fd96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 22 deletions

View file

@ -68,11 +68,19 @@ void Linker::Execute() {
}
// Configure used flexible memory size.
// if (auto* mem_param = GetProcParam()->mem_param) {
// if (u64* flexible_size = mem_param->flexible_memory_size) {
// memory->SetTotalFlexibleSize(*flexible_size);
// }
// }
if (const auto* proc_param = GetProcParam()) {
if (proc_param->size >=
offsetof(OrbisProcParam, mem_param) + sizeof(OrbisKernelMemParam*)) {
if (const auto* mem_param = proc_param->mem_param) {
if (mem_param->size >=
offsetof(OrbisKernelMemParam, flexible_memory_size) + sizeof(u64*)) {
if (const auto* flexible_size = mem_param->flexible_memory_size) {
memory->SetupMemoryRegions(*flexible_size);
}
}
}
}
}
// Init primary thread.
Common::SetCurrentThreadName("GAME_MainThread");