arm: Refactor some Event subclasses to lambdas
authorSean Wilson <spwilson2@wisc.edu>
Wed, 28 Jun 2017 16:55:34 +0000 (11:55 -0500)
committerSean Wilson <spwilson2@wisc.edu>
Wed, 12 Jul 2017 20:07:05 +0000 (20:07 +0000)
Change-Id: Ic59add8afee1d49633634272d9687a4b1558537e
Signed-off-by: Sean Wilson <spwilson2@wisc.edu>
Reviewed-on: https://gem5-review.googlesource.com/3929
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/dev/arm/gic_pl390.cc
src/dev/arm/gic_pl390.hh
src/dev/arm/vgic.cc
src/dev/arm/vgic.hh

index 126431fe69db7ea18bb2d62c131c8a5afbe2c6dd..d2ec1d79b40891f15c45316e29dea5618daedfc4 100644 (file)
@@ -87,7 +87,9 @@ Pl390::Pl390(const Params *p)
         cpuBpr[x] = GICC_BPR_MINIMUM;
         // Initialize cpu highest int
         cpuHighestInt[x] = SPURIOUS_INT;
-        postIntEvent[x] = new PostIntEvent(*this, x);
+        postIntEvent[x] =
+            new EventFunctionWrapper([this, x]{ postDelayedInt(x); },
+                                     "Post Interrupt to CPU");
     }
     DPRINTF(Interrupt, "cpuEnabled[0]=%d cpuEnabled[1]=%d\n", cpuEnabled[0],
             cpuEnabled[1]);
index 60d9ae30de93196b50519b54044612b05cea0b3e..58d84346d57c2a3027b6602e1044ed36c92dca28 100644 (file)
@@ -353,21 +353,7 @@ class Pl390 : public BaseGic, public BaseGicRegisters
      */
     void postDelayedInt(uint32_t cpu);
 
-    /** Event definition to post interrupt to CPU after a delay
-    */
-    class PostIntEvent : public Event
-    {
-      private:
-        Pl390 &parent;
-        uint32_t cpu;
-      public:
-        PostIntEvent(Pl390 &_parent, uint32_t _cpu)
-            : parent(_parent), cpu(_cpu)
-        { }
-        void process() { parent.postDelayedInt(cpu); }
-        const char *description() const { return "Post Interrupt to CPU"; }
-    };
-    PostIntEvent *postIntEvent[CPU_MAX];
+    EventFunctionWrapper *postIntEvent[CPU_MAX];
     int pendingDelayedInterrupts;
 
   public:
index 6744ad513e1bf92595725109fe38ae2f72de05b5..cc8ad77882586e3128aa3771ba445ebfcbba7058 100644 (file)
@@ -53,7 +53,9 @@ VGic::VGic(const Params *p)
       maintInt(p->ppint)
 {
     for (int x = 0; x < VGIC_CPU_MAX; x++) {
-        postVIntEvent[x] = new PostVIntEvent(x, p->platform);
+        postVIntEvent[x] = new EventFunctionWrapper(
+            [this, x]{ processPostVIntEvent(x); },
+            "Post VInterrupt to CPU");
         maintIntPosted[x] = false;
         vIntPosted[x] = false;
     }
@@ -368,6 +370,13 @@ VGic::unPostVInt(uint32_t cpu)
     platform->intrctrl->clear(cpu, ArmISA::INT_VIRT_IRQ, 0);
 }
 
+void
+VGic::processPostVIntEvent(uint32_t cpu)
+{
+     platform->intrctrl->post(cpu, ArmISA::INT_VIRT_IRQ, 0);
+}
+
+
 void
 VGic::postMaintInt(uint32_t cpu)
 {
index e9bc29c18e5b9683b7af37f1b4a65818cae1ad08..40e42d4fa0ed237f14522c73036923383e488d19 100644 (file)
@@ -104,22 +104,10 @@ class VGic : public PioDevice
     static const uint32_t LR_PENDING    = 1;
     static const uint32_t LR_ACTIVE     = 2;
 
-    /** Event definition to post interrupt to CPU after a delay
-    */
-    class PostVIntEvent : public Event
-    {
-      private:
-        uint32_t cpu;
-        Platform *platform;
-      public:
-        PostVIntEvent( uint32_t c, Platform* p)
-            : cpu(c), platform(p)
-        { }
-        void process() { platform->intrctrl->post(cpu, ArmISA::INT_VIRT_IRQ, 0);}
-        const char *description() const { return "Post VInterrupt to CPU"; }
-    };
+    /** Post interrupt to CPU */
+    void processPostVIntEvent(uint32_t cpu);
 
-    PostVIntEvent *postVIntEvent[VGIC_CPU_MAX];
+    EventFunctionWrapper *postVIntEvent[VGIC_CPU_MAX];
     bool        maintIntPosted[VGIC_CPU_MAX];
     bool        vIntPosted[VGIC_CPU_MAX];