Statistics
| Branch: | Revision:

root / qemu-timer.h @ d9346e81

History | View | Annotate | Download (2.1 kB)

1 87ecb68b pbrook
#ifndef QEMU_TIMER_H
2 87ecb68b pbrook
#define QEMU_TIMER_H
3 87ecb68b pbrook
4 87ecb68b pbrook
/* timers */
5 87ecb68b pbrook
6 87ecb68b pbrook
typedef struct QEMUClock QEMUClock;
7 87ecb68b pbrook
typedef void QEMUTimerCB(void *opaque);
8 87ecb68b pbrook
9 87ecb68b pbrook
/* The real time clock should be used only for stuff which does not
10 87ecb68b pbrook
   change the virtual machine state, as it is run even if the virtual
11 87ecb68b pbrook
   machine is stopped. The real time clock has a frequency of 1000
12 87ecb68b pbrook
   Hz. */
13 87ecb68b pbrook
extern QEMUClock *rt_clock;
14 87ecb68b pbrook
15 87ecb68b pbrook
/* The virtual clock is only run during the emulation. It is stopped
16 87ecb68b pbrook
   when the virtual machine is stopped. Virtual timers use a high
17 87ecb68b pbrook
   precision clock, usually cpu cycles (use ticks_per_sec). */
18 87ecb68b pbrook
extern QEMUClock *vm_clock;
19 87ecb68b pbrook
20 21d5d12b Jan Kiszka
/* The host clock should be use for device models that emulate accurate
21 21d5d12b Jan Kiszka
   real time sources. It will continue to run when the virtual machine
22 21d5d12b Jan Kiszka
   is suspended, and it will reflect system time changes the host may
23 21d5d12b Jan Kiszka
   undergo (e.g. due to NTP). The host clock has the same precision as
24 21d5d12b Jan Kiszka
   the virtual clock. */
25 21d5d12b Jan Kiszka
extern QEMUClock *host_clock;
26 21d5d12b Jan Kiszka
27 87ecb68b pbrook
int64_t qemu_get_clock(QEMUClock *clock);
28 41c872b6 Paolo Bonzini
int64_t qemu_get_clock_ns(QEMUClock *clock);
29 87ecb68b pbrook
30 87ecb68b pbrook
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
31 87ecb68b pbrook
void qemu_free_timer(QEMUTimer *ts);
32 87ecb68b pbrook
void qemu_del_timer(QEMUTimer *ts);
33 87ecb68b pbrook
void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
34 87ecb68b pbrook
int qemu_timer_pending(QEMUTimer *ts);
35 2430ffe4 Stefano Stabellini
int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
36 87ecb68b pbrook
37 274dfed8 Anthony Liguori
static inline int64_t get_ticks_per_sec(void)
38 274dfed8 Anthony Liguori
{
39 274dfed8 Anthony Liguori
    return 1000000000LL;
40 274dfed8 Anthony Liguori
}
41 87ecb68b pbrook
42 87ecb68b pbrook
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
43 87ecb68b pbrook
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
44 87ecb68b pbrook
45 87ecb68b pbrook
/* ptimer.c */
46 87ecb68b pbrook
typedef struct ptimer_state ptimer_state;
47 87ecb68b pbrook
typedef void (*ptimer_cb)(void *opaque);
48 87ecb68b pbrook
49 87ecb68b pbrook
ptimer_state *ptimer_init(QEMUBH *bh);
50 87ecb68b pbrook
void ptimer_set_period(ptimer_state *s, int64_t period);
51 87ecb68b pbrook
void ptimer_set_freq(ptimer_state *s, uint32_t freq);
52 87ecb68b pbrook
void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload);
53 87ecb68b pbrook
uint64_t ptimer_get_count(ptimer_state *s);
54 87ecb68b pbrook
void ptimer_set_count(ptimer_state *s, uint64_t count);
55 87ecb68b pbrook
void ptimer_run(ptimer_state *s, int oneshot);
56 87ecb68b pbrook
void ptimer_stop(ptimer_state *s);
57 87ecb68b pbrook
void qemu_put_ptimer(QEMUFile *f, ptimer_state *s);
58 87ecb68b pbrook
void qemu_get_ptimer(QEMUFile *f, ptimer_state *s);
59 87ecb68b pbrook
60 87ecb68b pbrook
#endif