From 11571cf2a40bfbbd479368aef683b977cd68c7fe Mon Sep 17 00:00:00 2001 From: elisha464 Date: Mon, 3 Mar 2014 22:45:27 +0200 Subject: [PATCH] fix memory alignment added eaIOMap with flags (draft) changed gcmInit to throw an error when not being able to map to io address --- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 19 ++++++++++++++++--- rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 6133a6b111..877075b86f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -37,6 +37,7 @@ uint32_t cellGcmGetMaxIoMapSize(); void cellGcmGetOffsetTable(mem_ptr_t table); int32_t cellGcmIoOffsetToAddress(u32 ioOffset, u64 address); int32_t cellGcmMapEaIoAddress(const u32 ea, const u32 io, const u32 size); +int32_t cellGcmMapEaIoAddressWithFlags(const u32 ea, const u32 io, const u32 size, const u32 flags); int32_t cellGcmMapMainMemory(u64 ea, u32 size, mem32_t offset); int32_t cellGcmReserveIoMapSize(const u32 size); int32_t cellGcmUnmapEaIoAddress(u64 ea); @@ -68,6 +69,14 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) cellGcmSys.Warning("*** local memory(addr=0x%x, size=0x%x)", local_addr, local_size); + InitOffsetTable(); + Memory.MemoryBlocks.push_back(Memory.RSXIOMem.SetRange(0x50000000, 0x10000000/*256MB*/));//TODO: implement allocateAdressSpace in memoryBase + if(cellGcmMapEaIoAddress(ioAddress, 0, ioSize) != CELL_OK) + { + Memory.MemoryBlocks.pop_back(); + return CELL_GCM_ERROR_FAILURE; + } + map_offset_addr = 0; map_offset_pos = 0; current_config.ioSize = ioSize; @@ -77,10 +86,7 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) current_config.memoryFrequency = 650000000; current_config.coreFrequency = 500000000; - InitOffsetTable(); Memory.RSXCMDMem.AllocAlign(cmdSize); - Memory.MemoryBlocks.push_back(Memory.RSXIOMem.SetRange(0x50000000, 0x10000000/*256MB*/));//TODO: implement allocateAdressSpace in memoryBase - cellGcmMapEaIoAddress(ioAddress, 0, ioSize); u32 ctx_begin = ioAddress/* + 0x1000*/; u32 ctx_size = 0x6ffc; @@ -677,6 +683,12 @@ int32_t cellGcmMapEaIoAddress(const u32 ea, const u32 io, const u32 size) return CELL_OK; } +int32_t cellGcmMapEaIoAddressWithFlags(const u32 ea, const u32 io, const u32 size, const u32 flags) +{ + cellGcmSys.Warning("cellGcmMapEaIoAddressWithFlags(ea=0x%x, io=0x%x, size=0x%x, flags=0x%x)", ea, io, size, flags); + return cellGcmMapEaIoAddress(ea, io, size); // TODO: strict ordering +} + int32_t cellGcmMapLocalMemory(u64 address, u64 size) { if(!local_size && !local_addr) @@ -855,6 +867,7 @@ void cellGcmSys_init() cellGcmSys.AddFunc(0x2922aed0, cellGcmGetOffsetTable); cellGcmSys.AddFunc(0x2a6fba9c, cellGcmIoOffsetToAddress); cellGcmSys.AddFunc(0x63441cb4, cellGcmMapEaIoAddress); + cellGcmSys.AddFunc(0x626e8518, cellGcmMapEaIoAddressWithFlags); cellGcmSys.AddFunc(0xdb769b32, cellGcmMapLocalMemory); cellGcmSys.AddFunc(0xa114ec67, cellGcmMapMainMemory); cellGcmSys.AddFunc(0xa7ede268, cellGcmReserveIoMapSize); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp index 04e2c958d3..5c4f5b9761 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp @@ -52,12 +52,12 @@ int sys_memory_allocate(u32 size, u32 flags, u32 alloc_addr_addr) { case SYS_MEMORY_PAGE_SIZE_1M: if(size & 0xfffff) return CELL_EALIGN; - addr = Memory.Alloc(size, 1); + addr = Memory.Alloc(size, 0x100000); break; case SYS_MEMORY_PAGE_SIZE_64K: if(size & 0xffff) return CELL_EALIGN; - addr = Memory.Alloc(size, 1); + addr = Memory.Alloc(size, 0x10000); break; default: return CELL_EINVAL;