HLE cellGcmSys: Make cellGcmUnmapEaIoAddress accurate

This commit is contained in:
Eladash
2020-02-15 14:25:57 +02:00
committed by Ani
parent df8d0cde4a
commit 1aa11440e0
+28 -27
View File
@@ -1076,16 +1076,11 @@ error_code cellGcmReserveIoMapSize(u32 size)
return CELL_OK; return CELL_OK;
} }
error_code cellGcmUnmapEaIoAddress(u32 ea) error_code GcmUnmapIoAddress(gcm_config* cfg, u32 io)
{ {
cellGcmSys.warning("cellGcmUnmapEaIoAddress(ea=0x%x)", ea); if (u32 ea = cfg->offsetTable.eaAddress[io >>= 20], size = cfg->IoMapTable[ea]; size)
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
if (u32 size = cfg->IoMapTable[ea >>= 20], io = cfg->offsetTable.ioAddress[ea]; size && io <= 0xBFF)
{ {
if (auto error = sys_rsx_context_iounmap(0x55555555, io << 20, size << 20)) if (auto error = sys_rsx_context_iounmap(0x55555555, io, size << 20))
{ {
return error; return error;
} }
@@ -1105,6 +1100,30 @@ error_code cellGcmUnmapEaIoAddress(u32 ea)
return CELL_GCM_ERROR_FAILURE; return CELL_GCM_ERROR_FAILURE;
} }
error_code cellGcmUnmapEaIoAddress(u32 ea)
{
cellGcmSys.warning("cellGcmUnmapEaIoAddress(ea=0x%x)", ea);
// Ignores lower bits
ea >>= 20;
if (ea > 0xBFF)
{
return CELL_GCM_ERROR_FAILURE;
}
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
if (const u32 io = cfg->offsetTable.ioAddress[ea] << 20;
io < rsx::get_current_renderer()->main_mem_size)
{
return GcmUnmapIoAddress(cfg, io);
}
return CELL_GCM_ERROR_FAILURE;
}
error_code cellGcmUnmapIoAddress(u32 io) error_code cellGcmUnmapIoAddress(u32 io)
{ {
cellGcmSys.warning("cellGcmUnmapIoAddress(io=0x%x)", io); cellGcmSys.warning("cellGcmUnmapIoAddress(io=0x%x)", io);
@@ -1112,25 +1131,7 @@ error_code cellGcmUnmapIoAddress(u32 io)
const auto cfg = g_fxo->get<gcm_config>(); const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex); std::lock_guard lock(cfg->gcmio_mutex);
if (u32 ea = cfg->offsetTable.eaAddress[io >>= 20], size = cfg->IoMapTable[ea]; size) return GcmUnmapIoAddress(cfg, io);
{
if (auto error = sys_rsx_context_iounmap(0x55555555, io, size << 20))
{
return error;
}
const auto render = rsx::get_current_renderer();
for (u32 i = 0; i < size; i++)
{
cfg->offsetTable.ioAddress[ea + i] = 0xFFFF;
cfg->offsetTable.eaAddress[io + i] = 0xFFFF;
}
cfg->IoMapTable[ea] = 0;
return CELL_OK;
}
return CELL_GCM_ERROR_FAILURE;
} }
error_code cellGcmUnreserveIoMapSize(u32 size) error_code cellGcmUnreserveIoMapSize(u32 size)