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