DmaDevice: fix minor type in error message.
[gem5.git] / src / dev / intel_8254_timer.cc
index 27f55fd9295723717fb272ad6e528d2977eb29ee..d5dd043e1d7d9168b39445612834efea489efed8 100644 (file)
 
 using namespace std;
 
-Intel8254Timer::Intel8254Timer(EventManager *em, const string &name)
-    : EventManager(em), _name(name),
-      counter0(this, name + ".counter0"),
-      counter1(this, name + ".counter1"),
-      counter2(this, name + ".counter2")
+Intel8254Timer::Intel8254Timer(EventManager *em, const string &name,
+    Counter *counter0, Counter *counter1, Counter *counter2) :
+    EventManager(em), _name(name)
 {
-    counter[0] = &counter0;
-    counter[1] = &counter0;
-    counter[2] = &counter0;
+    counter[0] = counter0;
+    counter[1] = counter1;
+    counter[2] = counter2;
+}
+
+Intel8254Timer::Intel8254Timer(EventManager *em, const string &name) :
+    EventManager(em), _name(name)
+{
+    counter[0] = new Counter(this, name + ".counter0", 0);
+    counter[1] = new Counter(this, name + ".counter1", 1);
+    counter[2] = new Counter(this, name + ".counter2", 2);
 }
 
 void
@@ -67,9 +73,9 @@ void
 Intel8254Timer::serialize(const string &base, ostream &os)
 {
     // serialize the counters
-    counter0.serialize(base + ".counter0", os);
-    counter1.serialize(base + ".counter1", os);
-    counter2.serialize(base + ".counter2", os);
+    counter[0]->serialize(base + ".counter0", os);
+    counter[1]->serialize(base + ".counter1", os);
+    counter[2]->serialize(base + ".counter2", os);
 }
 
 void
@@ -77,15 +83,16 @@ Intel8254Timer::unserialize(const string &base, Checkpoint *cp,
         const string &section)
 {
     // unserialze the counters
-    counter0.unserialize(base + ".counter0", cp, section);
-    counter1.unserialize(base + ".counter1", cp, section);
-    counter2.unserialize(base + ".counter2", cp, section);
+    counter[0]->unserialize(base + ".counter0", cp, section);
+    counter[1]->unserialize(base + ".counter1", cp, section);
+    counter[2]->unserialize(base + ".counter2", cp, section);
 }
 
-Intel8254Timer::Counter::Counter(Intel8254Timer *p, const string &name)
-    : _name(name), event(this), count(0), latched_count(0), period(0),
-      mode(0), output_high(false), latch_on(false), read_byte(LSB),
-      write_byte(LSB), parent(p)
+Intel8254Timer::Counter::Counter(Intel8254Timer *p,
+        const string &name, unsigned int _num)
+    : _name(name), num(_num), event(this), count(0),
+      latched_count(0), period(0), mode(0), output_high(false),
+      latch_on(false), read_byte(LSB), write_byte(LSB), parent(p)
 {
 
 }
@@ -240,7 +247,6 @@ Intel8254Timer::Counter::CounterEvent::CounterEvent(Counter* c_ptr)
 void
 Intel8254Timer::Counter::CounterEvent::process()
 {
-    DPRINTF(Intel8254Timer, "Timer Interrupt\n");
     switch (counter->mode) {
       case InitTc:
         counter->output_high = true;
@@ -252,6 +258,7 @@ Intel8254Timer::Counter::CounterEvent::process()
       default:
         panic("Unimplemented PITimer mode.\n");
     }
+    counter->parent->counterInterrupt(counter->num);
 }
 
 void
@@ -267,5 +274,5 @@ Intel8254Timer::Counter::CounterEvent::setTo(int clocks)
 const char *
 Intel8254Timer::Counter::CounterEvent::description() const
 {
-    return "tsunami 8254 Interval timer";
+    return "Intel 8254 Interval timer";
 }