mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
sys_semaphore: add vm::temporary_unlock
This commit is contained in:
parent
6126a98111
commit
bc1617758c
@ -957,25 +957,25 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
||||
// Intialise SPURS context
|
||||
const bool isSecond = (flags & SAF_SECOND_VERSION) != 0;
|
||||
|
||||
auto rollback = [=]
|
||||
auto rollback = [&]
|
||||
{
|
||||
if (spurs->semPrv)
|
||||
{
|
||||
sys_semaphore_destroy((u32)spurs->semPrv);
|
||||
sys_semaphore_destroy(ppu, ::narrow<u32>(+spurs->semPrv));
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++)
|
||||
{
|
||||
if (spurs->wklF1[i].sem)
|
||||
{
|
||||
sys_semaphore_destroy((u32)spurs->wklF1[i].sem);
|
||||
sys_semaphore_destroy(ppu, ::narrow<u32>(+spurs->wklF1[i].sem));
|
||||
}
|
||||
|
||||
if (isSecond)
|
||||
{
|
||||
if (spurs->wklF2[i].sem)
|
||||
{
|
||||
sys_semaphore_destroy((u32)spurs->wklF2[i].sem);
|
||||
sys_semaphore_destroy(ppu, ::narrow<u32>(+spurs->wklF2[i].sem));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1018,7 +1018,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
||||
|
||||
for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++)
|
||||
{
|
||||
if (s32 rc = sys_semaphore_create(sem, semAttr, 0, 1))
|
||||
if (s32 rc = sys_semaphore_create(ppu, sem, semAttr, 0, 1))
|
||||
{
|
||||
return rollback(), rc;
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
||||
|
||||
if (isSecond)
|
||||
{
|
||||
if (s32 rc = sys_semaphore_create(sem, semAttr, 0, 1))
|
||||
if (s32 rc = sys_semaphore_create(ppu, sem, semAttr, 0, 1))
|
||||
{
|
||||
return rollback(), rc;
|
||||
}
|
||||
@ -1038,7 +1038,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
||||
|
||||
// Create semaphore
|
||||
semAttr->name_u64 = "_spuPrv\0"_u64;
|
||||
if (s32 rc = sys_semaphore_create(sem, semAttr, 0, 1))
|
||||
if (s32 rc = sys_semaphore_create(ppu, sem, semAttr, 0, 1))
|
||||
{
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
@ -8,16 +8,16 @@
|
||||
#include "Emu/Cell/ErrorCodes.h"
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
|
||||
|
||||
|
||||
LOG_CHANNEL(sys_semaphore);
|
||||
|
||||
template<> DECLARE(ipc_manager<lv2_sema, u64>::g_ipc) {};
|
||||
|
||||
extern u64 get_system_time();
|
||||
|
||||
error_code sys_semaphore_create(vm::ptr<u32> sem_id, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val)
|
||||
error_code sys_semaphore_create(ppu_thread& ppu, vm::ptr<u32> sem_id, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val)
|
||||
{
|
||||
vm::temporary_unlock(ppu);
|
||||
|
||||
sys_semaphore.warning("sys_semaphore_create(sem_id=*0x%x, attr=*0x%x, initial_val=%d, max_val=%d)", sem_id, attr, initial_val, max_val);
|
||||
|
||||
if (!sem_id || !attr)
|
||||
@ -54,8 +54,10 @@ error_code sys_semaphore_create(vm::ptr<u32> sem_id, vm::ptr<sys_semaphore_attri
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sys_semaphore_destroy(u32 sem_id)
|
||||
error_code sys_semaphore_destroy(ppu_thread& ppu, u32 sem_id)
|
||||
{
|
||||
vm::temporary_unlock(ppu);
|
||||
|
||||
sys_semaphore.warning("sys_semaphore_destroy(sem_id=0x%x)", sem_id);
|
||||
|
||||
const auto sem = idm::withdraw<lv2_obj, lv2_sema>(sem_id, [](lv2_sema& sema) -> CellError
|
||||
@ -83,6 +85,8 @@ error_code sys_semaphore_destroy(u32 sem_id)
|
||||
|
||||
error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout)
|
||||
{
|
||||
vm::temporary_unlock(ppu);
|
||||
|
||||
sys_semaphore.trace("sys_semaphore_wait(sem_id=0x%x, timeout=0x%llx)", sem_id, timeout);
|
||||
|
||||
const auto sem = idm::get<lv2_obj, lv2_sema>(sem_id, [&](lv2_sema& sema)
|
||||
@ -165,8 +169,10 @@ error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout)
|
||||
return not_an_error(ppu.gpr[3]);
|
||||
}
|
||||
|
||||
error_code sys_semaphore_trywait(u32 sem_id)
|
||||
error_code sys_semaphore_trywait(ppu_thread& ppu, u32 sem_id)
|
||||
{
|
||||
vm::temporary_unlock(ppu);
|
||||
|
||||
sys_semaphore.trace("sys_semaphore_trywait(sem_id=0x%x)", sem_id);
|
||||
|
||||
const auto sem = idm::check<lv2_obj, lv2_sema>(sem_id, [&](lv2_sema& sema)
|
||||
@ -189,6 +195,8 @@ error_code sys_semaphore_trywait(u32 sem_id)
|
||||
|
||||
error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count)
|
||||
{
|
||||
vm::temporary_unlock(ppu);
|
||||
|
||||
sys_semaphore.trace("sys_semaphore_post(sem_id=0x%x, count=%d)", sem_id, count);
|
||||
|
||||
const auto sem = idm::get<lv2_obj, lv2_sema>(sem_id, [&](lv2_sema& sema)
|
||||
@ -247,8 +255,10 @@ error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sys_semaphore_get_value(u32 sem_id, vm::ptr<s32> count)
|
||||
error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> count)
|
||||
{
|
||||
vm::temporary_unlock(ppu);
|
||||
|
||||
sys_semaphore.trace("sys_semaphore_get_value(sem_id=0x%x, count=*0x%x)", sem_id, count);
|
||||
|
||||
if (!count)
|
||||
|
@ -51,9 +51,9 @@ class ppu_thread;
|
||||
|
||||
// Syscalls
|
||||
|
||||
error_code sys_semaphore_create(vm::ptr<u32> sem_id, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val);
|
||||
error_code sys_semaphore_destroy(u32 sem_id);
|
||||
error_code sys_semaphore_create(ppu_thread& ppu, vm::ptr<u32> sem_id, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val);
|
||||
error_code sys_semaphore_destroy(ppu_thread& ppu, u32 sem_id);
|
||||
error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout);
|
||||
error_code sys_semaphore_trywait(u32 sem_id);
|
||||
error_code sys_semaphore_trywait(ppu_thread& ppu, u32 sem_id);
|
||||
error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count);
|
||||
error_code sys_semaphore_get_value(u32 sem_id, vm::ptr<s32> count);
|
||||
error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> count);
|
||||
|
Loading…
Reference in New Issue
Block a user