4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #ifndef TIMERS_STATE_H
26 #define TIMERS_STATE_H
28 /* timers state, for sharing between icount and cpu-timers */
30 typedef struct TimersState
{
31 /* Protected by BQL. */
32 int64_t cpu_ticks_prev
;
33 int64_t cpu_ticks_offset
;
36 * Protect fields that can be respectively read outside the
37 * BQL, and written from multiple threads.
39 QemuSeqLock vm_clock_seqlock
;
40 QemuSpin vm_clock_lock
;
42 int16_t cpu_ticks_enabled
;
44 /* Conversion factor from emulated instructions to virtual clock ticks. */
45 int16_t icount_time_shift
;
47 /* Compensate for varying guest execution speed. */
48 int64_t qemu_icount_bias
;
50 int64_t vm_clock_warp_start
;
51 int64_t cpu_clock_offset
;
53 /* Only written by TCG thread */
56 /* for adjusting icount */
57 QEMUTimer
*icount_rt_timer
;
58 QEMUTimer
*icount_vm_timer
;
59 QEMUTimer
*icount_warp_timer
;
62 extern TimersState timers_state
;
65 * icount needs this internal from cpu-timers when adjusting the icount shift.
67 int64_t cpu_get_clock_locked(void);
69 #endif /* TIMERS_STATE_H */