mc146818rtc.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * QEMU MC146818 RTC emulation
  3. *
  4. * Copyright (c) 2003-2004 Fabrice Bellard
  5. *
  6. * SPDX-License-Identifier: MIT
  7. */
  8. #ifndef HW_RTC_MC146818RTC_H
  9. #define HW_RTC_MC146818RTC_H
  10. #include "qapi/qapi-types-machine.h"
  11. #include "qemu/queue.h"
  12. #include "qemu/timer.h"
  13. #include "hw/isa/isa.h"
  14. #include "qom/object.h"
  15. #define TYPE_MC146818_RTC "mc146818rtc"
  16. OBJECT_DECLARE_SIMPLE_TYPE(MC146818RtcState, MC146818_RTC)
  17. struct MC146818RtcState {
  18. ISADevice parent_obj;
  19. MemoryRegion io;
  20. MemoryRegion coalesced_io;
  21. uint8_t cmos_data[128];
  22. uint8_t cmos_index;
  23. uint8_t isairq;
  24. uint16_t io_base;
  25. int32_t base_year;
  26. uint64_t base_rtc;
  27. uint64_t last_update;
  28. int64_t offset;
  29. qemu_irq irq;
  30. int it_shift;
  31. /* periodic timer */
  32. QEMUTimer *periodic_timer;
  33. int64_t next_periodic_time;
  34. /* update-ended timer */
  35. QEMUTimer *update_timer;
  36. uint64_t next_alarm_time;
  37. uint16_t irq_reinject_on_ack_count;
  38. uint32_t irq_coalesced;
  39. uint32_t period;
  40. QEMUTimer *coalesced_timer;
  41. Notifier clock_reset_notifier;
  42. LostTickPolicy lost_tick_policy;
  43. Notifier suspend_notifier;
  44. QLIST_ENTRY(MC146818RtcState) link;
  45. };
  46. #define RTC_ISA_IRQ 8
  47. MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year,
  48. qemu_irq intercept_irq);
  49. void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int val);
  50. int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr);
  51. void rtc_reset_reinjection(MC146818RtcState *rtc);
  52. #endif /* HW_RTC_MC146818RTC_H */