2014-06-21 16:24:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2015-06-19 17:49:38 +02:00
|
|
|
namespace vm { using namespace ps3; }
|
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
char name[8];
|
|
|
|
|
u64 name_u64;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-27 05:11:59 +02:00
|
|
|
struct lv2_sema_t
|
2014-06-21 16:24:27 +02:00
|
|
|
{
|
|
|
|
|
const u32 protocol;
|
2015-03-08 04:37:07 +01:00
|
|
|
const s32 max;
|
2014-06-21 16:24:27 +02:00
|
|
|
const u64 name;
|
|
|
|
|
|
2015-03-08 04:37:07 +01:00
|
|
|
std::atomic<s32> value;
|
|
|
|
|
|
|
|
|
|
// TODO: use sleep queue, possibly remove condition variable
|
|
|
|
|
std::condition_variable cv;
|
2015-03-11 16:30:50 +01:00
|
|
|
std::atomic<u32> waiters;
|
2015-03-08 04:37:07 +01:00
|
|
|
|
2015-05-27 05:11:59 +02:00
|
|
|
lv2_sema_t(u32 protocol, s32 max, u64 name, s32 value)
|
2015-03-08 04:37:07 +01:00
|
|
|
: protocol(protocol)
|
|
|
|
|
, max(max)
|
2014-06-21 16:24:27 +02:00
|
|
|
, name(name)
|
2015-03-08 04:37:07 +01:00
|
|
|
, value(value)
|
|
|
|
|
, waiters(0)
|
2014-06-21 16:24:27 +02:00
|
|
|
{
|
|
|
|
|
}
|
2014-06-25 00:38:34 +02:00
|
|
|
};
|
|
|
|
|
|
2015-05-27 05:11:59 +02:00
|
|
|
REG_ID_TYPE(lv2_sema_t, 0x96); // SYS_SEMAPHORE_OBJECT
|
2014-09-19 02:19:22 +02:00
|
|
|
|
2014-06-25 00:38:34 +02:00
|
|
|
// SysCalls
|
2015-03-08 04:37:07 +01:00
|
|
|
s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val);
|
|
|
|
|
s32 sys_semaphore_destroy(u32 sem);
|
|
|
|
|
s32 sys_semaphore_wait(u32 sem, u64 timeout);
|
|
|
|
|
s32 sys_semaphore_trywait(u32 sem);
|
|
|
|
|
s32 sys_semaphore_post(u32 sem, s32 count);
|
|
|
|
|
s32 sys_semaphore_get_value(u32 sem, vm::ptr<s32> count);
|