mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
Core: physical backing for flexible and pooled memory allocations (#3639)
* Fix isDevKit Previously, isDevKit could increase the physical memory used above the length we reserve in the backing file. * Physical backing for flexible allocations I took the simple approach here, creating a separate map for flexible allocations and pretty much just copying over the logic used in the direct memory map. * Various fixups * Fix mistake #1 * Assert + clang * Fix 2 * Clang * Fix CanMergeWith Validate physical base for flexible mappings * Clang * Physical backing for pooled memory * Allow VMA splitting in NameVirtualRange This should be safe, since with the changes in this PR, the only issues that come from discrepancies between address space and vma_map are issues related to vmas being larger than address space mappings. NameVirtualRange will only ever shrink VMAs by naming part of one. * Fix * Fix NameVirtualRange * Revert NameVirtualRange changes Seems like it doesn't play nice for Windows * Clean up isDevKit logic We already log both isNeo and isDevKit in Emulator::Run, so the additional logging in MemoryManager::SetupMemoryRegions isn't really necessary. I've also added a separate constant for non-pro devkit memory, as suggested. Finally I've changed a couple constants to use the ORBIS prefix we generally follow here, instead of the SCE prefix. * Erase flexible memory contents from physical memory on unmap Flexible memory should not be preserved on unmap, so erase flexible contents from the physical backing when unmapping. * Expand flexible memory map Some games will end up fragmenting the physical backing space used for flexible memory. To reduce the frequency of this happening under normal circumstances, allocate the entirety of the remaining physical backing to the flexible memory map. This is effectively a workaround to the problem, but at the moment I think this should suffice. * Clang
This commit is contained in:
@@ -326,7 +326,7 @@ u32 PS4_SYSV_ABI sceKernelIsAddressSanitizerEnabled() {
|
||||
s32 PS4_SYSV_ABI sceKernelBatchMap(OrbisKernelBatchMapEntry* entries, s32 numEntries,
|
||||
s32* numEntriesOut) {
|
||||
return sceKernelBatchMap2(entries, numEntries, numEntriesOut,
|
||||
MemoryFlags::SCE_KERNEL_MAP_FIXED); // 0x10, 0x410?
|
||||
MemoryFlags::ORBIS_KERNEL_MAP_FIXED); // 0x10, 0x410?
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, s32 numEntries,
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
#include "common/bit_field.h"
|
||||
#include "common/types.h"
|
||||
|
||||
constexpr u64 SCE_KERNEL_TOTAL_MEM = 5248_MB;
|
||||
constexpr u64 SCE_KERNEL_TOTAL_MEM_PRO = 5888_MB;
|
||||
constexpr u64 ORBIS_KERNEL_TOTAL_MEM = 5248_MB;
|
||||
constexpr u64 ORBIS_KERNEL_TOTAL_MEM_PRO = 5888_MB;
|
||||
constexpr u64 ORBIS_KERNEL_TOTAL_MEM_DEV = 6656_MB;
|
||||
// TODO: This value needs confirmation
|
||||
constexpr u64 ORBIS_KERNEL_TOTAL_MEM_DEV_PRO = 7936_MB;
|
||||
|
||||
constexpr u64 SCE_FLEXIBLE_MEMORY_BASE = 64_MB;
|
||||
constexpr u64 SCE_FLEXIBLE_MEMORY_SIZE = 512_MB;
|
||||
constexpr u64 ORBIS_FLEXIBLE_MEMORY_BASE = 64_MB;
|
||||
constexpr u64 ORBIS_FLEXIBLE_MEMORY_SIZE = 512_MB;
|
||||
|
||||
namespace Core::Loader {
|
||||
class SymbolsResolver;
|
||||
@@ -19,24 +22,24 @@ class SymbolsResolver;
|
||||
namespace Libraries::Kernel {
|
||||
|
||||
enum MemoryTypes : u32 {
|
||||
SCE_KERNEL_WB_ONION = 0, // write - back mode (Onion bus)
|
||||
SCE_KERNEL_WC_GARLIC = 3, // write - combining mode (Garlic bus)
|
||||
SCE_KERNEL_WB_GARLIC = 10 // write - back mode (Garlic bus)
|
||||
ORBIS_KERNEL_WB_ONION = 0, // write - back mode (Onion bus)
|
||||
ORBIS_KERNEL_WC_GARLIC = 3, // write - combining mode (Garlic bus)
|
||||
ORBIS_KERNEL_WB_GARLIC = 10 // write - back mode (Garlic bus)
|
||||
};
|
||||
|
||||
enum MemoryFlags : u32 {
|
||||
SCE_KERNEL_MAP_FIXED = 0x0010, // Fixed
|
||||
SCE_KERNEL_MAP_NO_OVERWRITE = 0x0080,
|
||||
SCE_KERNEL_MAP_NO_COALESCE = 0x400000
|
||||
ORBIS_KERNEL_MAP_FIXED = 0x0010, // Fixed
|
||||
ORBIS_KERNEL_MAP_NO_OVERWRITE = 0x0080,
|
||||
ORBIS_KERNEL_MAP_NO_COALESCE = 0x400000
|
||||
};
|
||||
|
||||
enum MemoryProtection : u32 {
|
||||
SCE_KERNEL_PROT_CPU_READ = 0x01, // Permit reads from the CPU
|
||||
SCE_KERNEL_PROT_CPU_RW = 0x02, // Permit reads/writes from the CPU
|
||||
SCE_KERNEL_PROT_CPU_WRITE = 0x02, // Permit reads/writes from the CPU (same)
|
||||
SCE_KERNEL_PROT_GPU_READ = 0x10, // Permit reads from the GPU
|
||||
SCE_KERNEL_PROT_GPU_WRITE = 0x20, // Permit writes from the GPU
|
||||
SCE_KERNEL_PROT_GPU_RW = 0x30 // Permit reads/writes from the GPU
|
||||
ORBIS_KERNEL_PROT_CPU_READ = 0x01, // Permit reads from the CPU
|
||||
ORBIS_KERNEL_PROT_CPU_RW = 0x02, // Permit reads/writes from the CPU
|
||||
ORBIS_KERNEL_PROT_CPU_WRITE = 0x02, // Permit reads/writes from the CPU (same)
|
||||
ORBIS_KERNEL_PROT_GPU_READ = 0x10, // Permit reads from the GPU
|
||||
ORBIS_KERNEL_PROT_GPU_WRITE = 0x20, // Permit writes from the GPU
|
||||
ORBIS_KERNEL_PROT_GPU_RW = 0x30 // Permit reads/writes from the GPU
|
||||
};
|
||||
|
||||
enum MemoryOpTypes : u32 {
|
||||
|
||||
Reference in New Issue
Block a user