mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-16 11:48:36 +12:00
rsx: rewrite io mappings
Along with some with fixes to cellGcmSys HLE.
This commit is contained in:
parent
f47333997f
commit
bdab26ec09
9 changed files with 233 additions and 186 deletions
|
@ -188,8 +188,6 @@ error_code sys_rsx_context_allocate(vm::ptr<u32> context_id, vm::ptr<u64> lpar_d
|
|||
dmaControl.put = 0;
|
||||
dmaControl.ref = 0; // Set later to -1 by cellGcmSys
|
||||
|
||||
memset(&RSXIOMem, 0xFF, sizeof(RSXIOMem));
|
||||
|
||||
if (false/*system_mode == CELL_GCM_SYSTEM_MODE_IOMAP_512MB*/)
|
||||
rsx::get_current_renderer()->main_mem_size = 0x20000000; //512MB
|
||||
else
|
||||
|
@ -251,8 +249,10 @@ error_code sys_rsx_context_iomap(u32 context_id, u32 io, u32 ea, u32 size, u64 f
|
|||
{
|
||||
sys_rsx.warning("sys_rsx_context_iomap(context_id=0x%x, io=0x%x, ea=0x%x, size=0x%x, flags=0x%llx)", context_id, io, ea, size, flags);
|
||||
|
||||
const auto render = rsx::get_current_renderer();
|
||||
|
||||
if (!size || io & 0xFFFFF || ea + u64{size} > rsx::constants::local_mem_base || ea & 0xFFFFF || size & 0xFFFFF ||
|
||||
context_id != 0x55555555 || rsx::get_current_renderer()->main_mem_size < io + u64{size})
|
||||
context_id != 0x55555555 || render->main_mem_size < io + u64{size})
|
||||
{
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
@ -273,9 +273,13 @@ error_code sys_rsx_context_iomap(u32 context_id, u32 io, u32 ea, u32 size, u64 f
|
|||
|
||||
for (u32 i = 0; i < size; i++)
|
||||
{
|
||||
const u32 prev_ea = std::exchange(RSXIOMem.ea[io + i].raw(), ea + i);
|
||||
if (prev_ea < 0xC00) RSXIOMem.io[prev_ea].raw() = 0xFFFF; // Clear previous mapping if exists
|
||||
RSXIOMem.io[ea + i].raw() = io + i;
|
||||
auto& table = render->iomap_table;
|
||||
|
||||
// TODO: Investigate relaxed memory ordering
|
||||
const u32 prev_ea = table.ea[io + i];
|
||||
table.ea[io + i].release((ea + i) << 20);
|
||||
if (prev_ea + 1) table.io[prev_ea >> 20].release(-1); // Clear previous mapping if exists
|
||||
table.io[ea + i].release((io + i) << 20);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -291,8 +295,10 @@ error_code sys_rsx_context_iounmap(u32 context_id, u32 io, u32 size)
|
|||
{
|
||||
sys_rsx.warning("sys_rsx_context_iounmap(context_id=0x%x, io=0x%x, size=0x%x)", context_id, io, size);
|
||||
|
||||
const auto render = rsx::get_current_renderer();
|
||||
|
||||
if (!size || size & 0xFFFFF || io & 0xFFFFF || context_id != 0x55555555 ||
|
||||
rsx::get_current_renderer()->main_mem_size < io + u64{size})
|
||||
render->main_mem_size < io + u64{size})
|
||||
{
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
@ -301,12 +307,13 @@ error_code sys_rsx_context_iounmap(u32 context_id, u32 io, u32 size)
|
|||
|
||||
std::scoped_lock lock(s_rsxmem_mtx);
|
||||
|
||||
const u32 end = (io >>= 20) + (size >>= 20);
|
||||
|
||||
while (io < end)
|
||||
for (const u32 end = (io >>= 20) + (size >>= 20); io < end;)
|
||||
{
|
||||
const u32 ea_entry = std::exchange(RSXIOMem.ea[io++].raw(), 0xFFFF);
|
||||
if (ea_entry < 0xC00) RSXIOMem.io[ea_entry].raw() = 0xFFFF;
|
||||
auto& table = render->iomap_table;
|
||||
|
||||
const u32 ea_entry = table.ea[io];
|
||||
table.ea[io++].release(-1);
|
||||
if (ea_entry + 1) table.io[ea_entry >> 20].release(-1);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue