| 
									
										
										
										
											2019-10-04 01:03:53 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU MC146818 RTC emulation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2003-2004 Fabrice Bellard | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: MIT | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef HW_RTC_MC146818RTC_H
 | 
					
						
							|  |  |  | #define HW_RTC_MC146818RTC_H
 | 
					
						
							| 
									
										
										
										
											2010-05-14 16:29:16 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-13 21:53:41 +02:00
										 |  |  | #include "qapi/qapi-types-machine.h"
 | 
					
						
							| 
									
										
										
										
											2019-10-18 15:35:44 +02:00
										 |  |  | #include "qemu/queue.h"
 | 
					
						
							|  |  |  | #include "qemu/timer.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-05 17:06:20 +01:00
										 |  |  | #include "hw/isa/isa.h"
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | #include "qom/object.h"
 | 
					
						
							| 
									
										
										
										
											2010-06-13 14:15:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-27 22:18:43 +02:00
										 |  |  | #define TYPE_MC146818_RTC "mc146818rtc"
 | 
					
						
							| 
									
										
										
										
											2020-09-16 14:25:19 -04:00
										 |  |  | OBJECT_DECLARE_SIMPLE_TYPE(RTCState, MC146818_RTC) | 
					
						
							| 
									
										
										
										
											2019-10-18 15:35:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | struct RTCState { | 
					
						
							| 
									
										
										
										
											2019-10-18 15:35:44 +02:00
										 |  |  |     ISADevice parent_obj; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MemoryRegion io; | 
					
						
							|  |  |  |     MemoryRegion coalesced_io; | 
					
						
							|  |  |  |     uint8_t cmos_data[128]; | 
					
						
							|  |  |  |     uint8_t cmos_index; | 
					
						
							|  |  |  |     int32_t base_year; | 
					
						
							|  |  |  |     uint64_t base_rtc; | 
					
						
							|  |  |  |     uint64_t last_update; | 
					
						
							|  |  |  |     int64_t offset; | 
					
						
							|  |  |  |     qemu_irq irq; | 
					
						
							|  |  |  |     int it_shift; | 
					
						
							|  |  |  |     /* periodic timer */ | 
					
						
							|  |  |  |     QEMUTimer *periodic_timer; | 
					
						
							|  |  |  |     int64_t next_periodic_time; | 
					
						
							|  |  |  |     /* update-ended timer */ | 
					
						
							|  |  |  |     QEMUTimer *update_timer; | 
					
						
							|  |  |  |     uint64_t next_alarm_time; | 
					
						
							|  |  |  |     uint16_t irq_reinject_on_ack_count; | 
					
						
							|  |  |  |     uint32_t irq_coalesced; | 
					
						
							|  |  |  |     uint32_t period; | 
					
						
							|  |  |  |     QEMUTimer *coalesced_timer; | 
					
						
							|  |  |  |     Notifier clock_reset_notifier; | 
					
						
							|  |  |  |     LostTickPolicy lost_tick_policy; | 
					
						
							|  |  |  |     Notifier suspend_notifier; | 
					
						
							|  |  |  |     QLIST_ENTRY(RTCState) link; | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-04-27 22:18:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-18 15:35:45 +02:00
										 |  |  | #define RTC_ISA_IRQ 8
 | 
					
						
							| 
									
										
										
										
											2020-04-29 15:59:54 +02:00
										 |  |  | #define RTC_ISA_BASE 0x70
 | 
					
						
							| 
									
										
										
										
											2013-04-27 22:18:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 13:44:16 -03:00
										 |  |  | ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, | 
					
						
							|  |  |  |                              qemu_irq intercept_irq); | 
					
						
							| 
									
										
										
										
											2010-05-14 16:29:17 +09:00
										 |  |  | void rtc_set_memory(ISADevice *dev, int addr, int val); | 
					
						
							| 
									
										
										
										
											2013-04-23 10:29:40 +02:00
										 |  |  | int rtc_get_memory(ISADevice *dev, int addr); | 
					
						
							| 
									
										
										
										
											2010-05-14 16:29:16 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-29 15:29:06 +02:00
										 |  |  | #endif /* MC146818RTC_H */
 |