x86: Templatize IntSlavePort.
authorGabe Black <gabeblack@google.com>
Wed, 11 Sep 2019 00:24:47 +0000 (17:24 -0700)
committerGabe Black <gabeblack@google.com>
Sat, 21 Sep 2019 05:05:18 +0000 (05:05 +0000)
This makes the device IntSlavePort calls back into based on a template
parameter so that IntDevice doesn't have to be in the inheritance
hierarchy to use it.

It also makes IntSlavePort inherit from SimpleTimingPort directly,
skipping over MessageSlavePort.

Change-Id: Ic3213edc9c3ed5e506ee1e9f5e082cd47d7c7998
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20820
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/arch/x86/interrupts.hh
src/dev/x86/i82094aa.cc
src/dev/x86/i82094aa.hh
src/dev/x86/intdev.hh

index bd674cc7e84c1c77f90c81fcac3298644171e02e..48e350cfc6415059a0ce94b0e26e4cb20842a2b7 100644 (file)
@@ -172,7 +172,7 @@ class Interrupts : public PioDevice, IntDevice
     int initialApicId;
 
     // Port for receiving interrupts
-    IntSlavePort intSlavePort;
+    IntSlavePort<Interrupts> intSlavePort;
 
     Tick pioDelay;
     Addr pioAddr = MaxAddr;
@@ -200,11 +200,11 @@ class Interrupts : public PioDevice, IntDevice
     void init() override;
 
     /*
-     * Functions to interact with the interrupt port from IntDevice.
+     * Functions to interact with the interrupt port.
      */
     Tick read(PacketPtr pkt) override;
     Tick write(PacketPtr pkt) override;
-    Tick recvMessage(PacketPtr pkt) override;
+    Tick recvMessage(PacketPtr pkt);
     Tick recvResponse(PacketPtr pkt) override;
 
     bool
@@ -217,7 +217,7 @@ class Interrupts : public PioDevice, IntDevice
     }
 
     AddrRangeList getAddrRanges() const override;
-    AddrRangeList getIntAddrRange() const override;
+    AddrRangeList getIntAddrRange() const;
 
     Port &getPort(const std::string &if_name,
                   PortID idx=InvalidPortID) override
index 1fae67b09aafe3fc6f7037a311d1346ef9b9a7c2..e73eec791f3e955bbb812d8bd3c918b7ba0d6a55 100644 (file)
@@ -85,16 +85,6 @@ X86ISA::I82094AA::getPort(const std::string &if_name, PortID idx)
         return BasicPioDevice::getPort(if_name, idx);
 }
 
-AddrRangeList
-X86ISA::I82094AA::getIntAddrRange() const
-{
-    AddrRangeList ranges;
-    ranges.push_back(RangeEx(x86InterruptAddress(initialApicId, 0),
-                             x86InterruptAddress(initialApicId, 0) +
-                             PhysAddrAPICRangeSize));
-    return ranges;
-}
-
 Tick
 X86ISA::I82094AA::recvResponse(PacketPtr pkt)
 {
index b0764758a515da1484f8f343c31af3e3f059b798..17a0da4860a9c2fcb3d3d78f7b2e800867d4a95b 100644 (file)
@@ -100,8 +100,6 @@ class I82094AA : public BasicPioDevice, public IntDevice
     Tick read(PacketPtr pkt) override;
     Tick write(PacketPtr pkt) override;
 
-    AddrRangeList getIntAddrRange() const override;
-
     void writeReg(uint8_t offset, uint32_t value);
     uint32_t readReg(uint8_t offset);
 
index 0cc2be032f9888f682f6cd310027cfc7207d1916..1a198db628dc00bbc8b61667f32e2866f3b54d91 100644 (file)
 
 namespace X86ISA {
 
-typedef std::list<int> ApicList;
-
-class IntDevice
+template <class Device>
+class IntSlavePort : public SimpleTimingPort
 {
-  protected:
-    class IntSlavePort : public MessageSlavePort
+    Device * device;
+
+  public:
+    IntSlavePort(const std::string& _name, SimObject* _parent,
+                 Device* dev) :
+        SimpleTimingPort(_name, _parent), device(dev)
     {
-        IntDevice * device;
+    }
 
-      public:
-        IntSlavePort(const std::string& _name, SimObject* _parent,
-                     IntDevice* dev) :
-            MessageSlavePort(_name, _parent), device(dev)
-        {
-        }
+    AddrRangeList
+    getAddrRanges() const
+    {
+        return device->getIntAddrRange();
+    }
 
-        AddrRangeList getAddrRanges() const
-        {
-            return device->getIntAddrRange();
-        }
+    Tick
+    recvAtomic(PacketPtr pkt)
+    {
+        panic_if(pkt->cmd != MemCmd::MessageReq,
+                "%s received unexpected command %s from %s.\n",
+                name(), pkt->cmd.toString(), getPeer());
+        pkt->headerDelay = pkt->payloadDelay = 0;
+        return device->recvMessage(pkt);
+    }
+};
 
-        Tick recvMessage(PacketPtr pkt)
-        {
-            // @todo someone should pay for this
-            pkt->headerDelay = pkt->payloadDelay = 0;
-            return device->recvMessage(pkt);
-        }
-    };
+typedef std::list<int> ApicList;
+
+class IntDevice
+{
+  protected:
 
     class IntMasterPort : public MessageMasterPort
     {
@@ -118,25 +124,12 @@ class IntDevice
 
     virtual void init();
 
-    virtual Tick
-    recvMessage(PacketPtr pkt)
-    {
-        panic("recvMessage not implemented.\n");
-        return 0;
-    }
-
     virtual Tick
     recvResponse(PacketPtr pkt)
     {
         panic("recvResponse not implemented.\n");
         return 0;
     }
-
-    virtual AddrRangeList
-    getIntAddrRange() const
-    {
-        panic("intAddrRange not implemented.\n");
-    }
 };
 
 } // namespace X86ISA