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

60 lines
1.3 KiB
C
Raw Normal View History

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