diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index 7a17ef87cf..f8aa61441f 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -19,7 +19,7 @@ LOG_CHANNEL(cellSpurs); -error_code sys_spu_image_close(vm::ptr img); +error_code sys_spu_image_close(ppu_thread&, vm::ptr img); // TODO struct cell_error_t @@ -125,7 +125,7 @@ namespace _spurs //s32 cellSpursDetachLv2EventQueue(vm::ptr spurs, u8 port); // Enable the SPU exception event handler -s32 cellSpursEnableExceptionEventHandler(vm::ptr spurs, b8 flag); +s32 cellSpursEnableExceptionEventHandler(ppu_thread& ppu, vm::ptr spurs, b8 flag); //s32 cellSpursSetGlobalExceptionEventHandler(vm::ptr spurs, vm::ptr eaHandler, vm::ptr arg); //s32 cellSpursUnsetGlobalExceptionEventHandler(vm::ptr spurs); @@ -427,7 +427,7 @@ s32 _spurs::attach_lv2_eq(ppu_thread& ppu, vm::ptr spurs, u32 queue, portMask |= 1ull << (i); } - if (s32 res = sys_spu_thread_group_connect_event_all_threads(spurs->spuTG, queue, portMask, port)) + if (s32 res = sys_spu_thread_group_connect_event_all_threads(ppu, spurs->spuTG, queue, portMask, port)) { if (res == CELL_EISCONN) { @@ -849,7 +849,7 @@ s32 _spurs::finalize_spu(ppu_thread& ppu, vm::ptr spurs) { CHECK_SUCCESS(sys_spu_thread_group_join(ppu, spurs->spuTG, vm::null, vm::null)); - if (s32 rc = sys_spu_thread_group_destroy(spurs->spuTG)) + if (s32 rc = sys_spu_thread_group_destroy(ppu, spurs->spuTG)) { if (rc == CELL_EBUSY) { @@ -864,13 +864,13 @@ s32 _spurs::finalize_spu(ppu_thread& ppu, vm::ptr spurs) } else { - if (s32 rc = sys_spu_thread_group_destroy(spurs->spuTG)) + if (s32 rc = sys_spu_thread_group_destroy(ppu, spurs->spuTG)) { return rc; } } - CHECK_SUCCESS(sys_spu_image_close(spurs.ptr(&CellSpurs::spuImg))); + CHECK_SUCCESS(sys_spu_image_close(ppu, spurs.ptr(&CellSpurs::spuImg))); return CELL_OK; } @@ -1090,9 +1090,9 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr spurs, u32 revision, if (flags & SAF_UNKNOWN_FLAG_9) spuTgAttr->type |= 0x0800; if (flags & SAF_SYSTEM_WORKLOAD_ENABLED) spuTgAttr->type |= SYS_SPU_THREAD_GROUP_TYPE_COOPERATE_WITH_SYSTEM; - if (s32 rc = sys_spu_thread_group_create(spurs.ptr(&CellSpurs::spuTG), nSpus, spuPriority, spuTgAttr)) + if (s32 rc = sys_spu_thread_group_create(ppu, spurs.ptr(&CellSpurs::spuTG), nSpus, spuPriority, spuTgAttr)) { - sys_spu_image_close(spurs.ptr(&CellSpurs::spuImg)); + sys_spu_image_close(ppu, spurs.ptr(&CellSpurs::spuImg)); return rollback(), rc; } @@ -1112,10 +1112,10 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr spurs, u32 revision, spuThArgs->arg1 = (u64)num << 32; spuThArgs->arg2 = (u64)spurs.addr(); - if (s32 rc = sys_spu_thread_initialize(spurs.ptr(&CellSpurs::spus, num), spurs->spuTG, num, spurs.ptr(&CellSpurs::spuImg), spuThAttr, spuThArgs)) + if (s32 rc = sys_spu_thread_initialize(ppu, spurs.ptr(&CellSpurs::spus, num), spurs->spuTG, num, spurs.ptr(&CellSpurs::spuImg), spuThAttr, spuThArgs)) { - sys_spu_thread_group_destroy(spurs->spuTG); - sys_spu_image_close(spurs.ptr(&CellSpurs::spuImg)); + sys_spu_thread_group_destroy(ppu, spurs->spuTG); + sys_spu_image_close(ppu, spurs.ptr(&CellSpurs::spuImg)); return rollback(), rc; } @@ -1184,7 +1184,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr spurs, u32 revision, } // Enable SPURS exception handler - if (s32 rc = cellSpursEnableExceptionEventHandler(spurs, true /*enable*/)) + if (s32 rc = cellSpursEnableExceptionEventHandler(ppu, spurs, true /*enable*/)) { _spurs::signal_to_handler_thread(ppu, spurs); _spurs::join_handler_thread(ppu, spurs); @@ -1717,7 +1717,7 @@ s32 cellSpursDetachLv2EventQueue(vm::ptr spurs, u8 port) return _spurs::detach_lv2_eq(spurs, port, false); } -s32 cellSpursEnableExceptionEventHandler(vm::ptr spurs, b8 flag) +s32 cellSpursEnableExceptionEventHandler(ppu_thread& ppu, vm::ptr spurs, b8 flag) { cellSpurs.warning("cellSpursEnableExceptionEventHandler(spurs=*0x%x, flag=%d)", spurs, flag); @@ -1737,14 +1737,14 @@ s32 cellSpursEnableExceptionEventHandler(vm::ptr spurs, b8 flag) { if (oldEnableEH == 0) { - rc = sys_spu_thread_group_connect_event(spurs->spuTG, spurs->eventQueue, SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION); + rc = sys_spu_thread_group_connect_event(ppu, spurs->spuTG, spurs->eventQueue, SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION); } } else { if (oldEnableEH == 1) { - rc = sys_spu_thread_group_disconnect_event(spurs->eventQueue, SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION); + rc = sys_spu_thread_group_disconnect_event(ppu, spurs->eventQueue, SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION); } } diff --git a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp index 45d89a79b1..2920522b6b 100644 --- a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp @@ -271,7 +271,7 @@ error_code sys_spu_elf_get_segments(u32 elf_img, vm::ptr segmen return CELL_OK; } -error_code sys_spu_image_import(vm::ptr img, u32 src, u32 type) +error_code sys_spu_image_import(ppu_thread& ppu, vm::ptr img, u32 src, u32 type) { sysPrxForUser.warning("sys_spu_image_import(img=*0x%x, src=0x%x, type=%d)", img, src, type); @@ -324,7 +324,7 @@ error_code sys_spu_image_import(vm::ptr img, u32 src, u32 type) img_size = std::max(img_size, static_cast(p.p_offset + p.p_filesz)); } - return _sys_spu_image_import(img, src, img_size, 0); + return _sys_spu_image_import(ppu, img, src, img_size, 0); } else { @@ -357,7 +357,7 @@ error_code sys_spu_image_import(vm::ptr img, u32 src, u32 type) } } -error_code sys_spu_image_close(vm::ptr img) +error_code sys_spu_image_close(ppu_thread& ppu, vm::ptr img) { sysPrxForUser.warning("sys_spu_image_close(img=*0x%x)", img); @@ -369,7 +369,7 @@ error_code sys_spu_image_close(vm::ptr img) else if (img->type == SYS_SPU_IMAGE_TYPE_KERNEL) { // Call the syscall - return _sys_spu_image_close(img); + return _sys_spu_image_close(ppu, img); } else { diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index ba68ba4f2c..0db9b8cf6a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -138,8 +138,10 @@ void sys_spu_image::deploy(u32 loc, sys_spu_segment* segs, u32 nsegs) LOG_NOTICE(LOADER, "Loaded SPU image: %s (<- %u)%s", hash, applied, dump); } -error_code sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu) +error_code sys_spu_initialize(ppu_thread& ppu, u32 max_usable_spu, u32 max_raw_spu) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_initialize(max_usable_spu=%d, max_raw_spu=%d)", max_usable_spu, max_raw_spu); if (max_raw_spu > 5) @@ -150,8 +152,10 @@ error_code sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu) return CELL_OK; } -error_code _sys_spu_image_get_information(vm::ptr img, vm::ptr entry_point, vm::ptr nsegs) +error_code _sys_spu_image_get_information(ppu_thread& ppu, vm::ptr img, vm::ptr entry_point, vm::ptr nsegs) { + vm::temporary_unlock(ppu); + sys_spu.warning("_sys_spu_image_get_information(img=*0x%x, entry_point=*0x%x, nsegs=*0x%x)", img, entry_point, nsegs); *entry_point = img->entry_point; @@ -159,8 +163,10 @@ error_code _sys_spu_image_get_information(vm::ptr img, vm::ptr img, vm::cptr path) +error_code sys_spu_image_open(ppu_thread& ppu, vm::ptr img, vm::cptr path) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_image_open(img=*0x%x, path=%s)", img, path); const fs::file elf_file = decrypt_self(fs::file(vfs::get(path.get_ptr())), fxm::get_always()->devKlic.data()); @@ -176,24 +182,30 @@ error_code sys_spu_image_open(vm::ptr img, vm::cptr path) return CELL_OK; } -error_code _sys_spu_image_import(vm::ptr img, u32 src, u32 size, u32 arg4) +error_code _sys_spu_image_import(ppu_thread& ppu, vm::ptr img, u32 src, u32 size, u32 arg4) { + vm::temporary_unlock(ppu); + sys_spu.warning("_sys_spu_image_import(img=*0x%x, src=*0x%x, size=0x%x, arg4=0x%x)", img, src, size, arg4); img->load(fs::file{vm::base(src), size}); return CELL_OK; } -error_code _sys_spu_image_close(vm::ptr img) +error_code _sys_spu_image_close(ppu_thread& ppu, vm::ptr img) { + vm::temporary_unlock(ppu); + sys_spu.warning("_sys_spu_image_close(img=*0x%x)", img); vm::dealloc(img->segs.addr(), vm::main); return CELL_OK; } -error_code _sys_spu_image_get_segments(vm::ptr img, vm::ptr segments, s32 nseg) +error_code _sys_spu_image_get_segments(ppu_thread& ppu, vm::ptr img, vm::ptr segments, s32 nseg) { + vm::temporary_unlock(ppu); + sys_spu.error("_sys_spu_image_get_segments(img=*0x%x, segments=*0x%x, nseg=%d)", img, segments, nseg); // TODO: apply SPU patches @@ -201,8 +213,10 @@ error_code _sys_spu_image_get_segments(vm::ptr img, vm::ptr thread, u32 group_id, u32 spu_num, vm::ptr img, vm::ptr attr, vm::ptr arg) +error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 group_id, u32 spu_num, vm::ptr img, vm::ptr attr, vm::ptr arg) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_initialize(thread=*0x%x, group=0x%x, spu_num=%d, img=*0x%x, attr=*0x%x, arg=*0x%x)", thread, group_id, spu_num, img, attr, arg); // Read thread name @@ -274,8 +288,10 @@ error_code sys_spu_thread_initialize(vm::ptr thread, u32 group_id, u32 spu_ return CELL_OK; } -error_code sys_spu_thread_set_argument(u32 id, vm::ptr arg) +error_code sys_spu_thread_set_argument(ppu_thread& ppu, u32 id, vm::ptr arg) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_set_argument(id=0x%x, arg=*0x%x)", id, arg); const auto thread = idm::get>(id); @@ -294,8 +310,10 @@ error_code sys_spu_thread_set_argument(u32 id, vm::ptr return CELL_OK; } -error_code sys_spu_thread_get_exit_status(u32 id, vm::ptr status) +error_code sys_spu_thread_get_exit_status(ppu_thread& ppu, u32 id, vm::ptr status) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_get_exit_status(id=0x%x, status=*0x%x)", id, status); const auto thread = idm::get>(id); @@ -314,8 +332,10 @@ error_code sys_spu_thread_get_exit_status(u32 id, vm::ptr status) return CELL_ESTAT; } -error_code sys_spu_thread_group_create(vm::ptr id, u32 num, s32 prio, vm::ptr attr) +error_code sys_spu_thread_group_create(ppu_thread& ppu, vm::ptr id, u32 num, s32 prio, vm::ptr attr) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_group_create(id=*0x%x, num=%d, prio=%d, attr=*0x%x)", id, num, prio, attr); // TODO: max num value should be affected by sys_spu_initialize() settings @@ -335,8 +355,10 @@ error_code sys_spu_thread_group_create(vm::ptr id, u32 num, s32 prio, vm::p return CELL_OK; } -error_code sys_spu_thread_group_destroy(u32 id) +error_code sys_spu_thread_group_destroy(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_group_destroy(id=0x%x)", id); const auto group = idm::withdraw(id, [](lv2_spu_group& group) -> CellError @@ -451,8 +473,10 @@ error_code sys_spu_thread_group_start(ppu_thread& ppu, u32 id) return CELL_OK; } -error_code sys_spu_thread_group_suspend(u32 id) +error_code sys_spu_thread_group_suspend(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_group_suspend(id=0x%x)", id); const auto group = idm::get(id); @@ -504,8 +528,10 @@ error_code sys_spu_thread_group_suspend(u32 id) return CELL_OK; } -error_code sys_spu_thread_group_resume(u32 id) +error_code sys_spu_thread_group_resume(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_group_resume(id=0x%x)", id); const auto group = idm::get(id); @@ -549,8 +575,10 @@ error_code sys_spu_thread_group_resume(u32 id) return CELL_OK; } -error_code sys_spu_thread_group_yield(u32 id) +error_code sys_spu_thread_group_yield(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_group_yield(id=0x%x)", id); const auto group = idm::get(id); @@ -575,8 +603,10 @@ error_code sys_spu_thread_group_yield(u32 id) return CELL_OK; } -error_code sys_spu_thread_group_terminate(u32 id, s32 value) +error_code sys_spu_thread_group_terminate(ppu_thread& ppu, u32 id, s32 value) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_group_terminate(id=0x%x, value=0x%x)", id, value); // The id can be either SPU Thread Group or SPU Thread @@ -725,8 +755,10 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr cause return CELL_OK; } -error_code sys_spu_thread_group_set_priority(u32 id, s32 priority) +error_code sys_spu_thread_group_set_priority(ppu_thread& ppu, u32 id, s32 priority) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_group_set_priority(id=0x%x, priority=%d)", id, priority); if (priority < 16 || priority > 255) @@ -751,8 +783,10 @@ error_code sys_spu_thread_group_set_priority(u32 id, s32 priority) return CELL_OK; } -error_code sys_spu_thread_group_get_priority(u32 id, vm::ptr priority) +error_code sys_spu_thread_group_get_priority(ppu_thread& ppu, u32 id, vm::ptr priority) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_group_get_priority(id=0x%x, priority=*0x%x)", id, priority); const auto group = idm::get(id); @@ -774,8 +808,10 @@ error_code sys_spu_thread_group_get_priority(u32 id, vm::ptr priority) return CELL_OK; } -error_code sys_spu_thread_write_ls(u32 id, u32 lsa, u64 value, u32 type) +error_code sys_spu_thread_write_ls(ppu_thread& ppu, u32 id, u32 lsa, u64 value, u32 type) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_write_ls(id=0x%x, lsa=0x%05x, value=0x%llx, type=%d)", id, lsa, value, type); const auto thread = idm::get>(id); @@ -811,8 +847,10 @@ error_code sys_spu_thread_write_ls(u32 id, u32 lsa, u64 value, u32 type) return CELL_OK; } -error_code sys_spu_thread_read_ls(u32 id, u32 lsa, vm::ptr value, u32 type) +error_code sys_spu_thread_read_ls(ppu_thread& ppu, u32 id, u32 lsa, vm::ptr value, u32 type) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_read_ls(id=0x%x, lsa=0x%05x, value=*0x%x, type=%d)", id, lsa, value, type); const auto thread = idm::get>(id); @@ -848,8 +886,10 @@ error_code sys_spu_thread_read_ls(u32 id, u32 lsa, vm::ptr value, u32 type) return CELL_OK; } -error_code sys_spu_thread_write_spu_mb(u32 id, u32 value) +error_code sys_spu_thread_write_spu_mb(ppu_thread& ppu, u32 id, u32 value) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x)", id, value); const auto thread = idm::get>(id); @@ -873,8 +913,10 @@ error_code sys_spu_thread_write_spu_mb(u32 id, u32 value) return CELL_OK; } -error_code sys_spu_thread_set_spu_cfg(u32 id, u64 value) +error_code sys_spu_thread_set_spu_cfg(ppu_thread& ppu, u32 id, u64 value) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_set_spu_cfg(id=0x%x, value=0x%x)", id, value); const auto thread = idm::get>(id); @@ -894,8 +936,10 @@ error_code sys_spu_thread_set_spu_cfg(u32 id, u64 value) return CELL_OK; } -error_code sys_spu_thread_get_spu_cfg(u32 id, vm::ptr value) +error_code sys_spu_thread_get_spu_cfg(ppu_thread& ppu, u32 id, vm::ptr value) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_get_spu_cfg(id=0x%x, value=*0x%x)", id, value); const auto thread = idm::get>(id); @@ -910,8 +954,10 @@ error_code sys_spu_thread_get_spu_cfg(u32 id, vm::ptr value) return CELL_OK; } -error_code sys_spu_thread_write_snr(u32 id, u32 number, u32 value) +error_code sys_spu_thread_write_snr(ppu_thread& ppu, u32 id, u32 number, u32 value) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_spu_thread_write_snr(id=0x%x, number=%d, value=0x%x)", id, number, value); const auto thread = idm::get>(id); @@ -936,8 +982,10 @@ error_code sys_spu_thread_write_snr(u32 id, u32 number, u32 value) return CELL_OK; } -error_code sys_spu_thread_group_connect_event(u32 id, u32 eq, u32 et) +error_code sys_spu_thread_group_connect_event(ppu_thread& ppu, u32 id, u32 eq, u32 et) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_group_connect_event(id=0x%x, eq=0x%x, et=%d)", id, eq, et); const auto group = idm::get(id); @@ -992,8 +1040,10 @@ error_code sys_spu_thread_group_connect_event(u32 id, u32 eq, u32 et) return CELL_OK; } -error_code sys_spu_thread_group_disconnect_event(u32 id, u32 et) +error_code sys_spu_thread_group_disconnect_event(ppu_thread& ppu, u32 id, u32 et) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_group_disconnect_event(id=0x%x, et=%d)", id, et); const auto group = idm::get(id); @@ -1047,8 +1097,10 @@ error_code sys_spu_thread_group_disconnect_event(u32 id, u32 et) return CELL_OK; } -error_code sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup) +error_code sys_spu_thread_connect_event(ppu_thread& ppu, u32 id, u32 eq, u32 et, u8 spup) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_connect_event(id=0x%x, eq=0x%x, et=%d, spup=%d)", id, eq, et, spup); const auto thread = idm::get>(id); @@ -1079,8 +1131,10 @@ error_code sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup) return CELL_OK; } -error_code sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup) +error_code sys_spu_thread_disconnect_event(ppu_thread& ppu, u32 id, u32 et, u8 spup) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_disconnect_event(id=0x%x, et=%d, spup=%d)", id, et, spup); const auto thread = idm::get>(id); @@ -1110,8 +1164,10 @@ error_code sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup) return CELL_OK; } -error_code sys_spu_thread_bind_queue(u32 id, u32 spuq, u32 spuq_num) +error_code sys_spu_thread_bind_queue(ppu_thread& ppu, u32 id, u32 spuq, u32 spuq_num) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_bind_queue(id=0x%x, spuq=0x%x, spuq_num=0x%x)", id, spuq, spuq_num); const auto thread = idm::get>(id); @@ -1154,8 +1210,10 @@ error_code sys_spu_thread_bind_queue(u32 id, u32 spuq, u32 spuq_num) return CELL_EAGAIN; } -error_code sys_spu_thread_unbind_queue(u32 id, u32 spuq_num) +error_code sys_spu_thread_unbind_queue(ppu_thread& ppu, u32 id, u32 spuq_num) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_unbind_queue(id=0x%x, spuq_num=0x%x)", id, spuq_num); const auto thread = idm::get>(id); @@ -1180,8 +1238,10 @@ error_code sys_spu_thread_unbind_queue(u32 id, u32 spuq_num) return CELL_ESRCH; } -error_code sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 req, vm::ptr spup) +error_code sys_spu_thread_group_connect_event_all_threads(ppu_thread& ppu, u32 id, u32 eq, u64 req, vm::ptr spup) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_group_connect_event_all_threads(id=0x%x, eq=0x%x, req=0x%llx, spup=*0x%x)", id, eq, req, spup); const auto group = idm::get(id); @@ -1251,8 +1311,10 @@ error_code sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 re return CELL_OK; } -error_code sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup) +error_code sys_spu_thread_group_disconnect_event_all_threads(ppu_thread& ppu, u32 id, u8 spup) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_group_disconnect_event_all_threads(id=0x%x, spup=%d)", id, spup); const auto group = idm::get(id); @@ -1280,8 +1342,10 @@ error_code sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup) return CELL_OK; } -error_code sys_spu_thread_recover_page_fault(u32 id) +error_code sys_spu_thread_recover_page_fault(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_spu_thread_recover_page_fault(id=0x%x)", id); const auto thread = idm::get>(id); @@ -1299,8 +1363,10 @@ error_code sys_spu_thread_recover_page_fault(u32 id) return CELL_OK; } -error_code sys_raw_spu_recover_page_fault(u32 id) +error_code sys_raw_spu_recover_page_fault(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_raw_spu_recover_page_fault(id=0x%x)", id); const auto thread = idm::get>(spu_thread::find_raw_spu(id)); @@ -1318,8 +1384,10 @@ error_code sys_raw_spu_recover_page_fault(u32 id) return CELL_OK; } -error_code sys_raw_spu_create(vm::ptr id, vm::ptr attr) +error_code sys_raw_spu_create(ppu_thread& ppu, vm::ptr id, vm::ptr attr) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_raw_spu_create(id=*0x%x, attr=*0x%x)", id, attr); // TODO: check number set by sys_spu_initialize() @@ -1351,6 +1419,8 @@ error_code sys_raw_spu_create(vm::ptr id, vm::ptr attr) error_code sys_raw_spu_destroy(ppu_thread& ppu, u32 id) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_raw_spu_destroy(id=%d)", id); const auto thread = idm::get>(spu_thread::find_raw_spu(id)); @@ -1408,8 +1478,10 @@ error_code sys_raw_spu_destroy(ppu_thread& ppu, u32 id) return CELL_OK; } -error_code sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag) +error_code sys_raw_spu_create_interrupt_tag(ppu_thread& ppu, u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag) { + vm::temporary_unlock(ppu); + sys_spu.warning("sys_raw_spu_create_interrupt_tag(id=%d, class_id=%d, hwthread=0x%x, intrtag=*0x%x)", id, class_id, hwthread, intrtag); if (class_id != 0 && class_id != 2) @@ -1453,8 +1525,10 @@ error_code sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, return error; } -error_code sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask) +error_code sys_raw_spu_set_int_mask(ppu_thread& ppu, u32 id, u32 class_id, u64 mask) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_set_int_mask(id=%d, class_id=%d, mask=0x%llx)", id, class_id, mask); if (class_id != 0 && class_id != 2) @@ -1474,8 +1548,10 @@ error_code sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask) return CELL_OK; } -error_code sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr mask) +error_code sys_raw_spu_get_int_mask(ppu_thread& ppu, u32 id, u32 class_id, vm::ptr mask) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_get_int_mask(id=%d, class_id=%d, mask=*0x%x)", id, class_id, mask); if (class_id != 0 && class_id != 2) @@ -1495,8 +1571,10 @@ error_code sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr mask) return CELL_OK; } -error_code sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat) +error_code sys_raw_spu_set_int_stat(ppu_thread& ppu, u32 id, u32 class_id, u64 stat) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_set_int_stat(id=%d, class_id=%d, stat=0x%llx)", id, class_id, stat); if (class_id != 0 && class_id != 2) @@ -1516,8 +1594,10 @@ error_code sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat) return CELL_OK; } -error_code sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr stat) +error_code sys_raw_spu_get_int_stat(ppu_thread& ppu, u32 id, u32 class_id, vm::ptr stat) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_get_int_stat(id=%d, class_id=%d, stat=*0x%x)", id, class_id, stat); if (class_id != 0 && class_id != 2) @@ -1537,8 +1617,10 @@ error_code sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr stat) return CELL_OK; } -error_code sys_raw_spu_read_puint_mb(u32 id, vm::ptr value) +error_code sys_raw_spu_read_puint_mb(ppu_thread& ppu, u32 id, vm::ptr value) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_read_puint_mb(id=%d, value=*0x%x)", id, value); const auto thread = idm::get>(spu_thread::find_raw_spu(id)); @@ -1553,8 +1635,10 @@ error_code sys_raw_spu_read_puint_mb(u32 id, vm::ptr value) return CELL_OK; } -error_code sys_raw_spu_set_spu_cfg(u32 id, u32 value) +error_code sys_raw_spu_set_spu_cfg(ppu_thread& ppu, u32 id, u32 value) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_set_spu_cfg(id=%d, value=0x%x)", id, value); if (value > 3) @@ -1574,8 +1658,10 @@ error_code sys_raw_spu_set_spu_cfg(u32 id, u32 value) return CELL_OK; } -error_code sys_raw_spu_get_spu_cfg(u32 id, vm::ptr value) +error_code sys_raw_spu_get_spu_cfg(ppu_thread& ppu, u32 id, vm::ptr value) { + vm::temporary_unlock(ppu); + sys_spu.trace("sys_raw_spu_get_spu_afg(id=%d, value=*0x%x)", id, value); const auto thread = idm::get>(spu_thread::find_raw_spu(id)); diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.h b/rpcs3/Emu/Cell/lv2/sys_spu.h index 584864efe0..65c48df474 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.h +++ b/rpcs3/Emu/Cell/lv2/sys_spu.h @@ -287,49 +287,49 @@ class ppu_thread; // Syscalls -error_code sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu); -error_code _sys_spu_image_get_information(vm::ptr img, vm::ptr entry_point, vm::ptr nsegs); -error_code sys_spu_image_open(vm::ptr img, vm::cptr path); -error_code _sys_spu_image_import(vm::ptr img, u32 src, u32 size, u32 arg4); -error_code _sys_spu_image_close(vm::ptr img); -error_code _sys_spu_image_get_segments(vm::ptr img, vm::ptr segments, s32 nseg); -error_code sys_spu_thread_initialize(vm::ptr thread, u32 group, u32 spu_num, vm::ptr, vm::ptr, vm::ptr); -error_code sys_spu_thread_set_argument(u32 id, vm::ptr arg); -error_code sys_spu_thread_group_create(vm::ptr id, u32 num, s32 prio, vm::ptr attr); -error_code sys_spu_thread_group_destroy(u32 id); +error_code sys_spu_initialize(ppu_thread&, u32 max_usable_spu, u32 max_raw_spu); +error_code _sys_spu_image_get_information(ppu_thread&, vm::ptr img, vm::ptr entry_point, vm::ptr nsegs); +error_code sys_spu_image_open(ppu_thread&, vm::ptr img, vm::cptr path); +error_code _sys_spu_image_import(ppu_thread&, vm::ptr img, u32 src, u32 size, u32 arg4); +error_code _sys_spu_image_close(ppu_thread&, vm::ptr img); +error_code _sys_spu_image_get_segments(ppu_thread&, vm::ptr img, vm::ptr segments, s32 nseg); +error_code sys_spu_thread_initialize(ppu_thread&, vm::ptr thread, u32 group, u32 spu_num, vm::ptr, vm::ptr, vm::ptr); +error_code sys_spu_thread_set_argument(ppu_thread&, u32 id, vm::ptr arg); +error_code sys_spu_thread_group_create(ppu_thread&, vm::ptr id, u32 num, s32 prio, vm::ptr attr); +error_code sys_spu_thread_group_destroy(ppu_thread&, u32 id); error_code sys_spu_thread_group_start(ppu_thread&, u32 id); -error_code sys_spu_thread_group_suspend(u32 id); -error_code sys_spu_thread_group_resume(u32 id); -error_code sys_spu_thread_group_yield(u32 id); -error_code sys_spu_thread_group_terminate(u32 id, s32 value); +error_code sys_spu_thread_group_suspend(ppu_thread&, u32 id); +error_code sys_spu_thread_group_resume(ppu_thread&, u32 id); +error_code sys_spu_thread_group_yield(ppu_thread&, u32 id); +error_code sys_spu_thread_group_terminate(ppu_thread&, u32 id, s32 value); error_code sys_spu_thread_group_join(ppu_thread&, u32 id, vm::ptr cause, vm::ptr status); -error_code sys_spu_thread_group_set_priority(u32 id, s32 priority); -error_code sys_spu_thread_group_get_priority(u32 id, vm::ptr priority); -error_code sys_spu_thread_group_connect_event(u32 id, u32 eq, u32 et); -error_code sys_spu_thread_group_disconnect_event(u32 id, u32 et); -error_code sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, vm::ptr spup); -error_code sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup); -error_code sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type); -error_code sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr value, u32 type); -error_code sys_spu_thread_write_spu_mb(u32 id, u32 value); -error_code sys_spu_thread_set_spu_cfg(u32 id, u64 value); -error_code sys_spu_thread_get_spu_cfg(u32 id, vm::ptr value); -error_code sys_spu_thread_write_snr(u32 id, u32 number, u32 value); -error_code sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup); -error_code sys_spu_thread_disconnect_event(u32 id, u32 event_type, u8 spup); -error_code sys_spu_thread_bind_queue(u32 id, u32 spuq, u32 spuq_num); -error_code sys_spu_thread_unbind_queue(u32 id, u32 spuq_num); -error_code sys_spu_thread_get_exit_status(u32 id, vm::ptr status); -error_code sys_spu_thread_recover_page_fault(u32 id); +error_code sys_spu_thread_group_set_priority(ppu_thread&, u32 id, s32 priority); +error_code sys_spu_thread_group_get_priority(ppu_thread&, u32 id, vm::ptr priority); +error_code sys_spu_thread_group_connect_event(ppu_thread&, u32 id, u32 eq, u32 et); +error_code sys_spu_thread_group_disconnect_event(ppu_thread&, u32 id, u32 et); +error_code sys_spu_thread_group_connect_event_all_threads(ppu_thread&, u32 id, u32 eq_id, u64 req, vm::ptr spup); +error_code sys_spu_thread_group_disconnect_event_all_threads(ppu_thread&, u32 id, u8 spup); +error_code sys_spu_thread_write_ls(ppu_thread&, u32 id, u32 address, u64 value, u32 type); +error_code sys_spu_thread_read_ls(ppu_thread&, u32 id, u32 address, vm::ptr value, u32 type); +error_code sys_spu_thread_write_spu_mb(ppu_thread&, u32 id, u32 value); +error_code sys_spu_thread_set_spu_cfg(ppu_thread&, u32 id, u64 value); +error_code sys_spu_thread_get_spu_cfg(ppu_thread&, u32 id, vm::ptr value); +error_code sys_spu_thread_write_snr(ppu_thread&, u32 id, u32 number, u32 value); +error_code sys_spu_thread_connect_event(ppu_thread&, u32 id, u32 eq, u32 et, u8 spup); +error_code sys_spu_thread_disconnect_event(ppu_thread&, u32 id, u32 event_type, u8 spup); +error_code sys_spu_thread_bind_queue(ppu_thread&, u32 id, u32 spuq, u32 spuq_num); +error_code sys_spu_thread_unbind_queue(ppu_thread&, u32 id, u32 spuq_num); +error_code sys_spu_thread_get_exit_status(ppu_thread&, u32 id, vm::ptr status); +error_code sys_spu_thread_recover_page_fault(ppu_thread&, u32 id); -error_code sys_raw_spu_create(vm::ptr id, vm::ptr attr); +error_code sys_raw_spu_create(ppu_thread&, vm::ptr id, vm::ptr attr); error_code sys_raw_spu_destroy(ppu_thread& ppu, u32 id); -error_code sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag); -error_code sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask); -error_code sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr mask); -error_code sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat); -error_code sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr stat); -error_code sys_raw_spu_read_puint_mb(u32 id, vm::ptr value); -error_code sys_raw_spu_set_spu_cfg(u32 id, u32 value); -error_code sys_raw_spu_get_spu_cfg(u32 id, vm::ptr value); -error_code sys_raw_spu_recover_page_fault(u32 id); +error_code sys_raw_spu_create_interrupt_tag(ppu_thread&, u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag); +error_code sys_raw_spu_set_int_mask(ppu_thread&, u32 id, u32 class_id, u64 mask); +error_code sys_raw_spu_get_int_mask(ppu_thread&, u32 id, u32 class_id, vm::ptr mask); +error_code sys_raw_spu_set_int_stat(ppu_thread&, u32 id, u32 class_id, u64 stat); +error_code sys_raw_spu_get_int_stat(ppu_thread&, u32 id, u32 class_id, vm::ptr stat); +error_code sys_raw_spu_read_puint_mb(ppu_thread&, u32 id, vm::ptr value); +error_code sys_raw_spu_set_spu_cfg(ppu_thread&, u32 id, u32 value); +error_code sys_raw_spu_get_spu_cfg(ppu_thread&, u32 id, vm::ptr value); +error_code sys_raw_spu_recover_page_fault(ppu_thread&, u32 id);