cpu-timers-internal.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * QEMU System Emulator
  3. *
  4. * Copyright (c) 2003-2008 Fabrice Bellard
  5. *
  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:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  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.
  23. */
  24. #ifndef TIMERS_STATE_H
  25. #define TIMERS_STATE_H
  26. /* timers state, for sharing between icount and cpu-timers */
  27. typedef struct TimersState {
  28. /* Protected by BQL. */
  29. int64_t cpu_ticks_prev;
  30. int64_t cpu_ticks_offset;
  31. /*
  32. * Protect fields that can be respectively read outside the
  33. * BQL, and written from multiple threads.
  34. */
  35. QemuSeqLock vm_clock_seqlock;
  36. QemuSpin vm_clock_lock;
  37. int16_t cpu_ticks_enabled;
  38. /* Conversion factor from emulated instructions to virtual clock ticks. */
  39. int16_t icount_time_shift;
  40. /* Icount delta used for shift auto adjust. */
  41. int64_t last_delta;
  42. /* Compensate for varying guest execution speed. */
  43. aligned_int64_t qemu_icount_bias;
  44. int64_t vm_clock_warp_start;
  45. int64_t cpu_clock_offset;
  46. /* Only written by TCG thread */
  47. int64_t qemu_icount;
  48. /* for adjusting icount */
  49. QEMUTimer *icount_rt_timer;
  50. QEMUTimer *icount_vm_timer;
  51. QEMUTimer *icount_warp_timer;
  52. } TimersState;
  53. extern TimersState timers_state;
  54. /*
  55. * icount needs this internal from cpu-timers when adjusting the icount shift.
  56. */
  57. int64_t cpu_get_clock_locked(void);
  58. #endif /* TIMERS_STATE_H */