rpcsx/rpcs3/Emu/Cell/lv2/sys_timer.h
Nekotekina b21fce4d6f IdManager improved
lv2_obj for kernel objects
Simple lookup (vector)
Another idm API refactoring
2017-01-29 21:37:04 +03:00

53 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_expiration_time;
be_t<u64> period;
be_t<u32> timer_state;
be_t<u32> pad;
};
class lv2_timer final : public lv2_obj, public named_thread
{
void on_task() override;
public:
static const u32 id_base = 0x11000000;
std::string get_name() const override;
void on_stop() override;
const u32 id = idm::last_id();
atomic_t<u32> state{ SYS_TIMER_STATE_RUN }; // Timer state
std::weak_ptr<lv2_event_queue> port; // Event queue
u64 source; // Event source
u64 data1; // Event arg 1
u64 data2; // Event arg 2
u64 expire = 0; // Next expiration time
u64 period = 0; // Period (oneshot if 0)
};
s32 sys_timer_create(vm::ps3::ptr<u32> timer_id);
s32 sys_timer_destroy(u32 timer_id);
s32 sys_timer_get_information(u32 timer_id, vm::ps3::ptr<sys_timer_information_t> info);
s32 _sys_timer_start(u32 timer_id, u64 basetime, u64 period); // basetime type changed from s64
s32 sys_timer_stop(u32 timer_id);
s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data1, u64 data2);
s32 sys_timer_disconnect_event_queue(u32 timer_id);
s32 sys_timer_sleep(u32 sleep_time);
s32 sys_timer_usleep(u64 sleep_time);