]>
Commit | Line | Data |
---|---|---|
bcdb9064 PMD |
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 | |
e1460e47 | 11 | |
53e4b801 HP |
12 | #include "qapi/qapi-types-misc.h" |
13 | #include "qemu/queue.h" | |
14 | #include "qemu/timer.h" | |
0d09e41a | 15 | #include "hw/isa/isa.h" |
db1015e9 | 16 | #include "qom/object.h" |
7d932dfd | 17 | |
0e41271e | 18 | #define TYPE_MC146818_RTC "mc146818rtc" |
8063396b | 19 | OBJECT_DECLARE_SIMPLE_TYPE(RTCState, MC146818_RTC) |
53e4b801 | 20 | |
db1015e9 | 21 | struct RTCState { |
53e4b801 HP |
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; | |
db1015e9 | 48 | }; |
0e41271e | 49 | |
d578f7df | 50 | #define RTC_ISA_IRQ 8 |
ba480fa6 | 51 | #define RTC_ISA_BASE 0x70 |
0e41271e | 52 | |
6c646a11 PMD |
53 | ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, |
54 | qemu_irq intercept_irq); | |
1d914fa0 | 55 | void rtc_set_memory(ISADevice *dev, int addr, int val); |
b8b7456d | 56 | int rtc_get_memory(ISADevice *dev, int addr); |
e1460e47 | 57 | |
175de524 | 58 | #endif /* MC146818RTC_H */ |