2 * QEMU MC146818 RTC emulation
4 * Copyright (c) 2003-2004 Fabrice Bellard
6 * SPDX-License-Identifier: MIT
9 #ifndef HW_RTC_MC146818RTC_H
10 #define HW_RTC_MC146818RTC_H
12 #include "qapi/qapi-types-misc.h"
13 #include "qemu/queue.h"
14 #include "qemu/timer.h"
15 #include "hw/isa/isa.h"
17 #define TYPE_MC146818_RTC "mc146818rtc"
18 #define MC146818_RTC(obj) OBJECT_CHECK(RTCState, (obj), TYPE_MC146818_RTC)
20 typedef struct RTCState
{
24 MemoryRegion coalesced_io
;
25 uint8_t cmos_data
[128];
34 QEMUTimer
*periodic_timer
;
35 int64_t next_periodic_time
;
36 /* update-ended timer */
37 QEMUTimer
*update_timer
;
38 uint64_t next_alarm_time
;
39 uint16_t irq_reinject_on_ack_count
;
40 uint32_t irq_coalesced
;
42 QEMUTimer
*coalesced_timer
;
43 Notifier clock_reset_notifier
;
44 LostTickPolicy lost_tick_policy
;
45 Notifier suspend_notifier
;
46 QLIST_ENTRY(RTCState
) link
;
51 ISADevice
*mc146818_rtc_init(ISABus
*bus
, int base_year
,
52 qemu_irq intercept_irq
);
53 void rtc_set_memory(ISADevice
*dev
, int addr
, int val
);
54 int rtc_get_memory(ISADevice
*dev
, int addr
);
56 #endif /* MC146818RTC_H */