ARM: Add support for running multiple systems
[gem5.git] / src / dev / mc146818.cc
index fd70b503b65b2943fcd219f1a7d912ececc685a9..b0aaf6e64db2eb188b9449e567049c9ea4ca606b 100644 (file)
  */
 
 #include <sys/time.h>
-#include <time.h>
 
+#include <ctime>
 #include <string>
 
 #include "base/bitfield.hh"
 #include "base/time.hh"
 #include "base/trace.hh"
+#include "debug/MC146818.hh"
 #include "dev/mc146818.hh"
 #include "dev/rtcreg.h"
-#include "sim/sim_object.hh"
 
 using namespace std;
 
@@ -106,12 +106,8 @@ MC146818::MC146818(EventManager *em, const string &n, const struct tm time,
 
 MC146818::~MC146818()
 {
-    if (tickEvent.scheduled()) {
-        deschedule(tickEvent);
-    }
-    if (event.scheduled()) {
-        deschedule(event);
-    }
+    deschedule(tickEvent);
+    deschedule(event);
 }
 
 void
@@ -208,20 +204,6 @@ MC146818::tickClock()
     setTime(*gmtime(&calTime));
 }
 
-unsigned int 
-MC146818::drain(Event *de)
-{
-    if (event.scheduled()) {
-        rtcTimerInterruptTickOffset = event.when() - curTick;
-        rtcClockTickOffset = event.when() - curTick;
-        deschedule(event);
-    }
-    if (tickEvent.scheduled()) {
-        deschedule(tickEvent);
-    }
-    return 0;
-}
-
 void
 MC146818::serialize(const string &base, ostream &os)
 {
@@ -233,7 +215,9 @@ MC146818::serialize(const string &base, ostream &os)
     // save the timer tick and rtc clock tick values to correctly reschedule 
     // them during unserialize
     //
+    Tick rtcTimerInterruptTickOffset = event.when() - curTick();
     SERIALIZE_SCALAR(rtcTimerInterruptTickOffset);
+    Tick rtcClockTickOffset = tickEvent.when() - curTick();
     SERIALIZE_SCALAR(rtcClockTickOffset);
 }
 
@@ -251,30 +235,30 @@ MC146818::unserialize(const string &base, Checkpoint *cp,
     //
     Tick rtcTimerInterruptTickOffset;
     UNSERIALIZE_SCALAR(rtcTimerInterruptTickOffset);
-    reschedule(event, curTick + rtcTimerInterruptTickOffset);
+    reschedule(event, curTick() + rtcTimerInterruptTickOffset);
     Tick rtcClockTickOffset;
     UNSERIALIZE_SCALAR(rtcClockTickOffset);
-    reschedule(tickEvent, curTick + rtcClockTickOffset);
+    reschedule(tickEvent, curTick() + rtcClockTickOffset);
 }
 
 MC146818::RTCEvent::RTCEvent(MC146818 * _parent, Tick i)
     : parent(_parent), interval(i)
 {
     DPRINTF(MC146818, "RTC Event Initilizing\n");
-    parent->schedule(this, curTick + interval);
+    parent->schedule(this, curTick() + interval);
 }
 
 void
 MC146818::RTCEvent::scheduleIntr()
 {
-    parent->schedule(this, curTick + interval);
+    parent->schedule(this, curTick() + interval);
 }
 
 void
 MC146818::RTCEvent::process()
 {
     DPRINTF(MC146818, "RTC Timer Interrupt\n");
-    parent->schedule(this, curTick + interval);
+    parent->schedule(this, curTick() + interval);
     parent->handleEvent();
 }
 
@@ -288,7 +272,7 @@ void
 MC146818::RTCTickEvent::process()
 {
     DPRINTF(MC146818, "RTC clock tick\n");
-    parent->schedule(this, curTick + SimClock::Int::s);
+    parent->schedule(this, curTick() + SimClock::Int::s);
     parent->tickClock();
 }