rpcsx/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h

66 lines
1.4 KiB
C
Raw Normal View History

2014-08-08 17:55:12 +02:00
#pragma once
namespace vm { using namespace ps3; }
2014-08-08 17:55:12 +02:00
enum
{
SYS_SYNC_WAITER_SINGLE = 0x10000,
SYS_SYNC_WAITER_MULTIPLE = 0x20000,
SYS_EVENT_FLAG_WAIT_AND = 0x01,
SYS_EVENT_FLAG_WAIT_OR = 0x02,
SYS_EVENT_FLAG_WAIT_CLEAR = 0x10,
SYS_EVENT_FLAG_WAIT_CLEAR_ALL = 0x20,
};
2015-07-09 17:30:37 +02:00
struct sys_event_flag_attribute_t
2014-08-08 17:55:12 +02:00
{
be_t<u32> protocol;
be_t<u32> pshared;
be_t<u64> ipc_key;
2014-12-24 17:09:32 +01:00
be_t<s32> flags;
be_t<s32> type;
2015-03-05 22:29:05 +01:00
2014-12-24 17:09:32 +01:00
union
{
char name[8];
u64 name_u64;
};
2014-08-08 17:55:12 +02:00
};
struct lv2_event_flag_t
2014-08-08 17:55:12 +02:00
{
2014-12-23 00:31:11 +01:00
const u32 protocol;
const s32 type;
2014-12-24 17:09:32 +01:00
const u64 name;
2014-08-08 17:55:12 +02:00
2015-03-11 11:39:54 +01:00
std::atomic<u64> flags;
2015-03-11 16:30:50 +01:00
std::atomic<u32> cancelled;
2015-03-11 11:39:54 +01:00
2015-03-05 22:29:05 +01:00
// 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-05 22:29:05 +01:00
lv2_event_flag_t(u64 pattern, u32 protocol, s32 type, u64 name)
2015-03-05 22:29:05 +01:00
: flags(pattern)
, protocol(protocol)
2014-12-23 00:31:11 +01:00
, type(type)
2014-12-24 17:09:32 +01:00
, name(name)
2015-03-11 18:50:11 +01:00
, cancelled(0)
2015-03-05 22:29:05 +01:00
, waiters(0)
2014-08-08 17:55:12 +02:00
{
}
};
REG_ID_TYPE(lv2_event_flag_t, 0x98); // SYS_EVENT_FLAG_OBJECT
2015-07-09 17:30:37 +02:00
s32 sys_event_flag_create(vm::ptr<u32> id, vm::ptr<sys_event_flag_attribute_t> attr, u64 init);
2015-03-05 22:29:05 +01:00
s32 sys_event_flag_destroy(u32 id);
s32 sys_event_flag_wait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result, u64 timeout);
s32 sys_event_flag_trywait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result);
s32 sys_event_flag_set(u32 id, u64 bitptn);
s32 sys_event_flag_clear(u32 id, u64 bitptn);
s32 sys_event_flag_cancel(u32 id, vm::ptr<u32> num);
s32 sys_event_flag_get(u32 id, vm::ptr<u64> flags);