From 8b78cc1dece8fdbdda2b8f214f5b259989c26e1e Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 3 Aug 2023 14:18:55 +0300 Subject: [PATCH] initial work on sceKernelMapDirectMemory --- src/Core/PS4/HLE/Kernel/memory_management.cpp | 7 +++++++ src/Core/PS4/HLE/Kernel/memory_management.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Core/PS4/HLE/Kernel/memory_management.cpp b/src/Core/PS4/HLE/Kernel/memory_management.cpp index f22c94f4..37530ab9 100644 --- a/src/Core/PS4/HLE/Kernel/memory_management.cpp +++ b/src/Core/PS4/HLE/Kernel/memory_management.cpp @@ -64,7 +64,14 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u } int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int flags, s64 directMemoryStart, u64 alignment) { + PRINT_FUNCTION_NAME(); auto* physical_memory = Singleton::Instance(); + LOG_INFO_IF(log_file_memory, "len = {}\n", log_hex_full(len)); + LOG_INFO_IF(log_file_memory, "prot = {}\n", log_hex_full(prot)); + LOG_INFO_IF(log_file_memory, "flags = {}\n", log_hex_full(flags)); + LOG_INFO_IF(log_file_memory, "directMemoryStart = {}\n", log_hex_full(directMemoryStart)); + LOG_INFO_IF(log_file_memory, "alignment = {}\n", log_hex_full(alignment)); + BREAKPOINT(); return SCE_OK; } diff --git a/src/Core/PS4/HLE/Kernel/memory_management.h b/src/Core/PS4/HLE/Kernel/memory_management.h index bab7acf3..0fe55024 100644 --- a/src/Core/PS4/HLE/Kernel/memory_management.h +++ b/src/Core/PS4/HLE/Kernel/memory_management.h @@ -14,6 +14,20 @@ enum MemoryTypes : u32 { SCE_KERNEL_WB_GARLIC = 10 // write - back mode (Garlic bus) }; +enum MemoryFlags : u32 { + NOT_SPECIFIED = 0, // not in SCE but it is a possible value (aligned memory) + SCE_KERNEL_MAP_FIXED = 0x0010, // Fixed + SCE_KERNEL_MAP_NO_OVERWRITE = 0x0080, + SCE_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 +}; namespace HLE::Libs::LibKernel::MemoryManagement { u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize();