sys_event_flag: add vm::temporary_unlock

This commit is contained in:
Nekotekina 2019-07-14 17:37:58 +03:00
parent 22e4ef147a
commit 7398cfc950
2 changed files with 26 additions and 12 deletions

View File

@ -10,16 +10,16 @@
#include <algorithm>
LOG_CHANNEL(sys_event_flag);
template<> DECLARE(ipc_manager<lv2_event_flag, u64>::g_ipc) {};
extern u64 get_system_time();
error_code sys_event_flag_create(vm::ptr<u32> id, vm::ptr<sys_event_flag_attribute_t> attr, u64 init)
error_code sys_event_flag_create(ppu_thread& ppu, vm::ptr<u32> id, vm::ptr<sys_event_flag_attribute_t> attr, u64 init)
{
vm::temporary_unlock(ppu);
sys_event_flag.warning("sys_event_flag_create(id=*0x%x, attr=*0x%x, init=0x%llx)", id, attr, init);
if (!id || !attr)
@ -62,8 +62,10 @@ error_code sys_event_flag_create(vm::ptr<u32> id, vm::ptr<sys_event_flag_attribu
return CELL_OK;
}
error_code sys_event_flag_destroy(u32 id)
error_code sys_event_flag_destroy(ppu_thread& ppu, u32 id)
{
vm::temporary_unlock(ppu);
sys_event_flag.warning("sys_event_flag_destroy(id=0x%x)", id);
const auto flag = idm::withdraw<lv2_obj, lv2_event_flag>(id, [&](lv2_event_flag& flag) -> CellError
@ -91,6 +93,8 @@ error_code sys_event_flag_destroy(u32 id)
error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result, u64 timeout)
{
vm::temporary_unlock(ppu);
sys_event_flag.trace("sys_event_flag_wait(id=0x%x, bitptn=0x%llx, mode=0x%x, result=*0x%x, timeout=0x%llx)", id, bitptn, mode, result, timeout);
// Fix function arguments for external access
@ -202,8 +206,10 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
return not_an_error(ppu.gpr[3]);
}
error_code sys_event_flag_trywait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result)
error_code sys_event_flag_trywait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result)
{
vm::temporary_unlock(ppu);
sys_event_flag.trace("sys_event_flag_trywait(id=0x%x, bitptn=0x%llx, mode=0x%x, result=*0x%x)", id, bitptn, mode, result);
if (result) *result = 0;
@ -240,6 +246,8 @@ error_code sys_event_flag_trywait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> res
error_code sys_event_flag_set(u32 id, u64 bitptn)
{
vm::temporary_unlock();
// Warning: may be called from SPU thread.
sys_event_flag.trace("sys_event_flag_set(id=0x%x, bitptn=0x%llx)", id, bitptn);
@ -321,8 +329,10 @@ error_code sys_event_flag_set(u32 id, u64 bitptn)
return CELL_OK;
}
error_code sys_event_flag_clear(u32 id, u64 bitptn)
error_code sys_event_flag_clear(ppu_thread& ppu, u32 id, u64 bitptn)
{
vm::temporary_unlock(ppu);
sys_event_flag.trace("sys_event_flag_clear(id=0x%x, bitptn=0x%llx)", id, bitptn);
const auto flag = idm::check<lv2_obj, lv2_event_flag>(id, [&](lv2_event_flag& flag)
@ -340,6 +350,8 @@ error_code sys_event_flag_clear(u32 id, u64 bitptn)
error_code sys_event_flag_cancel(ppu_thread& ppu, u32 id, vm::ptr<u32> num)
{
vm::temporary_unlock(ppu);
sys_event_flag.trace("sys_event_flag_cancel(id=0x%x, num=*0x%x)", id, num);
if (num) *num = 0;
@ -383,8 +395,10 @@ error_code sys_event_flag_cancel(ppu_thread& ppu, u32 id, vm::ptr<u32> num)
return CELL_OK;
}
error_code sys_event_flag_get(u32 id, vm::ptr<u64> flags)
error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr<u64> flags)
{
vm::temporary_unlock(ppu);
sys_event_flag.trace("sys_event_flag_get(id=0x%x, flags=*0x%x)", id, flags);
if (!flags)

View File

@ -114,11 +114,11 @@ class ppu_thread;
// Syscalls
error_code sys_event_flag_create(vm::ptr<u32> id, vm::ptr<sys_event_flag_attribute_t> attr, u64 init);
error_code sys_event_flag_destroy(u32 id);
error_code sys_event_flag_create(ppu_thread& ppu, vm::ptr<u32> id, vm::ptr<sys_event_flag_attribute_t> attr, u64 init);
error_code sys_event_flag_destroy(ppu_thread& ppu, u32 id);
error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result, u64 timeout);
error_code sys_event_flag_trywait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result);
error_code sys_event_flag_trywait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result);
error_code sys_event_flag_set(u32 id, u64 bitptn);
error_code sys_event_flag_clear(u32 id, u64 bitptn);
error_code sys_event_flag_clear(ppu_thread& ppu, u32 id, u64 bitptn);
error_code sys_event_flag_cancel(ppu_thread& ppu, u32 id, vm::ptr<u32> num);
error_code sys_event_flag_get(u32 id, vm::ptr<u64> flags);
error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr<u64> flags);