2014-06-21 16:24:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2016-04-14 00:23:53 +02:00
|
|
|
#include "sys_sync.h"
|
2015-06-19 17:49:38 +02:00
|
|
|
|
2018-09-26 00:14:10 +02:00
|
|
|
#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
|
|
|
|
|
{
|
2019-10-25 16:50:46 +02:00
|
|
|
nse_t<u64, 1> name_u64;
|
2019-07-08 19:00:27 +02:00
|
|
|
char name[sizeof(u64)];
|
2014-06-21 16:24:27 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-29 17:50:18 +01: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
|
|
|
|
2018-11-26 16:55:22 +01: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)
|
2020-02-21 13:20:10 +01:00
|
|
|
, flags(flags)
|
2017-01-31 00:09:55 +01:00
|
|
|
, max(max)
|
|
|
|
|
, val(value)
|
2014-06-21 16:24:27 +02:00
|
|
|
{
|
|
|
|
|
}
|
2014-06-25 00:38:34 +02:00
|
|
|
};
|
|
|
|
|
|
2015-07-21 13:55:29 +02:00
|
|
|
// Aux
|
2016-07-27 23:43:22 +02:00
|
|
|
class ppu_thread;
|
2015-07-21 13:55:29 +02:00
|
|
|
|
2017-01-31 00:09:55 +01:00
|
|
|
// Syscalls
|
|
|
|
|
|
2019-07-14 17:18:03 +02:00
|
|
|
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);
|
2019-07-14 17:18:03 +02:00
|
|
|
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);
|
2019-07-14 17:18:03 +02:00
|
|
|
error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> count);
|