mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-19 18:37:04 +02:00
extra ps4 defs
This commit is contained in:
parent
734f1e3273
commit
3f03058ebc
3 changed files with 19 additions and 34 deletions
|
|
@ -48,17 +48,6 @@
|
||||||
#ifndef MAP_ANONYMOUS
|
#ifndef MAP_ANONYMOUS
|
||||||
# define MAP_ANONYMOUS MAP_ANON
|
# define MAP_ANONYMOUS MAP_ANON
|
||||||
#endif
|
#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 ^^^
|
#endif // ^^^ POSIX ^^^
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,19 @@
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/virtual_buffer.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 {
|
namespace Common {
|
||||||
|
|
||||||
|
|
@ -22,19 +35,8 @@ void* AllocateMemoryPages(std::size_t size) noexcept {
|
||||||
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
ASSERT(addr != nullptr);
|
ASSERT(addr != nullptr);
|
||||||
#elif defined(__OPENORBIS__)
|
#elif defined(__OPENORBIS__)
|
||||||
u64 align = 16384;
|
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
void *addr = nullptr;
|
ASSERT(addr != MAP_FAILED);
|
||||||
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);
|
|
||||||
#else
|
#else
|
||||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
ASSERT(addr != MAP_FAILED);
|
ASSERT(addr != MAP_FAILED);
|
||||||
|
|
@ -47,7 +49,6 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept {
|
||||||
return;
|
return;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
VirtualFree(addr, 0, MEM_RELEASE)
|
VirtualFree(addr, 0, MEM_RELEASE)
|
||||||
#elif defined(__OPENORBIS__)
|
|
||||||
#else
|
#else
|
||||||
int rc = munmap(addr, size);
|
int rc = munmap(addr, size);
|
||||||
ASSERT(rc == 0);
|
ASSERT(rc == 0);
|
||||||
|
|
|
||||||
|
|
@ -26,27 +26,22 @@ public:
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Common::PhysicalAddress GetPhysicalAddr(const T* ptr) const {
|
Common::PhysicalAddress GetPhysicalAddr(const T* ptr) const {
|
||||||
return (reinterpret_cast<uintptr_t>(ptr) -
|
return (uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())) + DramMemoryMap::Base;
|
||||||
reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) +
|
|
||||||
DramMemoryMap::Base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PAddr GetRawPhysicalAddr(const T* ptr) const {
|
PAddr GetRawPhysicalAddr(const T* ptr) const {
|
||||||
return static_cast<PAddr>(reinterpret_cast<uintptr_t>(ptr) -
|
return PAddr(uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer()));
|
||||||
reinterpret_cast<uintptr_t>(buffer.BackingBasePointer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* GetPointer(Common::PhysicalAddress addr) {
|
T* GetPointer(Common::PhysicalAddress addr) {
|
||||||
return reinterpret_cast<T*>(buffer.BackingBasePointer() +
|
return reinterpret_cast<T*>(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base));
|
||||||
(GetInteger(addr) - DramMemoryMap::Base));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T* GetPointer(Common::PhysicalAddress addr) const {
|
const T* GetPointer(Common::PhysicalAddress addr) const {
|
||||||
return reinterpret_cast<T*>(buffer.BackingBasePointer() +
|
return reinterpret_cast<T*>(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base));
|
||||||
(GetInteger(addr) - DramMemoryMap::Base));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue