diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index 658b0bd654..9374112e68 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -82,7 +82,7 @@ u32 gcmIoOffsetToAddress(u32 ioOffset) { const u32 upper12Bits = g_fxo->get()->offsetTable.eaAddress[ioOffset >> 20]; - if (static_cast(upper12Bits) < 0) + if (upper12Bits > 0xBFF) { return 0; } @@ -1035,7 +1035,7 @@ error_code cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr offset) // Use the offset table to find the next free io address for (u32 io = 0, end = (rsx::get_current_renderer()->main_mem_size - cfg->reserved_size) >> 20, unmap_count = 1; io < end; unmap_count++) { - if (static_cast(cfg->offsetTable.eaAddress[io + unmap_count - 1]) < 0) + if (cfg->offsetTable.eaAddress[io + unmap_count - 1] > 0xBFF) { if (unmap_count >= (size >> 20)) { @@ -1088,17 +1088,13 @@ error_code cellGcmUnmapEaIoAddress(u32 ea) const auto cfg = g_fxo->get(); std::lock_guard lock(cfg->gcmio_mutex); - if (const u32 size = cfg->IoMapTable[ea >> 20]) + if (u32 size = cfg->IoMapTable[ea >>= 20], io = cfg->offsetTable.ioAddress[ea]; size && io <= 0xBFF) { - u32 io = cfg->offsetTable.ioAddress[ea]; - - if (auto error = sys_rsx_context_iounmap(0x55555555, io, size)) + if (auto error = sys_rsx_context_iounmap(0x55555555, io << 20, size << 20)) { return error; } - ea >>= 20, io >>= 20; - const auto render = rsx::get_current_renderer(); for (u32 i = 0; i < size; i++) @@ -1123,7 +1119,7 @@ error_code cellGcmUnmapIoAddress(u32 io) if (u32 ea = cfg->offsetTable.eaAddress[io >>= 20], size = cfg->IoMapTable[ea]; size) { - if (auto error = sys_rsx_context_iounmap(0x55555555, io, size)) + if (auto error = sys_rsx_context_iounmap(0x55555555, io, size << 20)) { return error; } @@ -1135,6 +1131,7 @@ error_code cellGcmUnmapIoAddress(u32 io) cfg->offsetTable.eaAddress[io + i] = 0xFFFF; } + cfg->IoMapTable[ea] = 0; return CELL_OK; }