mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-31 15:53:17 +00:00
core: better memory configuration (#1896)
This commit is contained in:
parent
55f78a0b94
commit
817a62468e
7 changed files with 55 additions and 32 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "common/arch.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/config.h"
|
||||
#include "common/elf_info.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/path_util.h"
|
||||
#include "common/string_util.h"
|
||||
|
@ -65,21 +66,41 @@ void Linker::Execute() {
|
|||
Relocate(m.get());
|
||||
}
|
||||
|
||||
// Configure used flexible memory 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);
|
||||
}
|
||||
// Configure the direct and flexible memory regions.
|
||||
u64 fmem_size = SCE_FLEXIBLE_MEMORY_SIZE;
|
||||
bool use_extended_mem1 = true, use_extended_mem2 = true;
|
||||
|
||||
const auto* proc_param = GetProcParam();
|
||||
ASSERT(proc_param);
|
||||
|
||||
Core::OrbisKernelMemParam mem_param{};
|
||||
if (proc_param->size >= offsetof(OrbisProcParam, mem_param) + sizeof(OrbisKernelMemParam*)) {
|
||||
if (proc_param->mem_param) {
|
||||
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) {
|
||||
fmem_size = *flexible_size + SCE_FLEXIBLE_MEMORY_BASE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mem_param.size < offsetof(OrbisKernelMemParam, extended_memory_1) + sizeof(u64*)) {
|
||||
mem_param.extended_memory_1 = nullptr;
|
||||
}
|
||||
if (mem_param.size < offsetof(OrbisKernelMemParam, extended_memory_2) + sizeof(u64*)) {
|
||||
mem_param.extended_memory_2 = nullptr;
|
||||
}
|
||||
|
||||
const u64 sdk_ver = proc_param->sdk_version;
|
||||
if (sdk_ver < Common::ElfInfo::FW_50) {
|
||||
use_extended_mem1 = mem_param.extended_memory_1 ? *mem_param.extended_memory_1 : false;
|
||||
use_extended_mem2 = mem_param.extended_memory_2 ? *mem_param.extended_memory_2 : false;
|
||||
}
|
||||
|
||||
memory->SetupMemoryRegions(fmem_size, use_extended_mem1, use_extended_mem2);
|
||||
|
||||
main_thread.Run([this, module](std::stop_token) {
|
||||
Common::SetCurrentThreadName("GAME_MainThread");
|
||||
LoadSharedLibraries();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue