changeset 102cf92b8ea9 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=102cf92b8ea9
description:
        X86: Set up a mechanism for the I8254 timer to cause interrupts.

diffstat:

3 files changed, 14 insertions(+), 3 deletions(-)
src/dev/intel_8254_timer.cc |    2 --
src/dev/x86/i8254.cc        |    3 +++
src/dev/x86/i8254.hh        |   12 +++++++++++-

diffs (178 lines):

diff -r 51b7b8cf8083 -r 102cf92b8ea9 src/dev/intel_8254_timer.cc
--- a/src/dev/intel_8254_timer.cc       Sat Oct 11 15:14:37 2008 -0700
+++ b/src/dev/intel_8254_timer.cc       Sat Oct 11 15:15:34 2008 -0700
@@ -47,9 +47,9 @@
 Intel8254Timer::Intel8254Timer(EventManager *em, const string &name) :
     EventManager(em), _name(name)
 {
-    counter[0] = new Counter(this, name + ".counter0");
-    counter[1] = new Counter(this, name + ".counter1");
-    counter[2] = new Counter(this, name + ".counter2");
+    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
@@ -88,10 +88,11 @@
     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)
 {
 
 }
@@ -246,7 +247,6 @@
 void
 Intel8254Timer::Counter::CounterEvent::process()
 {
-    DPRINTF(Intel8254Timer, "Timer Interrupt\n");
     switch (counter->mode) {
       case InitTc:
         counter->output_high = true;
@@ -258,6 +258,7 @@
       default:
         panic("Unimplemented PITimer mode.\n");
     }
+    counter->parent->counterInterrupt(counter->num);
 }
 
 void
@@ -273,5 +274,5 @@
 const char *
 Intel8254Timer::Counter::CounterEvent::description() const
 {
-    return "tsunami 8254 Interval timer";
+    return "Intel 8254 Interval timer";
 }
diff -r 51b7b8cf8083 -r 102cf92b8ea9 src/dev/intel_8254_timer.hh
--- a/src/dev/intel_8254_timer.hh       Sat Oct 11 15:14:37 2008 -0700
+++ b/src/dev/intel_8254_timer.hh       Sat Oct 11 15:15:34 2008 -0700
@@ -90,7 +90,7 @@
             CounterEvent(Counter*);
 
             /** Event process */
-            virtual void process();
+            void process();
 
             /** Event description */
             virtual const char *description() const;
@@ -103,6 +103,8 @@
       private:
         std::string _name;
         const std::string &name() const { return _name; }
+
+        unsigned int num;
 
         CounterEvent event;
 
@@ -134,7 +136,7 @@
         Intel8254Timer *parent;
 
       public:
-        Counter(Intel8254Timer *p, const std::string &name);
+        Counter(Intel8254Timer *p, const std::string &name, unsigned int num);
 
         /** Latch the current count (if one is not already latched) */
         void latchCount();
@@ -181,7 +183,17 @@
     /** PIT has three seperate counters */
     Counter *counter[3];
 
+    virtual void
+    counterInterrupt(unsigned int num)
+    {
+        DPRINTF(Intel8254Timer, "Timer interrupt from counter %d.\n", num);
+    }
+
   public:
+
+    virtual
+    ~Intel8254Timer()
+    {}
 
     Intel8254Timer(EventManager *em, const std::string &name,
             Counter *counter0, Counter *counter1, Counter *counter2);
diff -r 51b7b8cf8083 -r 102cf92b8ea9 src/dev/x86/SConscript
--- a/src/dev/x86/SConscript    Sat Oct 11 15:14:37 2008 -0700
+++ b/src/dev/x86/SConscript    Sat Oct 11 15:15:34 2008 -0700
@@ -47,6 +47,7 @@
 
     SimObject('I8254.py')
     Source('i8254.cc')
+    TraceFlag('I8254', 'Interrupts from the I8254 timer');
 
     SimObject('PcSpeaker.py')
     Source('speaker.cc')
diff -r 51b7b8cf8083 -r 102cf92b8ea9 src/dev/x86/i8254.cc
--- a/src/dev/x86/i8254.cc      Sat Oct 11 15:14:37 2008 -0700
+++ b/src/dev/x86/i8254.cc      Sat Oct 11 15:15:34 2008 -0700
@@ -29,8 +29,17 @@
  */
 
 #include "dev/x86/i8254.hh"
+#include "dev/x86/intdev.hh"
 #include "mem/packet.hh"
 #include "mem/packet_access.hh"
+
+void
+X86ISA::I8254::counterInterrupt(unsigned int num)
+{
+    DPRINTF(I8254, "Interrupt from counter %d.\n", num);
+    if (num == 0)
+        intPin->signalInterrupt();
+}
 
 Tick
 X86ISA::I8254::read(PacketPtr pkt)
diff -r 51b7b8cf8083 -r 102cf92b8ea9 src/dev/x86/i8254.hh
--- a/src/dev/x86/i8254.hh      Sat Oct 11 15:14:37 2008 -0700
+++ b/src/dev/x86/i8254.hh      Sat Oct 11 15:15:34 2008 -0700
@@ -44,9 +44,29 @@
 {
   protected:
     Tick latency;
-    Intel8254Timer pit;
+    class X86Intel8254Timer : public Intel8254Timer
+    {
+      protected:
+        I8254 * parent;
+
+        void
+        counterInterrupt(unsigned int num)
+        {
+            parent->counterInterrupt(num);
+        }
+
+      public:
+        X86Intel8254Timer(const std::string &name, I8254 * _parent) :
+            Intel8254Timer(_parent, name), parent(_parent)
+        {}
+    };
+
+    
+    X86Intel8254Timer pit;
 
     IntPin *intPin;
+    
+    void counterInterrupt(unsigned int num);
 
   public:
     typedef I8254Params Params;
@@ -58,7 +78,7 @@
     }
 
     I8254(Params *p) : BasicPioDevice(p), latency(p->pio_latency),
-            pit(this, p->name), intPin(p->int_pin)
+            pit(p->name, this), intPin(p->int_pin)
     {
         pioSize = 4;
     }
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to