mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 03:32:55 +00:00
Small fix
This commit is contained in:
parent
267de68441
commit
ba83767706
@ -48,7 +48,7 @@ void MemoryBase::Init(MemoryType type)
|
||||
|
||||
memset(RawSPUMem, 0, sizeof(RawSPUMem));
|
||||
|
||||
LOG_NOTICE(MEMORY, "Initializing memory: base_addr = 0x%llx, priv_addr = 0x%llx", (u64)vm::g_base_addr, (u64)vm::g_priv_addr);
|
||||
LOG_NOTICE(MEMORY, "Initializing memory: g_base_addr = 0x%llx, g_priv_addr = 0x%llx", (u64)vm::g_base_addr, (u64)vm::g_priv_addr);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (!vm::g_base_addr || !vm::g_priv_addr)
|
||||
|
@ -22,11 +22,6 @@ enum : u32
|
||||
RAW_SPU_PROB_OFFSET = 0x00040000,
|
||||
};
|
||||
|
||||
namespace vm
|
||||
{
|
||||
extern void* const g_base_addr;
|
||||
}
|
||||
|
||||
class MemoryBase
|
||||
{
|
||||
std::vector<MemoryBlock*> MemoryBlocks;
|
||||
|
@ -25,35 +25,32 @@
|
||||
|
||||
namespace vm
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE g_memory_handle;
|
||||
#endif
|
||||
|
||||
void* g_priv_addr;
|
||||
|
||||
void* initialize()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
g_memory_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_RESERVE, 0x1, 0x0, NULL);
|
||||
HANDLE memory_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_RESERVE, 0x1, 0x0, NULL);
|
||||
|
||||
void* base_addr = MapViewOfFile(g_memory_handle, FILE_MAP_WRITE, 0, 0, 0x100000000); // main memory
|
||||
g_priv_addr = MapViewOfFile(g_memory_handle, FILE_MAP_WRITE, 0, 0, 0x100000000); // memory mirror for privileged access
|
||||
void* base_addr = MapViewOfFile(memory_handle, FILE_MAP_WRITE, 0, 0, 0x100000000);
|
||||
g_priv_addr = MapViewOfFile(memory_handle, FILE_MAP_WRITE, 0, 0, 0x100000000);
|
||||
|
||||
CloseHandle(memory_handle);
|
||||
|
||||
return base_addr;
|
||||
|
||||
//return VirtualAlloc(nullptr, 0x100000000, MEM_RESERVE, PAGE_NOACCESS);
|
||||
#else
|
||||
//shm_unlink("/rpcs3_vm");
|
||||
|
||||
int memory_handle = shm_open("/rpcs3_vm", O_RDWR | O_CREAT | O_EXCL, 0);
|
||||
|
||||
if (memory_handle == -1)
|
||||
{
|
||||
printf("shm_open() failed\n");
|
||||
printf("shm_open('/rpcs3_vm') failed\n");
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
ftruncate(memory_handle, 0x100000000);
|
||||
if (ftruncate(memory_handle, 0x100000000) == -1)
|
||||
{
|
||||
printf("ftruncate(memory_handle) failed\n");
|
||||
shm_unlink("/rpcs3_vm");
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
void* base_addr = mmap(nullptr, 0x100000000, PROT_NONE, MAP_SHARED, memory_handle, 0);
|
||||
g_priv_addr = mmap(nullptr, 0x100000000, PROT_NONE, MAP_SHARED, memory_handle, 0);
|
||||
@ -61,8 +58,6 @@ namespace vm
|
||||
shm_unlink("/rpcs3_vm");
|
||||
|
||||
return base_addr;
|
||||
|
||||
//return mmap(nullptr, 0x100000000, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -71,14 +66,14 @@ namespace vm
|
||||
#ifdef _WIN32
|
||||
UnmapViewOfFile(g_base_addr);
|
||||
UnmapViewOfFile(g_priv_addr);
|
||||
CloseHandle(g_memory_handle);
|
||||
#else
|
||||
munmap(g_base_addr, 0x100000000);
|
||||
munmap(g_priv_addr, 0x100000000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void* const g_base_addr = (atexit(finalize), initialize());
|
||||
void* g_base_addr = (atexit(finalize), initialize());
|
||||
void* g_priv_addr;
|
||||
|
||||
std::array<atomic_le_t<u8>, 0x100000000ull / 4096> g_page_info = {}; // information about every page
|
||||
|
||||
@ -628,7 +623,7 @@ namespace vm
|
||||
{
|
||||
PPUThread& PPU = static_cast<PPUThread&>(CPU);
|
||||
|
||||
old_pos = (u32)PPU.GPR[1];
|
||||
old_pos = vm::cast(PPU.GPR[1], "SP");
|
||||
PPU.GPR[1] -= align(size, 8); // room minimal possible size
|
||||
PPU.GPR[1] &= ~(align_v - 1); // fix stack alignment
|
||||
|
||||
|
@ -5,6 +5,9 @@ class CPUThread;
|
||||
|
||||
namespace vm
|
||||
{
|
||||
extern void* g_base_addr; // base address of ps3/psv virtual memory for common access
|
||||
extern void* g_priv_addr; // base address of ps3/psv virtual memory for privileged access
|
||||
|
||||
enum memory_location : uint
|
||||
{
|
||||
main,
|
||||
@ -29,13 +32,6 @@ namespace vm
|
||||
static void set_stack_size(u32 size) {}
|
||||
static void initialize_stack() {}
|
||||
|
||||
#ifdef _WIN32
|
||||
extern HANDLE g_memory_handle;
|
||||
#endif
|
||||
|
||||
extern void* g_priv_addr;
|
||||
extern void* const g_base_addr;
|
||||
|
||||
// break the reservation, return true if it was successfully broken
|
||||
bool reservation_break(u32 addr);
|
||||
// read memory and reserve it for further atomic update, return true if the previous reservation was broken
|
||||
|
Loading…
x
Reference in New Issue
Block a user