2019-10-04 02:03:53 +03: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 11:29:16 +04:00
|
|
|
|
2020-09-13 22:53:41 +03:00
|
|
|
#include "qapi/qapi-types-machine.h"
|
2019-10-18 16:35:44 +03:00
|
|
|
#include "qemu/queue.h"
|
|
|
|
#include "qemu/timer.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/isa/isa.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2010-06-13 16:15:40 +04:00
|
|
|
|
2013-04-28 00:18:43 +04:00
|
|
|
#define TYPE_MC146818_RTC "mc146818rtc"
|
2023-02-11 02:17:03 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(MC146818RtcState, MC146818_RTC)
|
2019-10-18 16:35:44 +03:00
|
|
|
|
2023-02-11 02:17:03 +03:00
|
|
|
struct MC146818RtcState {
|
2019-10-18 16:35:44 +03:00
|
|
|
ISADevice parent_obj;
|
|
|
|
|
|
|
|
MemoryRegion io;
|
|
|
|
MemoryRegion coalesced_io;
|
|
|
|
uint8_t cmos_data[128];
|
|
|
|
uint8_t cmos_index;
|
2022-03-02 01:00:31 +03:00
|
|
|
uint8_t isairq;
|
2022-05-29 21:40:06 +03:00
|
|
|
uint16_t io_base;
|
2019-10-18 16:35:44 +03:00
|
|
|
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;
|
2023-02-11 02:17:03 +03:00
|
|
|
QLIST_ENTRY(MC146818RtcState) link;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-04-28 00:18:43 +04:00
|
|
|
|
2019-10-18 16:35:45 +03:00
|
|
|
#define RTC_ISA_IRQ 8
|
2013-04-28 00:18:43 +04:00
|
|
|
|
2023-02-11 02:17:51 +03:00
|
|
|
MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year,
|
|
|
|
qemu_irq intercept_irq);
|
2023-02-11 02:18:53 +03:00
|
|
|
void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int val);
|
|
|
|
int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr);
|
2023-01-10 12:53:50 +03:00
|
|
|
void qmp_rtc_reset_reinjection(Error **errp);
|
2010-05-14 11:29:16 +04:00
|
|
|
|
2022-05-06 16:49:11 +03:00
|
|
|
#endif /* HW_RTC_MC146818RTC_H */
|