From: Cagdas Dirik Date: Sat, 3 Jan 2015 23:51:48 +0000 (-0600) Subject: dev: prevent RTC events firing before startup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02c376ac44584484268bd714a45fa0f0265a896a;p=gem5.git 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 --- diff --git a/src/dev/alpha/tsunami_io.cc b/src/dev/alpha/tsunami_io.cc index 2c503880f..a20cd8a88 100644 --- a/src/dev/alpha/tsunami_io.cc +++ b/src/dev/alpha/tsunami_io.cc @@ -284,6 +284,12 @@ TsunamiIO::unserialize(Checkpoint *cp, const string §ion) rtc.unserialize("rtc", cp, section); } +void +TsunamiIO::startup() +{ + rtc.startup(); +} + TsunamiIO * TsunamiIOParams::create() { diff --git a/src/dev/alpha/tsunami_io.hh b/src/dev/alpha/tsunami_io.hh index 684295551..f242c9e2a 100644 --- a/src/dev/alpha/tsunami_io.hh +++ b/src/dev/alpha/tsunami_io.hh @@ -151,6 +151,11 @@ class TsunamiIO : public BasicPioDevice */ virtual void unserialize(Checkpoint *cp, const std::string §ion); + /** + * Start running. + */ + virtual void startup(); + }; #endif // __DEV_TSUNAMI_IO_HH__ diff --git a/src/dev/arm/rtc_pl031.cc b/src/dev/arm/rtc_pl031.cc index a43ac6271..e619045c2 100644 --- a/src/dev/arm/rtc_pl031.cc +++ b/src/dev/arm/rtc_pl031.cc @@ -44,7 +44,6 @@ #include "debug/Timer.hh" #include "dev/arm/amba_device.hh" #include "dev/arm/rtc_pl031.hh" -#include "dev/mc146818.hh" #include "mem/packet.hh" #include "mem/packet_access.hh" 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 diff --git a/src/dev/mc146818.hh b/src/dev/mc146818.hh index 76cd40c37..936f597d0 100644 --- a/src/dev/mc146818.hh +++ b/src/dev/mc146818.hh @@ -51,6 +51,7 @@ class MC146818 : public EventManager { MC146818 * parent; Tick interval; + Tick offset; RTCEvent(MC146818 * _parent, Tick i); @@ -68,11 +69,11 @@ class MC146818 : public EventManager struct RTCTickEvent : public Event { MC146818 * parent; + Tick offset; - RTCTickEvent(MC146818 * _parent) : parent(_parent) - { - parent->schedule(this, curTick() + SimClock::Int::s); - } + RTCTickEvent(MC146818 * _parent) : + parent(_parent), offset(SimClock::Int::s) + {} /** Event process to occur at interrupt*/ void process(); @@ -153,6 +154,9 @@ class MC146818 : public EventManager bool bcd, Tick frequency); virtual ~MC146818(); + /** Start ticking */ + virtual void startup(); + /** RTC write data */ void writeData(const uint8_t addr, const uint8_t data); diff --git a/src/dev/mips/malta_io.cc b/src/dev/mips/malta_io.cc index d769b1112..6797a054c 100755 --- a/src/dev/mips/malta_io.cc +++ b/src/dev/mips/malta_io.cc @@ -142,6 +142,12 @@ MaltaIO::unserialize(Checkpoint *cp, const string §ion) rtc.unserialize("rtc", cp, section); } +void +MaltaIO::startup() +{ + rtc.startup(); +} + MaltaIO * MaltaIOParams::create() { diff --git a/src/dev/mips/malta_io.hh b/src/dev/mips/malta_io.hh index f74d42da4..dd035aea2 100755 --- a/src/dev/mips/malta_io.hh +++ b/src/dev/mips/malta_io.hh @@ -143,6 +143,11 @@ class MaltaIO : public BasicPioDevice */ virtual void unserialize(Checkpoint *cp, const std::string §ion); + /** + * Start running. + */ + virtual void startup(); + }; #endif // __DEV_MALTA_IO_HH__ diff --git a/src/dev/x86/cmos.cc b/src/dev/x86/cmos.cc index d7107deb7..6a778b758 100644 --- a/src/dev/x86/cmos.cc +++ b/src/dev/x86/cmos.cc @@ -112,6 +112,12 @@ X86ISA::Cmos::writeRegister(uint8_t reg, uint8_t val) } } +void +X86ISA::Cmos::startup() +{ + rtc.startup(); +} + void X86ISA::Cmos::serialize(std::ostream &os) { diff --git a/src/dev/x86/cmos.hh b/src/dev/x86/cmos.hh index 7957e5304..fa5865c0a 100644 --- a/src/dev/x86/cmos.hh +++ b/src/dev/x86/cmos.hh @@ -82,6 +82,7 @@ class Cmos : public BasicPioDevice Tick write(PacketPtr pkt); + virtual void startup(); virtual void serialize(std::ostream &os); virtual void unserialize(Checkpoint *cp, const std::string §ion);