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

51 lines
930 B
C
Raw Normal View History

2014-06-21 16:24:27 +02:00
#pragma once
#include "Utilities/SleepQueue.h"
2015-07-21 13:55:29 +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;
};
};
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;
2015-07-21 13:55:29 +02:00
sleep_queue_t sq;
2015-03-08 04:37:07 +01: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)
2014-06-21 16:24:27 +02:00
{
}
};
2015-07-21 13:55:29 +02:00
// Aux
class PPUThread;
// SysCalls
2015-07-21 13:55:29 +02:00
s32 sys_semaphore_create(vm::ptr<u32> sem_id, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val);
s32 sys_semaphore_destroy(u32 sem_id);
s32 sys_semaphore_wait(PPUThread& ppu, u32 sem_id, u64 timeout);
s32 sys_semaphore_trywait(u32 sem_id);
s32 sys_semaphore_post(u32 sem_id, s32 count);
s32 sys_semaphore_get_value(u32 sem_id, vm::ptr<s32> count);