root / qemu-timer.h @ ccd59d09
History | View | Annotate | Download (1.7 kB)
1 |
#ifndef QEMU_TIMER_H
|
---|---|
2 |
#define QEMU_TIMER_H
|
3 |
|
4 |
/* timers */
|
5 |
|
6 |
typedef struct QEMUClock QEMUClock; |
7 |
typedef void QEMUTimerCB(void *opaque); |
8 |
|
9 |
/* The real time clock should be used only for stuff which does not
|
10 |
change the virtual machine state, as it is run even if the virtual
|
11 |
machine is stopped. The real time clock has a frequency of 1000
|
12 |
Hz. */
|
13 |
extern QEMUClock *rt_clock;
|
14 |
|
15 |
/* The virtual clock is only run during the emulation. It is stopped
|
16 |
when the virtual machine is stopped. Virtual timers use a high
|
17 |
precision clock, usually cpu cycles (use ticks_per_sec). */
|
18 |
extern QEMUClock *vm_clock;
|
19 |
|
20 |
int64_t qemu_get_clock(QEMUClock *clock); |
21 |
|
22 |
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
|
23 |
void qemu_free_timer(QEMUTimer *ts);
|
24 |
void qemu_del_timer(QEMUTimer *ts);
|
25 |
void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
|
26 |
int qemu_timer_pending(QEMUTimer *ts);
|
27 |
int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
|
28 |
|
29 |
static inline int64_t get_ticks_per_sec(void) |
30 |
{ |
31 |
return 1000000000LL; |
32 |
} |
33 |
|
34 |
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
|
35 |
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
|
36 |
|
37 |
/* ptimer.c */
|
38 |
typedef struct ptimer_state ptimer_state; |
39 |
typedef void (*ptimer_cb)(void *opaque); |
40 |
|
41 |
ptimer_state *ptimer_init(QEMUBH *bh); |
42 |
void ptimer_set_period(ptimer_state *s, int64_t period);
|
43 |
void ptimer_set_freq(ptimer_state *s, uint32_t freq);
|
44 |
void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload); |
45 |
uint64_t ptimer_get_count(ptimer_state *s); |
46 |
void ptimer_set_count(ptimer_state *s, uint64_t count);
|
47 |
void ptimer_run(ptimer_state *s, int oneshot); |
48 |
void ptimer_stop(ptimer_state *s);
|
49 |
void qemu_put_ptimer(QEMUFile *f, ptimer_state *s);
|
50 |
void qemu_get_ptimer(QEMUFile *f, ptimer_state *s);
|
51 |
|
52 |
#endif
|