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