2014-06-25 00:38:34 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2015-06-19 17:49:38 +02:00
|
|
|
#include "Utilities/Thread.h"
|
|
|
|
|
|
|
|
|
|
namespace vm { using namespace ps3; }
|
|
|
|
|
|
2015-03-08 16:25:31 +01:00
|
|
|
// Timer State
|
|
|
|
|
enum : u32
|
2014-06-25 00:38:34 +02:00
|
|
|
{
|
2015-03-08 16:25:31 +01:00
|
|
|
SYS_TIMER_STATE_STOP = 0,
|
|
|
|
|
SYS_TIMER_STATE_RUN = 1,
|
2014-06-25 00:38:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct sys_timer_information_t
|
|
|
|
|
{
|
2015-03-08 16:25:31 +01:00
|
|
|
be_t<s64> next_expiration_time;
|
|
|
|
|
be_t<u64> period;
|
|
|
|
|
be_t<u32> timer_state;
|
|
|
|
|
be_t<u32> pad;
|
2014-06-25 00:38:34 +02:00
|
|
|
};
|
|
|
|
|
|
2016-04-14 00:23:53 +02:00
|
|
|
class lv2_timer_t final : public named_thread
|
2014-06-25 00:38:34 +02:00
|
|
|
{
|
2015-11-26 09:06:29 +01:00
|
|
|
void on_task() override;
|
|
|
|
|
|
2016-04-14 00:23:53 +02:00
|
|
|
public:
|
2016-04-25 12:49:12 +02:00
|
|
|
std::string get_name() const override;
|
|
|
|
|
|
|
|
|
|
void on_stop() override;
|
2015-11-26 09:06:29 +01:00
|
|
|
|
2016-04-27 00:27:24 +02:00
|
|
|
const id_value<> id{};
|
2015-11-26 09:06:29 +01:00
|
|
|
|
2016-04-14 00:23:53 +02:00
|
|
|
atomic_t<u32> state{ SYS_TIMER_STATE_RUN }; // Timer state
|
2015-11-26 09:06:29 +01:00
|
|
|
|
2016-04-14 00:23:53 +02:00
|
|
|
std::weak_ptr<lv2_event_queue_t> port; // Event queue
|
|
|
|
|
u64 source; // Event source
|
|
|
|
|
u64 data1; // Event arg 1
|
|
|
|
|
u64 data2; // Event arg 2
|
2015-03-08 16:25:31 +01:00
|
|
|
|
2016-04-14 00:23:53 +02:00
|
|
|
u64 expire = 0; // Next expiration time
|
|
|
|
|
u64 period = 0; // Period (oneshot if 0)
|
2014-06-25 00:38:34 +02:00
|
|
|
};
|
|
|
|
|
|
2015-06-22 00:27:58 +02:00
|
|
|
s32 sys_timer_create(vm::ptr<u32> timer_id);
|
2014-06-25 00:38:34 +02:00
|
|
|
s32 sys_timer_destroy(u32 timer_id);
|
2014-09-02 03:05:13 +02:00
|
|
|
s32 sys_timer_get_information(u32 timer_id, vm::ptr<sys_timer_information_t> info);
|
2015-03-08 16:25:31 +01:00
|
|
|
s32 _sys_timer_start(u32 timer_id, u64 basetime, u64 period); // basetime type changed from s64
|
2014-06-25 00:38:34 +02:00
|
|
|
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);
|