sys_spu: add vm::temporary_unlock

This commit is contained in:
Nekotekina 2019-07-14 18:33:23 +03:00
parent 1a1eff66bc
commit cfa1416d64
4 changed files with 189 additions and 103 deletions

View file

@ -19,7 +19,7 @@
LOG_CHANNEL(cellSpurs);
error_code sys_spu_image_close(vm::ptr<sys_spu_image> img);
error_code sys_spu_image_close(ppu_thread&, vm::ptr<sys_spu_image> img);
// TODO
struct cell_error_t
@ -125,7 +125,7 @@ namespace _spurs
//s32 cellSpursDetachLv2EventQueue(vm::ptr<CellSpurs> spurs, u8 port);
// Enable the SPU exception event handler
s32 cellSpursEnableExceptionEventHandler(vm::ptr<CellSpurs> spurs, b8 flag);
s32 cellSpursEnableExceptionEventHandler(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, b8 flag);
//s32 cellSpursSetGlobalExceptionEventHandler(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursGlobalExceptionEventHandler> eaHandler, vm::ptr<void> arg);
//s32 cellSpursUnsetGlobalExceptionEventHandler(vm::ptr<CellSpurs> spurs);
@ -427,7 +427,7 @@ s32 _spurs::attach_lv2_eq(ppu_thread& ppu, vm::ptr<CellSpurs> 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<CellSpurs> 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<CellSpurs> 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<CellSpurs> 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<CellSpurs> 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<CellSpurs> 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<CellSpurs> spurs, u8 port)
return _spurs::detach_lv2_eq(spurs, port, false);
}
s32 cellSpursEnableExceptionEventHandler(vm::ptr<CellSpurs> spurs, b8 flag)
s32 cellSpursEnableExceptionEventHandler(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, b8 flag)
{
cellSpurs.warning("cellSpursEnableExceptionEventHandler(spurs=*0x%x, flag=%d)", spurs, flag);
@ -1737,14 +1737,14 @@ s32 cellSpursEnableExceptionEventHandler(vm::ptr<CellSpurs> 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);
}
}

View file

@ -271,7 +271,7 @@ error_code sys_spu_elf_get_segments(u32 elf_img, vm::ptr<sys_spu_segment> segmen
return CELL_OK;
}
error_code sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 type)
error_code sys_spu_image_import(ppu_thread& ppu, vm::ptr<sys_spu_image> 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<sys_spu_image> img, u32 src, u32 type)
img_size = std::max<u32>(img_size, static_cast<u32>(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<sys_spu_image> img, u32 src, u32 type)
}
}
error_code sys_spu_image_close(vm::ptr<sys_spu_image> img)
error_code sys_spu_image_close(ppu_thread& ppu, vm::ptr<sys_spu_image> img)
{
sysPrxForUser.warning("sys_spu_image_close(img=*0x%x)", img);
@ -369,7 +369,7 @@ error_code sys_spu_image_close(vm::ptr<sys_spu_image> 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
{

View file

@ -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<sys_spu_image> img, vm::ptr<u32> entry_point, vm::ptr<s32> nsegs)
error_code _sys_spu_image_get_information(ppu_thread& ppu, vm::ptr<sys_spu_image> img, vm::ptr<u32> entry_point, vm::ptr<s32> 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<sys_spu_image> img, vm::ptr<u3
return CELL_OK;
}
error_code sys_spu_image_open(vm::ptr<sys_spu_image> img, vm::cptr<char> path)
error_code sys_spu_image_open(ppu_thread& ppu, vm::ptr<sys_spu_image> img, vm::cptr<char> 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<LoadedNpdrmKeys_t>()->devKlic.data());
@ -176,24 +182,30 @@ error_code sys_spu_image_open(vm::ptr<sys_spu_image> img, vm::cptr<char> path)
return CELL_OK;
}
error_code _sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 size, u32 arg4)
error_code _sys_spu_image_import(ppu_thread& ppu, vm::ptr<sys_spu_image> 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<sys_spu_image> img)
error_code _sys_spu_image_close(ppu_thread& ppu, vm::ptr<sys_spu_image> 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<sys_spu_image> img, vm::ptr<sys_spu_segment> segments, s32 nseg)
error_code _sys_spu_image_get_segments(ppu_thread& ppu, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_segment> 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<sys_spu_image> img, vm::ptr<sys_s
return CELL_OK;
}
error_code sys_spu_thread_initialize(vm::ptr<u32> thread, u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_thread_attribute> attr, vm::ptr<sys_spu_thread_argument> arg)
error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr<u32> thread, u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_thread_attribute> attr, vm::ptr<sys_spu_thread_argument> 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<u32> thread, u32 group_id, u32 spu_
return CELL_OK;
}
error_code sys_spu_thread_set_argument(u32 id, vm::ptr<sys_spu_thread_argument> arg)
error_code sys_spu_thread_set_argument(ppu_thread& ppu, u32 id, vm::ptr<sys_spu_thread_argument> 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<named_thread<spu_thread>>(id);
@ -294,8 +310,10 @@ error_code sys_spu_thread_set_argument(u32 id, vm::ptr<sys_spu_thread_argument>
return CELL_OK;
}
error_code sys_spu_thread_get_exit_status(u32 id, vm::ptr<u32> status)
error_code sys_spu_thread_get_exit_status(ppu_thread& ppu, u32 id, vm::ptr<u32> 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<named_thread<spu_thread>>(id);
@ -314,8 +332,10 @@ error_code sys_spu_thread_get_exit_status(u32 id, vm::ptr<u32> status)
return CELL_ESTAT;
}
error_code sys_spu_thread_group_create(vm::ptr<u32> id, u32 num, s32 prio, vm::ptr<sys_spu_thread_group_attribute> attr)
error_code sys_spu_thread_group_create(ppu_thread& ppu, vm::ptr<u32> id, u32 num, s32 prio, vm::ptr<sys_spu_thread_group_attribute> 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<u32> 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<lv2_spu_group>(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<lv2_spu_group>(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<lv2_spu_group>(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<lv2_spu_group>(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<u32> 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<s32> priority)
error_code sys_spu_thread_group_get_priority(ppu_thread& ppu, u32 id, vm::ptr<s32> 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<lv2_spu_group>(id);
@ -774,8 +808,10 @@ error_code sys_spu_thread_group_get_priority(u32 id, vm::ptr<s32> 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<named_thread<spu_thread>>(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<u64> value, u32 type)
error_code sys_spu_thread_read_ls(ppu_thread& ppu, u32 id, u32 lsa, vm::ptr<u64> 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<named_thread<spu_thread>>(id);
@ -848,8 +886,10 @@ error_code sys_spu_thread_read_ls(u32 id, u32 lsa, vm::ptr<u64> 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<named_thread<spu_thread>>(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<named_thread<spu_thread>>(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<u64> value)
error_code sys_spu_thread_get_spu_cfg(ppu_thread& ppu, u32 id, vm::ptr<u64> 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<named_thread<spu_thread>>(id);
@ -910,8 +954,10 @@ error_code sys_spu_thread_get_spu_cfg(u32 id, vm::ptr<u64> 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<named_thread<spu_thread>>(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<lv2_spu_group>(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<lv2_spu_group>(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<named_thread<spu_thread>>(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<named_thread<spu_thread>>(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<named_thread<spu_thread>>(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<named_thread<spu_thread>>(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<u8> spup)
error_code sys_spu_thread_group_connect_event_all_threads(ppu_thread& ppu, u32 id, u32 eq, u64 req, vm::ptr<u8> 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<lv2_spu_group>(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<lv2_spu_group>(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<named_thread<spu_thread>>(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<named_thread<spu_thread>>(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<u32> id, vm::ptr<void> attr)
error_code sys_raw_spu_create(ppu_thread& ppu, vm::ptr<u32> id, vm::ptr<void> 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<u32> id, vm::ptr<void> 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<named_thread<spu_thread>>(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<u32> intrtag)
error_code sys_raw_spu_create_interrupt_tag(ppu_thread& ppu, u32 id, u32 class_id, u32 hwthread, vm::ptr<u32> 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<u64> mask)
error_code sys_raw_spu_get_int_mask(ppu_thread& ppu, u32 id, u32 class_id, vm::ptr<u64> 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<u64> 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<u64> stat)
error_code sys_raw_spu_get_int_stat(ppu_thread& ppu, u32 id, u32 class_id, vm::ptr<u64> 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<u64> stat)
return CELL_OK;
}
error_code sys_raw_spu_read_puint_mb(u32 id, vm::ptr<u32> value)
error_code sys_raw_spu_read_puint_mb(ppu_thread& ppu, u32 id, vm::ptr<u32> 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<named_thread<spu_thread>>(spu_thread::find_raw_spu(id));
@ -1553,8 +1635,10 @@ error_code sys_raw_spu_read_puint_mb(u32 id, vm::ptr<u32> 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<u32> value)
error_code sys_raw_spu_get_spu_cfg(ppu_thread& ppu, u32 id, vm::ptr<u32> 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<named_thread<spu_thread>>(spu_thread::find_raw_spu(id));

View file

@ -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<sys_spu_image> img, vm::ptr<u32> entry_point, vm::ptr<s32> nsegs);
error_code sys_spu_image_open(vm::ptr<sys_spu_image> img, vm::cptr<char> path);
error_code _sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 size, u32 arg4);
error_code _sys_spu_image_close(vm::ptr<sys_spu_image> img);
error_code _sys_spu_image_get_segments(vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_segment> segments, s32 nseg);
error_code sys_spu_thread_initialize(vm::ptr<u32> thread, u32 group, u32 spu_num, vm::ptr<sys_spu_image>, vm::ptr<sys_spu_thread_attribute>, vm::ptr<sys_spu_thread_argument>);
error_code sys_spu_thread_set_argument(u32 id, vm::ptr<sys_spu_thread_argument> arg);
error_code sys_spu_thread_group_create(vm::ptr<u32> id, u32 num, s32 prio, vm::ptr<sys_spu_thread_group_attribute> 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<sys_spu_image> img, vm::ptr<u32> entry_point, vm::ptr<s32> nsegs);
error_code sys_spu_image_open(ppu_thread&, vm::ptr<sys_spu_image> img, vm::cptr<char> path);
error_code _sys_spu_image_import(ppu_thread&, vm::ptr<sys_spu_image> img, u32 src, u32 size, u32 arg4);
error_code _sys_spu_image_close(ppu_thread&, vm::ptr<sys_spu_image> img);
error_code _sys_spu_image_get_segments(ppu_thread&, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_segment> segments, s32 nseg);
error_code sys_spu_thread_initialize(ppu_thread&, vm::ptr<u32> thread, u32 group, u32 spu_num, vm::ptr<sys_spu_image>, vm::ptr<sys_spu_thread_attribute>, vm::ptr<sys_spu_thread_argument>);
error_code sys_spu_thread_set_argument(ppu_thread&, u32 id, vm::ptr<sys_spu_thread_argument> arg);
error_code sys_spu_thread_group_create(ppu_thread&, vm::ptr<u32> id, u32 num, s32 prio, vm::ptr<sys_spu_thread_group_attribute> 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<u32> cause, vm::ptr<u32> 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<s32> 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<u8> 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<u64> 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<u64> 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<u32> 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<s32> 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<u8> 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<u64> 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<u64> 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<u32> status);
error_code sys_spu_thread_recover_page_fault(ppu_thread&, u32 id);
error_code sys_raw_spu_create(vm::ptr<u32> id, vm::ptr<void> attr);
error_code sys_raw_spu_create(ppu_thread&, vm::ptr<u32> id, vm::ptr<void> 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<u32> 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<u64> 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<u64> stat);
error_code sys_raw_spu_read_puint_mb(u32 id, vm::ptr<u32> 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<u32> 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<u32> 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<u64> 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<u64> stat);
error_code sys_raw_spu_read_puint_mb(ppu_thread&, u32 id, vm::ptr<u32> 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<u32> value);
error_code sys_raw_spu_recover_page_fault(ppu_thread&, u32 id);