HLE cellGcmSys: Fix unmapping

This commit is contained in:
Eladash 2020-02-11 23:31:17 +02:00 committed by kd-11
parent 0d7aa5e310
commit ddeb39d8de

View File

@ -82,7 +82,7 @@ u32 gcmIoOffsetToAddress(u32 ioOffset)
{
const u32 upper12Bits = g_fxo->get<gcm_config>()->offsetTable.eaAddress[ioOffset >> 20];
if (static_cast<s16>(upper12Bits) < 0)
if (upper12Bits > 0xBFF)
{
return 0;
}
@ -1035,7 +1035,7 @@ error_code cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr<u32> 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<s16>(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<gcm_config>();
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;
}