]> git.proxmox.com Git - mirror_qemu.git/blame - qemu-timer.h
Implement multi-level page tables.
[mirror_qemu.git] / qemu-timer.h
CommitLineData
87ecb68b
PB
1#ifndef QEMU_TIMER_H
2#define QEMU_TIMER_H
3
4/* timers */
5
6typedef struct QEMUClock QEMUClock;
7typedef 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. */
13extern 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). */
18extern QEMUClock *vm_clock;
19
21d5d12b
JK
20/* The host clock should be use for device models that emulate accurate
21 real time sources. It will continue to run when the virtual machine
22 is suspended, and it will reflect system time changes the host may
23 undergo (e.g. due to NTP). The host clock has the same precision as
24 the virtual clock. */
25extern QEMUClock *host_clock;
26
87ecb68b 27int64_t qemu_get_clock(QEMUClock *clock);
41c872b6 28int64_t qemu_get_clock_ns(QEMUClock *clock);
87ecb68b
PB
29
30QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
31void qemu_free_timer(QEMUTimer *ts);
32void qemu_del_timer(QEMUTimer *ts);
33void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
34int qemu_timer_pending(QEMUTimer *ts);
2430ffe4 35int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
87ecb68b 36
274dfed8
AL
37static inline int64_t get_ticks_per_sec(void)
38{
39 return 1000000000LL;
40}
87ecb68b
PB
41
42void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
43void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
44
45/* ptimer.c */
46typedef struct ptimer_state ptimer_state;
47typedef void (*ptimer_cb)(void *opaque);
48
49ptimer_state *ptimer_init(QEMUBH *bh);
50void ptimer_set_period(ptimer_state *s, int64_t period);
51void ptimer_set_freq(ptimer_state *s, uint32_t freq);
52void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload);
53uint64_t ptimer_get_count(ptimer_state *s);
54void ptimer_set_count(ptimer_state *s, uint64_t count);
55void ptimer_run(ptimer_state *s, int oneshot);
56void ptimer_stop(ptimer_state *s);
57void qemu_put_ptimer(QEMUFile *f, ptimer_state *s);
58void qemu_get_ptimer(QEMUFile *f, ptimer_state *s);
59
60#endif