xref: /qemu/include/system/cpu-timers.h (revision 161f5bc8e965fa8255db435683e6b52042037bb7)
1 /*
2  * CPU timers state API
3  *
4  * Copyright 2020 SUSE LLC
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  *
9  */
10 #ifndef SYSTEM_CPU_TIMERS_H
11 #define SYSTEM_CPU_TIMERS_H
12 
13 #include "qemu/timer.h"
14 
15 /* init the whole cpu timers API, including icount, ticks, and cpu_throttle */
16 void cpu_timers_init(void);
17 
18 /*
19  * CPU Ticks and Clock
20  */
21 
22 /* Caller must hold BQL */
23 void cpu_enable_ticks(void);
24 /* Caller must hold BQL */
25 void cpu_disable_ticks(void);
26 
27 /*
28  * return the time elapsed in VM between vm_start and vm_stop.
29  * cpu_get_ticks() uses units of the host CPU cycle counter.
30  */
31 int64_t cpu_get_ticks(void);
32 
33 /*
34  * Returns the monotonic time elapsed in VM, i.e.,
35  * the time between vm_start and vm_stop
36  */
37 int64_t cpu_get_clock(void);
38 
39 void qemu_timer_notify_cb(void *opaque, QEMUClockType type);
40 
41 /* get/set VIRTUAL clock and VM elapsed ticks via the cpus accel interface */
42 int64_t cpus_get_virtual_clock(void);
43 void cpus_set_virtual_clock(int64_t new_time);
44 int64_t cpus_get_elapsed_ticks(void);
45 
46 #endif /* SYSTEM_CPU_TIMERS_H */
47