mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Calling Memory expansion when a game needs it
This commit is contained in:
parent
8b7eed3ffc
commit
5c87aa346b
@ -15,6 +15,7 @@
|
|||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/linker.h"
|
#include "core/linker.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
#include "src/common/memory_patcher.h"
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
|
||||||
@ -26,6 +27,17 @@ u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize() {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
||||||
u64 alignment, int memoryType, s64* physAddrOut) {
|
u64 alignment, int memoryType, s64* physAddrOut) {
|
||||||
|
auto* memory = Core::Memory::Instance();
|
||||||
|
|
||||||
|
if (memory->NeedsExtraMemory()) {
|
||||||
|
LOG_INFO(Kernel_Vmm, "Game '{}' requires extra memory, applying expanded allocation.",
|
||||||
|
MemoryPatcher::g_game_serial);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LOG_INFO(Kernel_Vmm, "Game '{}' using standard memory allocation.",
|
||||||
|
MemoryPatcher::g_game_serial);
|
||||||
|
}
|
||||||
|
|
||||||
if (searchStart < 0 || searchEnd < 0) {
|
if (searchStart < 0 || searchEnd < 0) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Invalid parameters!");
|
LOG_ERROR(Kernel_Vmm, "Invalid parameters!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
@ -56,7 +68,6 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
|||||||
return ORBIS_KERNEL_ERROR_EAGAIN;
|
return ORBIS_KERNEL_ERROR_EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* memory = Core::Memory::Instance();
|
|
||||||
PAddr phys_addr = memory->Allocate(searchStart, searchEnd, len, alignment, memoryType);
|
PAddr phys_addr = memory->Allocate(searchStart, searchEnd, len, alignment, memoryType);
|
||||||
if (phys_addr == -1) {
|
if (phys_addr == -1) {
|
||||||
return ORBIS_KERNEL_ERROR_EAGAIN;
|
return ORBIS_KERNEL_ERROR_EAGAIN;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
constexpr u64 SCE_KERNEL_TOTAL_MEM = 5248_MB;
|
constexpr u64 SCE_KERNEL_TOTAL_MEM = 5248_MB * 4;
|
||||||
constexpr u64 SCE_KERNEL_TOTAL_MEM_PRO = 5888_MB;
|
constexpr u64 SCE_KERNEL_TOTAL_MEM_PRO = 5888_MB * 4;
|
||||||
|
|
||||||
constexpr u64 SCE_FLEXIBLE_MEMORY_BASE = 64_MB;
|
constexpr u64 SCE_FLEXIBLE_MEMORY_BASE = 64_MB;
|
||||||
constexpr u64 SCE_FLEXIBLE_MEMORY_SIZE = 512_MB;
|
constexpr u64 SCE_FLEXIBLE_MEMORY_SIZE = 512_MB;
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include "common/enum.h"
|
#include "common/enum.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/address_space.h"
|
#include "core/address_space.h"
|
||||||
#include "core/libraries/kernel/memory.h"
|
#include "core/libraries/kernel/memory.h"
|
||||||
|
#include "src/common/memory_patcher.h"
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
class Rasterizer;
|
class Rasterizer;
|
||||||
@ -163,6 +166,13 @@ public:
|
|||||||
const VAddr end_addr = end_it->first + end_it->second.size;
|
const VAddr end_addr = end_it->first + end_it->second.size;
|
||||||
return virtual_addr >= vma_map.begin()->first && virtual_addr < end_addr;
|
return virtual_addr >= vma_map.begin()->first && virtual_addr < end_addr;
|
||||||
}
|
}
|
||||||
|
bool NeedsExtraMemory() {
|
||||||
|
static const std::unordered_set<std::string> extra_memory_games = {
|
||||||
|
// here should be games with needs of extra memory as EXAMPLE
|
||||||
|
"CUSA03173"};
|
||||||
|
|
||||||
|
return extra_memory_games.find(MemoryPatcher::g_game_serial) != extra_memory_games.end();
|
||||||
|
}
|
||||||
|
|
||||||
u64 ClampRangeSize(VAddr virtual_addr, u64 size);
|
u64 ClampRangeSize(VAddr virtual_addr, u64 size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user