rpcsx/rpcs3/Emu/Cell/lv2/sys_semaphore.h

56 lines
1.2 KiB
C
Raw Normal View History

2014-06-21 18:24:27 +04:00
#pragma once
2016-04-14 01:23:53 +03:00
#include "sys_sync.h"
#include "Emu/Memory/vm_ptr.h"
2015-03-08 06:37:07 +03:00
struct sys_semaphore_attribute_t
2014-06-21 18:24:27 +04:00
{
be_t<u32> protocol;
2015-03-08 06:37:07 +03:00
be_t<u32> pshared;
be_t<u64> ipc_key;
be_t<s32> flags;
be_t<u32> pad;
2014-06-21 18:24:27 +04:00
union
{
nse_t<u64, 1> name_u64;
char name[sizeof(u64)];
2014-06-21 18:24:27 +04:00
};
};
struct lv2_sema final : lv2_obj
2014-06-21 18:24:27 +04:00
{
2017-01-25 20:50:30 +03:00
static const u32 id_base = 0x96000000;
2020-06-09 18:35:14 +03:00
const lv2_protocol protocol;
2017-01-31 02:09:55 +03:00
const u64 key;
2014-06-21 18:24:27 +04:00
const u64 name;
2017-01-31 02:09:55 +03:00
const s32 max;
2014-06-21 18:24:27 +04:00
shared_mutex mutex;
2017-01-31 02:09:55 +03:00
atomic_t<s32> val;
std::deque<cpu_thread*> sq;
2015-03-08 06:37:07 +03:00
2021-05-08 20:08:25 +03:00
lv2_sema(u32 protocol, u64 key, u64 name, s32 max, s32 value) noexcept
: protocol{static_cast<u8>(protocol)}
2017-07-24 18:59:48 +03:00
, key(key)
2014-06-21 18:24:27 +04:00
, name(name)
2017-01-31 02:09:55 +03:00
, max(max)
, val(value)
2014-06-21 18:24:27 +04:00
{
}
};
2015-07-21 14:55:29 +03:00
// Aux
class ppu_thread;
2015-07-21 14:55:29 +03:00
2017-01-31 02:09:55 +03:00
// Syscalls
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);
2017-01-31 02:09:55 +03:00
error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout);
error_code sys_semaphore_trywait(ppu_thread& ppu, u32 sem_id);
2017-02-06 21:36:46 +03:00
error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count);
error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> count);