diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index d0767df755..6560be209b 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -505,7 +505,7 @@ error_code cellGemEnableMagnetometer2() return CELL_OK; } -error_code cellGemEnd() +error_code cellGemEnd(ppu_thread& ppu) { cellGem.warning("cellGemEnd()"); @@ -517,7 +517,7 @@ error_code cellGemEnd() { if (u32 addr = gem->memory_ptr) { - sys_memory_free(addr); + sys_memory_free(ppu, addr); } return CELL_OK; @@ -950,7 +950,7 @@ error_code cellGemHSVtoRGB(f32 h, f32 s, f32 v, vm::ptr r, vm::ptr g, return CELL_OK; } -error_code cellGemInit(vm::cptr attribute) +error_code cellGemInit(ppu_thread& ppu, vm::cptr attribute) { cellGem.warning("cellGemInit(attribute=*0x%x)", attribute); @@ -973,7 +973,7 @@ error_code cellGemInit(vm::cptr attribute) vm::var addr(0); // Decrease memory stats - if (sys_memory_allocate(GemGetMemorySize(attribute->max_connect), SYS_MEMORY_PAGE_SIZE_64K, +addr) != CELL_OK) + if (sys_memory_allocate(ppu, GemGetMemorySize(attribute->max_connect), SYS_MEMORY_PAGE_SIZE_64K, +addr) != CELL_OK) { return CELL_GEM_ERROR_RESOURCE_ALLOCATION_FAILED; } diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.cpp b/rpcs3/Emu/Cell/lv2/sys_memory.cpp index 8ef20a4e08..dda9afa978 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_memory.cpp @@ -19,9 +19,9 @@ struct sys_memory_address_table // Todo: fix order of error checks -error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) +error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr alloc_addr) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_allocate(size=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, flags, alloc_addr); @@ -68,7 +68,7 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) } // Dealloc using the syscall - sys_memory_free(addr); + sys_memory_free(cpu, addr); return CELL_EFAULT; } } @@ -77,9 +77,9 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) return CELL_ENOMEM; } -error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr alloc_addr) +error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid, u64 flags, vm::ptr alloc_addr) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, cid, flags, alloc_addr); @@ -138,7 +138,7 @@ error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm:: } // Dealloc using the syscall - sys_memory_free(addr); + sys_memory_free(cpu, addr); return CELL_EFAULT; } } @@ -147,9 +147,9 @@ error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm:: return CELL_ENOMEM; } -error_code sys_memory_free(u32 addr) +error_code sys_memory_free(cpu_thread& cpu, u32 addr) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_free(addr=0x%x)", addr); @@ -165,9 +165,9 @@ error_code sys_memory_free(u32 addr) return CELL_OK; } -error_code sys_memory_get_page_attribute(u32 addr, vm::ptr attr) +error_code sys_memory_get_page_attribute(cpu_thread& cpu, u32 addr, vm::ptr attr) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.trace("sys_memory_get_page_attribute(addr=0x%x, attr=*0x%x)", addr, attr); @@ -203,9 +203,9 @@ error_code sys_memory_get_page_attribute(u32 addr, vm::ptr attr return CELL_OK; } -error_code sys_memory_get_user_memory_size(vm::ptr mem_info) +error_code sys_memory_get_user_memory_size(cpu_thread& cpu, vm::ptr mem_info) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info); @@ -226,18 +226,18 @@ error_code sys_memory_get_user_memory_size(vm::ptr mem_info) return CELL_OK; } -error_code sys_memory_get_user_memory_stat(vm::ptr mem_stat) +error_code sys_memory_get_user_memory_stat(cpu_thread& cpu, vm::ptr mem_stat) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.todo("sys_memory_get_user_memory_stat(mem_stat=*0x%x)", mem_stat); return CELL_OK; } -error_code sys_memory_container_create(vm::ptr cid, u32 size) +error_code sys_memory_container_create(cpu_thread& cpu, vm::ptr cid, u32 size) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_container_create(cid=*0x%x, size=0x%x)", cid, size); @@ -270,9 +270,9 @@ error_code sys_memory_container_create(vm::ptr cid, u32 size) return CELL_EAGAIN; } -error_code sys_memory_container_destroy(u32 cid) +error_code sys_memory_container_destroy(cpu_thread& cpu, u32 cid) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_container_destroy(cid=0x%x)", cid); @@ -305,9 +305,9 @@ error_code sys_memory_container_destroy(u32 cid) return CELL_OK; } -error_code sys_memory_container_get_size(vm::ptr mem_info, u32 cid) +error_code sys_memory_container_get_size(cpu_thread& cpu, vm::ptr mem_info, u32 cid) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_memory.warning("sys_memory_container_get_size(mem_info=*0x%x, cid=0x%x)", mem_info, cid); diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.h b/rpcs3/Emu/Cell/lv2/sys_memory.h index a6cb319357..e309080014 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.h +++ b/rpcs3/Emu/Cell/lv2/sys_memory.h @@ -4,6 +4,8 @@ #include "Emu/Memory/vm_ptr.h" #include "Emu/IdManager.h" +class cpu_thread; + enum : u32 { SYS_MEMORY_CONTAINER_ID_INVALID = 0xFFFFFFFF, @@ -89,12 +91,12 @@ struct sys_memory_user_memory_stat_t }; // SysCalls -error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr); -error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr alloc_addr); -error_code sys_memory_free(u32 start_addr); -error_code sys_memory_get_page_attribute(u32 addr, vm::ptr attr); -error_code sys_memory_get_user_memory_size(vm::ptr mem_info); -error_code sys_memory_get_user_memory_stat(vm::ptr mem_stat); -error_code sys_memory_container_create(vm::ptr cid, u32 size); -error_code sys_memory_container_destroy(u32 cid); -error_code sys_memory_container_get_size(vm::ptr mem_info, u32 cid); +error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr alloc_addr); +error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid, u64 flags, vm::ptr alloc_addr); +error_code sys_memory_free(cpu_thread& cpu, u32 start_addr); +error_code sys_memory_get_page_attribute(cpu_thread& cpu, u32 addr, vm::ptr attr); +error_code sys_memory_get_user_memory_size(cpu_thread& cpu, vm::ptr mem_info); +error_code sys_memory_get_user_memory_stat(cpu_thread& cpu, vm::ptr mem_stat); +error_code sys_memory_container_create(cpu_thread& cpu, vm::ptr cid, u32 size); +error_code sys_memory_container_destroy(cpu_thread& cpu, u32 cid); +error_code sys_memory_container_get_size(cpu_thread& cpu, vm::ptr mem_info, u32 cid); diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index 91777f7fe7..5e3f6bd679 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -33,7 +33,7 @@ namespace rsx const auto contextInfo = vm::ptr::make(contextAddr); // 'fake' initialize usermemory - sys_memory_allocate(buffer_size, SYS_MEMORY_PAGE_SIZE_1M, contextInfo.ptr(&rsx_context::user_addr)); + sys_memory_allocate(*this, buffer_size, SYS_MEMORY_PAGE_SIZE_1M, contextInfo.ptr(&rsx_context::user_addr)); verify(HERE), (user_mem_addr = contextInfo->user_addr) != 0; if (sys_rsx_device_map(*this, contextInfo.ptr(&rsx_context::dev_addr), vm::null, 0x8) != CELL_OK)