From 9ba0a9189b4a06d86911c5ee5f118b85e2bb66a0 Mon Sep 17 00:00:00 2001 From: scribam Date: Sat, 8 Apr 2017 17:42:28 +0200 Subject: [PATCH] Update sys_spu - Implement sys_spu_thread_group_set_priority - Implement sys_spu_thread_group_get_priority --- rpcs3/Emu/Cell/lv2/lv2.cpp | 4 +-- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 49 ++++++++++++++++++++++++++++++++++ rpcs3/Emu/Cell/lv2/sys_spu.h | 2 ++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 008d683baa..fd19e45ca2 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -238,8 +238,8 @@ std::array g_ppu_syscall_table BIND_FUNC(sys_spu_thread_group_yield), //176 (0x0B0) BIND_FUNC(sys_spu_thread_group_terminate), //177 (0x0B1) BIND_FUNC(sys_spu_thread_group_join), //178 (0x0B2) - null_func,//BIND_FUNC(sys_spu_thread_group_set_priority)//179 (0x0B3) - null_func,//BIND_FUNC(sys_spu_thread_group_get_priority)//180 (0x0B4) + BIND_FUNC(sys_spu_thread_group_set_priority), //179 (0x0B3) + BIND_FUNC(sys_spu_thread_group_get_priority), //180 (0x0B4) BIND_FUNC(sys_spu_thread_write_ls), //181 (0x0B5) BIND_FUNC(sys_spu_thread_read_ls), //182 (0x0B6) null_func, //183 (0x0B7) UNS diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index d0761b554c..b12d7da23c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -606,6 +606,55 @@ 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) +{ + sys_spu.trace("sys_spu_thread_group_set_priority(id=0x%x, priority=%d)", id, priority); + + if (priority < 16 || priority > 255) + { + return CELL_EINVAL; + } + + const auto group = idm::get(id); + + if (!group) + { + return CELL_ESRCH; + } + + if (group->type == SYS_SPU_THREAD_GROUP_TYPE_EXCLUSIVE_NON_CONTEXT) + { + return CELL_EINVAL; + } + + group->prio = priority; + + return CELL_OK; +} + +error_code sys_spu_thread_group_get_priority(u32 id, vm::ptr priority) +{ + sys_spu.trace("sys_spu_thread_group_get_priority(id=0x%x, priority=*0x%x)", id, priority); + + const auto group = idm::get(id); + + if (!group) + { + return CELL_ESRCH; + } + + if (group->type == SYS_SPU_THREAD_GROUP_TYPE_EXCLUSIVE_NON_CONTEXT) + { + *priority = 0; + } + else + { + *priority = group->prio; + } + + return CELL_OK; +} + error_code sys_spu_thread_write_ls(u32 id, u32 lsa, u64 value, u32 type) { sys_spu.trace("sys_spu_thread_write_ls(id=0x%x, lsa=0x%05x, value=0x%llx, type=%d)", id, lsa, value, type); diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.h b/rpcs3/Emu/Cell/lv2/sys_spu.h index 448707b55c..55b69da1b0 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.h +++ b/rpcs3/Emu/Cell/lv2/sys_spu.h @@ -222,6 +222,8 @@ 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_join(ppu_thread&, u32 id, vm::ps3::ptr cause, vm::ps3::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::ps3::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::ps3::ptr spup);