Adding 1.5 * memory same as Ps4 allocates when asking for more ram

This commit is contained in:
Dmugetsu 2025-03-07 17:32:34 -06:00
parent 703fe8410e
commit d69b6758fe
4 changed files with 21 additions and 23 deletions

View File

@ -276,7 +276,7 @@ int PS4_SYSV_ABI sceKernelDirectMemoryQuery(u64 offset, int flags, OrbisQueryInf
s32 PS4_SYSV_ABI sceKernelAvailableFlexibleMemorySize(size_t* out_size) {
auto* memory = Core::Memory::Instance();
*out_size = memory->GetTotalUnifiedMemorySize();
*out_size = memory->GetAvailableUnifiedMemorySize();
LOG_INFO(Kernel_Vmm, "called size = {:#x}", *out_size);
return ORBIS_OK;
}

View File

@ -5,17 +5,14 @@
#include "common/bit_field.h"
#include "common/types.h"
#include "core/linker.h"
#include "core/memory.h"
#include "src/common/memory_patcher.h"
constexpr bool USE_EXPANDED_MEMORY = true;
constexpr bool USE_EXPANDED_MEMORY = false;
constexpr u64 SCE_KERNEL_TOTAL_MEM = (USE_EXPANDED_MEMORY ? 5248_MB * 1.2 : 5248_MB);
constexpr u64 SCE_KERNEL_TOTAL_MEM_PRO = (USE_EXPANDED_MEMORY ? 5888_MB * 1.2 : 5888_MB);
constexpr u64 SCE_KERNEL_TOTAL_MEM = 5248_MB;
constexpr u64 SCE_KERNEL_TOTAL_MEM_PRO = (USE_EXPANDED_MEMORY ? 5888_MB * 1.5 : 5888_MB);
constexpr u64 SCE_FLEXIBLE_MEMORY_BASE = (USE_EXPANDED_MEMORY ? 64_MB * 1.2 : 64_MB);
constexpr u64 SCE_FLEXIBLE_MEMORY_SIZE = (USE_EXPANDED_MEMORY ? 512_MB * 1.2 : 512_MB);
constexpr u64 SCE_FLEXIBLE_MEMORY_BASE = 64_MB;
constexpr u64 SCE_FLEXIBLE_MEMORY_SIZE = (USE_EXPANDED_MEMORY ? 512_MB * 1.5 : 512_MB);
namespace Core::Loader {
class SymbolsResolver;

View File

@ -37,23 +37,14 @@ MemoryManager::~MemoryManager() = default;
void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1,
bool use_extended_mem2) {
const bool is_neo = ::Libraries::Kernel::sceKernelIsNeoMode();
auto total_size = is_neo ? SCE_KERNEL_TOTAL_MEM_PRO : SCE_KERNEL_TOTAL_MEM;
if (NeedsExtraMemory()) {
total_size = SCE_KERNEL_TOTAL_MEM * 1.2;
}
if (!use_extended_mem1 && is_neo) {
total_size -= 256_MB;
}
if (!use_extended_mem2 && !is_neo) {
total_size -= 128_MB;
}
total_flexible_size = flexible_size - SCE_FLEXIBLE_MEMORY_BASE;
if (NeedsExtraMemory()) {
total_flexible_size = flexible_size - SCE_FLEXIBLE_MEMORY_BASE * 1.2;
}
total_direct_size = total_size - flexible_size;
// Insert an area that covers direct memory physical block.

View File

@ -164,12 +164,22 @@ public:
return virtual_addr >= vma_map.begin()->first && virtual_addr < end_addr;
}
bool NeedsExtraMemory() {
static const std::unordered_set<std::string> extra_memory_games = {
"CUSA28615", // Example game that needs extra memory
"CUSA03173" // Add other games here if needed
};
if (IsNeoModeEnabled()) {
bool USE_EXPANDED_MEMORY = false;
return true;
}
return false;
}
return extra_memory_games.find(MemoryPatcher::g_game_serial) != extra_memory_games.end();
bool IsNeoModeEnabled() {
return (getSystemMemoryFlag() == SCE_KERNEL_TOTAL_MEM_PRO);
}
uint64_t getSystemMemoryFlag() {
if (USE_EXPANDED_MEMORY) {
return SCE_KERNEL_TOTAL_MEM_PRO; // Expanded memory
}
return SCE_KERNEL_TOTAL_MEM; // Regular memory
}
u64 ClampRangeSize(VAddr virtual_addr, u64 size);