From 283be34a992401f07d62e274d501c4185fca8377 Mon Sep 17 00:00:00 2001 From: Brad Beckmann Date: Fri, 20 Aug 2010 11:46:13 -0700 Subject: devices: Fixed periodic interrupts to work with draining Added drain functions to the RTC and 8254 timer so that periodic interrupts stop when the system is draining. This patch is needed to checkpoint in timing mode. Otherwise under certain situations, the event queue will never be completely empty. --- src/dev/mc146818.cc | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/dev/mc146818.cc') diff --git a/src/dev/mc146818.cc b/src/dev/mc146818.cc index 16ed58e46..fd70b503b 100644 --- a/src/dev/mc146818.cc +++ b/src/dev/mc146818.cc @@ -40,6 +40,7 @@ #include "base/trace.hh" #include "dev/mc146818.hh" #include "dev/rtcreg.h" +#include "sim/sim_object.hh" using namespace std; @@ -105,8 +106,12 @@ MC146818::MC146818(EventManager *em, const string &n, const struct tm time, MC146818::~MC146818() { - deschedule(tickEvent); - deschedule(event); + if (tickEvent.scheduled()) { + deschedule(tickEvent); + } + if (event.scheduled()) { + deschedule(event); + } } void @@ -203,6 +208,20 @@ 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) { @@ -214,9 +233,7 @@ 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 = event.when() - curTick; SERIALIZE_SCALAR(rtcClockTickOffset); } -- cgit v1.2.3