From 02c376ac44584484268bd714a45fa0f0265a896a Mon Sep 17 00:00:00 2001 From: Cagdas Dirik Date: Sat, 3 Jan 2015 17:51:48 -0600 Subject: dev: prevent RTC events firing before startup This change includes edits to MC146818 timer to prevent RTC events firing before startup to comply with SimObject initialization call sequence. Committed by: Nilay Vaish --- src/dev/mc146818.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/dev/mc146818.cc') diff --git a/src/dev/mc146818.cc b/src/dev/mc146818.cc index 81366b774..fa8350760 100644 --- a/src/dev/mc146818.cc +++ b/src/dev/mc146818.cc @@ -122,6 +122,15 @@ MC146818::rega_dv_disabled(const RtcRegA ®) reg.dv == RTCA_DV_DISABLED1; } +void +MC146818::startup() +{ + assert(!event.scheduled()); + assert(!tickEvent.scheduled()); + schedule(event, curTick() + event.offset); + schedule(tickEvent, curTick() + tickEvent.offset); +} + void MC146818::writeData(const uint8_t addr, const uint8_t data) { @@ -291,17 +300,16 @@ MC146818::unserialize(const string &base, Checkpoint *cp, // Tick rtcTimerInterruptTickOffset; UNSERIALIZE_SCALAR(rtcTimerInterruptTickOffset); - reschedule(event, curTick() + rtcTimerInterruptTickOffset); + event.offset = rtcTimerInterruptTickOffset; Tick rtcClockTickOffset; UNSERIALIZE_SCALAR(rtcClockTickOffset); - reschedule(tickEvent, curTick() + rtcClockTickOffset); + tickEvent.offset = rtcClockTickOffset; } MC146818::RTCEvent::RTCEvent(MC146818 * _parent, Tick i) - : parent(_parent), interval(i) + : parent(_parent), interval(i), offset(i) { DPRINTF(MC146818, "RTC Event Initilizing\n"); - parent->schedule(this, curTick() + interval); } void -- cgit v1.2.3