Merge tag 'pull-la-20220729' of https://gitlab.com/rth7680/qemu into staging
[qemu/ar7.git] / softmmu / timers-state.h
blob94bb7394c5d7e962f09a4242f3337bef5a03fd31
1 /*
2 * QEMU System Emulator
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
22 * THE SOFTWARE.
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;
46 /* Icount delta used for shift auto adjust. */
47 int64_t last_delta;
49 /* Compensate for varying guest execution speed. */
50 aligned_int64_t qemu_icount_bias;
52 int64_t vm_clock_warp_start;
53 int64_t cpu_clock_offset;
55 /* Only written by TCG thread */
56 int64_t qemu_icount;
58 /* for adjusting icount */
59 QEMUTimer *icount_rt_timer;
60 QEMUTimer *icount_vm_timer;
61 QEMUTimer *icount_warp_timer;
62 } TimersState;
64 extern TimersState timers_state;
67 * icount needs this internal from cpu-timers when adjusting the icount shift.
69 int64_t cpu_get_clock_locked(void);
71 #endif /* TIMERS_STATE_H */