rpcsx/rpcs3/Emu/Cell/lv2/sys_timer.h
Nekotekina 1b37e775be Migration to named_thread<>
Add atomic_t<>::try_dec instead of fetch_dec_sat
Add atomic_t<>::try_inc
GDBDebugServer is broken (needs rewrite)
Removed old_thread class (former named_thread)
Removed storing/rethrowing exceptions from thread
Emu.Stop doesn't inject an exception anymore
task_stack helper class removed
thread_base simplified (no shared_from_this)
thread_ctrl::spawn simplified (creates detached thread)
Implemented overrideable thread detaching logic
Disabled cellAdec, cellDmux, cellFsAio
SPUThread renamed to spu_thread
RawSPUThread removed, spu_thread used instead
Disabled deriving from ppu_thread
Partial support for thread renaming
lv2_timer... simplified, screw it
idm/fxm: butchered support for on_stop/on_init
vm: improved allocation structure (added size)
2018-10-19 22:22:35 +03:00

54 lines
1.3 KiB
C++

#pragma once
#include "Utilities/Thread.h"
// Timer State
enum : u32
{
SYS_TIMER_STATE_STOP = 0,
SYS_TIMER_STATE_RUN = 1,
};
struct sys_timer_information_t
{
be_t<s64> next_expire;
be_t<u64> period;
be_t<u32> timer_state;
be_t<u32> pad;
};
struct lv2_timer_context : lv2_obj
{
static const u32 id_base = 0x11000000;
void operator()();
void on_abort();
semaphore<> mutex;
atomic_t<u32> state{SYS_TIMER_STATE_STOP};
std::weak_ptr<lv2_event_queue> port;
u64 source;
u64 data1;
u64 data2;
atomic_t<u64> expire{0}; // Next expiration time
atomic_t<u64> period{0}; // Period (oneshot if 0)
};
using lv2_timer = named_thread<lv2_timer_context>;
class ppu_thread;
// Syscalls
error_code sys_timer_create(vm::ptr<u32> timer_id);
error_code sys_timer_destroy(u32 timer_id);
error_code sys_timer_get_information(u32 timer_id, vm::ptr<sys_timer_information_t> info);
error_code _sys_timer_start(u32 timer_id, u64 basetime, u64 period); // basetime type changed from s64
error_code sys_timer_stop(u32 timer_id);
error_code sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data1, u64 data2);
error_code sys_timer_disconnect_event_queue(u32 timer_id);
error_code sys_timer_sleep(ppu_thread&, u32 sleep_time);
error_code sys_timer_usleep(ppu_thread&, u64 sleep_time);