cpu: provide a wakeup mechanism that can be used to pull CPUs out of sleep.
authorNathan Binkert <nate@binkert.org>
Sat, 24 Jan 2009 15:27:21 +0000 (07:27 -0800)
committerNathan Binkert <nate@binkert.org>
Sat, 24 Jan 2009 15:27:21 +0000 (07:27 -0800)
Make interrupts use the new wakeup method, and pull all of the interrupt
stuff into the cpu base class so that only the wakeup code needs to be updated.
I tried to make wakeup, wakeCPU, and the various other mechanisms for waking
and sleeping a little more sane, but I couldn't understand why the statistics
were changing the way they were.  Maybe we'll try again some day.

src/cpu/base.cc
src/cpu/base.hh
src/cpu/o3/cpu.cc
src/cpu/o3/cpu.hh
src/cpu/ozone/cpu.hh
src/cpu/ozone/cpu_impl.hh
src/cpu/simple/base.cc
src/cpu/simple/base.hh

index 16760613598830557ead10db0f22ae6078f17ff7..29095f12ac9c5533bd40c5fc498091f5940211ce 100644 (file)
@@ -389,24 +389,6 @@ BaseCPU::ProfileEvent::process()
     cpu->schedule(this, curTick + interval);
 }
 
-void
-BaseCPU::postInterrupt(int int_num, int index)
-{
-    interrupts->post(int_num, index);
-}
-
-void
-BaseCPU::clearInterrupt(int int_num, int index)
-{
-    interrupts->clear(int_num, index);
-}
-
-void
-BaseCPU::clearInterrupts()
-{
-    interrupts->clearAll();
-}
-
 void
 BaseCPU::serialize(std::ostream &os)
 {
index 83d73ede04cbd77d029fef92fbe87fcfc3a89bba..c8215e047cbfc978d5f419809c3e9c6f3c5634fe 100644 (file)
@@ -125,9 +125,26 @@ class BaseCPU : public MemObject
         return interrupts;
     }
 
-    virtual void postInterrupt(int int_num, int index);
-    virtual void clearInterrupt(int int_num, int index);
-    virtual void clearInterrupts();
+    virtual void wakeup() = 0;
+
+    void
+    postInterrupt(int int_num, int index)
+    {
+        interrupts->post(int_num, index);
+        wakeup();
+    }
+
+    void
+    clearInterrupt(int int_num, int index)
+    {
+        interrupts->clear(int_num, index);
+    }
+
+    void
+    clearInterrupts()
+    {
+        interrupts->clearAll();
+    }
 
     bool
     checkInterrupts(ThreadContext *tc) const
index f567c1868765d0b00d5749f7a463df92e660b6f4..4f6d5d41c335486974af3d05561713e208515f6f 100644 (file)
@@ -893,18 +893,6 @@ FullO3CPU<Impl>::activateWhenReady(int tid)
 }
 
 #if FULL_SYSTEM
-template <class Impl>
-void
-FullO3CPU<Impl>::postInterrupt(int int_num, int index)
-{
-    BaseCPU::postInterrupt(int_num, index);
-
-    if (this->thread[0]->status() == ThreadContext::Suspended) {
-        DPRINTF(IPI,"Suspended Processor awoke\n");
-        this->threadContexts[0]->activate();
-    }
-}
-
 template <class Impl>
 Fault
 FullO3CPU<Impl>::hwrei(unsigned tid)
@@ -1689,6 +1677,21 @@ FullO3CPU<Impl>::wakeCPU()
     schedule(tickEvent, nextCycle());
 }
 
+#if FULL_SYSTEM
+template <class Impl>
+void
+FullO3CPU<Impl>::wakeup()
+{
+    if (this->thread[0]->status() != ThreadContext::Suspended)
+        return;
+
+    this->wakeCPU();
+
+    DPRINTF(Quiesce, "Suspended Processor woken\n");
+    this->threadContexts[0]->activate();
+}
+#endif
+
 template <class Impl>
 int
 FullO3CPU<Impl>::getFreeTid()
index d24e8c38347ca1c347fe1d9d1b9a7b3222bd681e..d14001d0d9fe852519879c4949851480570dff51 100644 (file)
@@ -402,9 +402,6 @@ class FullO3CPU : public BaseO3CPU
     void trap(Fault fault, unsigned tid);
 
 #if FULL_SYSTEM
-    /** Posts an interrupt. */
-    void postInterrupt(int int_num, int index);
-
     /** HW return from error interrupt. */
     Fault hwrei(unsigned tid);
 
@@ -701,6 +698,10 @@ class FullO3CPU : public BaseO3CPU
     /** Wakes the CPU, rescheduling the CPU if it's not already active. */
     void wakeCPU();
 
+#if FULL_SYSTEM
+    virtual void wakeup();
+#endif
+
     /** Gets a free thread id. Use if thread ids change across system. */
     int getFreeTid();
 
index 6b5e7282d4a5fef51e50bd216914fc96a0f78f55..55ad7b3fb8bcad17b859d92dc5a8fb7782ffa0c8 100644 (file)
@@ -333,7 +333,7 @@ class OzoneCPU : public BaseCPU
     Status _status;
 
   public:
-    void postInterrupt(int int_num, int index);
+    void wakeup();
 
     void zero_fill_64(Addr addr) {
         static int warned = 0;
index 1402f4b727ac972dd314baf2c823fb654138a320..84ee6946495285f32da911ec11fa3b16d1818700 100644 (file)
@@ -582,10 +582,8 @@ OzoneCPU<Impl>::dbg_vtophys(Addr addr)
 #if FULL_SYSTEM
 template <class Impl>
 void
-OzoneCPU<Impl>::postInterrupt(int int_num, int index)
+OzoneCPU<Impl>::wakeup()
 {
-    BaseCPU::postInterrupt(int_num, index);
-
     if (_status == Idle) {
         DPRINTF(IPI,"Suspended Processor awoke\n");
 //      thread.activate();
index 3c154afb6b10fbab71698edbe0f94b5a69ac96c4..89d9ce3830f2965e609291d863cbb0e35d6cc7b0 100644 (file)
@@ -303,14 +303,13 @@ BaseSimpleCPU::dbg_vtophys(Addr addr)
 
 #if FULL_SYSTEM
 void
-BaseSimpleCPU::postInterrupt(int int_num, int index)
+BaseSimpleCPU::wakeup()
 {
-    BaseCPU::postInterrupt(int_num, index);
+    if (thread->status() != ThreadContext::Suspended)
+        return;
 
-    if (thread->status() == ThreadContext::Suspended) {
-                DPRINTF(Quiesce,"Suspended Processor awoke\n");
-        thread->activate();
-    }
+    DPRINTF(Quiesce,"Suspended Processor awoke\n");
+    thread->activate();
 }
 #endif // FULL_SYSTEM
 
index 6e72b8f6cee7b8ed5d14d4918d81ae4d747d9a05..34d0f5954295b6becd01aa5514cbd54cf27073cf 100644 (file)
@@ -98,7 +98,7 @@ class BaseSimpleCPU : public BaseCPU
     }
 
   public:
-    void postInterrupt(int int_num, int index);
+    void wakeup();
 
     void zero_fill_64(Addr addr) {
       static int warned = 0;