From 0f6d9f703a2a5c7053a7580e38772144507f3386 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 21:29:18 +0000 Subject: [PATCH] extra ps4 defs --- src/common/host_memory.cpp | 11 ----------- src/common/virtual_buffer.cpp | 29 +++++++++++++++-------------- src/core/device_memory.h | 13 ++++--------- src/core/device_memory_manager.inc | 2 +- 4 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 3c66e4309f..aec9a5c8e0 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -46,17 +46,6 @@ #ifndef MAP_ANONYMOUS # define MAP_ANONYMOUS MAP_ANON #endif -// PlayStation 4 -// Flag needs to be undef-ed on non PS4 since it has different semantics -// on some platforms. -#ifndef MAP_SYSTEM -# ifdef __OPENORBIS__ -# define MAP_SYSTEM 0x2000 -# else -# undef MAP_SYSTEM -# define MAP_SYSTEM 0 -# endif -#endif #endif // ^^^ POSIX ^^^ diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index ef9113c557..1d4929d233 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -14,6 +14,19 @@ #include "common/assert.h" #include "common/virtual_buffer.h" +#include "common/logging/log.h" + +// PlayStation 4 +// Flag needs to be undef-ed on non PS4 since it has different semantics +// on some platforms. +#ifdef __OPENORBIS__ +# ifndef MAP_SYSTEM +# define MAP_SYSTEM 0x2000 +# endif +# ifndef MAP_VOID +# define MAP_VOID 0x100 +# endif +#endif namespace Common { @@ -22,19 +35,8 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - u64 align = 16384; - void *addr = nullptr; - off_t direct_mem_off; - int32_t rc; - if ((rc = sceKernelAllocateDirectMemory(0, sceKernelGetDirectMemorySize(), size, align, 3, &direct_mem_off)) < 0) { - ASSERT(false && "sceKernelAllocateDirectMemory"); - return nullptr; - } - if ((rc = sceKernelMapDirectMemory(&addr, size, 0x33, 0, direct_mem_off, align)) < 0) { - ASSERT(false && "sceKernelMapDirectMemory"); - return nullptr; - } - ASSERT(addr != nullptr); + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + ASSERT(addr != MAP_FAILED); #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); @@ -47,7 +49,6 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { return; #ifdef _WIN32 VirtualFree(addr, 0, MEM_RELEASE) -#elif defined(__OPENORBIS__) #else int rc = munmap(addr, size); ASSERT(rc == 0); diff --git a/src/core/device_memory.h b/src/core/device_memory.h index 11bf0e3268..b96717871c 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h @@ -26,27 +26,22 @@ public: template Common::PhysicalAddress GetPhysicalAddr(const T* ptr) const { - return (reinterpret_cast(ptr) - - reinterpret_cast(buffer.BackingBasePointer())) + - DramMemoryMap::Base; + return (uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())) + DramMemoryMap::Base; } template PAddr GetRawPhysicalAddr(const T* ptr) const { - return static_cast(reinterpret_cast(ptr) - - reinterpret_cast(buffer.BackingBasePointer())); + return PAddr(uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())); } template T* GetPointer(Common::PhysicalAddress addr) { - return reinterpret_cast(buffer.BackingBasePointer() + - (GetInteger(addr) - DramMemoryMap::Base)); + return reinterpret_cast(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base)); } template const T* GetPointer(Common::PhysicalAddress addr) const { - return reinterpret_cast(buffer.BackingBasePointer() + - (GetInteger(addr) - DramMemoryMap::Base)); + return reinterpret_cast(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base)); } template diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index 52dff5df9a..1a039d90f1 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -161,7 +161,7 @@ struct DeviceMemoryManagerAllocator { template DeviceMemoryManager::DeviceMemoryManager(const DeviceMemory& device_memory_) - : physical_base{reinterpret_cast(device_memory_.buffer.BackingBasePointer())}, + : physical_base{uintptr_t(device_memory_.buffer.BackingBasePointer())}, device_inter{nullptr}, compressed_physical_ptr(device_as_size >> Memory::YUZU_PAGEBITS), compressed_device_addr(1ULL << ((Settings::values.memory_layout_mode.GetValue() == Settings::MemoryLayout::Memory_4Gb