cpu, mem: Add new getSendFunctional method to the base CPU.
authorGabe Black <gabeblack@google.com>
Sat, 17 Aug 2019 07:30:46 +0000 (00:30 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 28 Aug 2019 07:58:56 +0000 (07:58 +0000)
This returns a sendFunctional delegate references which can be used
to send functional accesses directly, or more likely when constructing
a PortProxy subclass. In those cases only the functional capabilities
of those ports are needed so there's no reason to require a full port
which supports all three protocols. Also, this removes the last
remaining use of get(Data|Inst)Port which relies on those returning
a port which supports the gem5 protocols, except the default
implementations of this new function. If a CPU doesn't have
traditional gem5 style ports, it can override this function to
do whatever other behavior is necessary and return its real ports
through get(Data|Inst)Port.

Change-Id: Ide4da81e3bc679662cd85902ba6bd537cce54a53
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20237
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/cpu/base.hh
src/cpu/thread_state.cc
src/mem/fs_translating_port_proxy.cc

index 1ca1ca10cde0b304956aa23042f8f112f6245603..00373a655c1b301dc6868bd264270676cd00aab7 100644 (file)
@@ -160,6 +160,16 @@ class BaseCPU : public ClockedObject
      */
     virtual MasterPort &getDataPort() = 0;
 
+    /**
+     * Returns a sendFunctional delegate for use with port proxies.
+     */
+    virtual PortProxy::SendFunctionalFunc
+    getSendFunctional()
+    {
+        MasterPort &port = getDataPort();
+        return [&port](PacketPtr pkt)->void { port.sendFunctional(pkt); };
+    }
+
     /**
      * Purely virtual method that returns a reference to the instruction
      * port. All subclasses must implement this method.
index dc4a624a7039e0403df86592506d7f9edc841d1b..cb9a87ca8ae3c805e136fe909102c0aa00229f73 100644 (file)
@@ -109,15 +109,15 @@ ThreadState::initMemProxies(ThreadContext *tc)
         assert(physProxy == NULL);
         // This cannot be done in the constructor as the thread state
         // itself is created in the base cpu constructor and the
-        // getDataPort is a virtual function
-        physProxy = new PortProxy(baseCpu->getDataPort(),
+        // getSendFunctional is a virtual function
+        physProxy = new PortProxy(baseCpu->getSendFunctional(),
                                   baseCpu->cacheLineSize());
 
         assert(virtProxy == NULL);
         virtProxy = new FSTranslatingPortProxy(tc);
     } else {
         assert(virtProxy == NULL);
-        virtProxy = new SETranslatingPortProxy(baseCpu->getDataPort(),
+        virtProxy = new SETranslatingPortProxy(baseCpu->getSendFunctional(),
                                            process,
                                            SETranslatingPortProxy::NextPage);
     }
index d12af13af9ec2117b812ee39d25e8aa7cd32be9e..2ef48b09841cb007a95e8a0395890729147833cb 100644 (file)
@@ -55,7 +55,7 @@
 #include "sim/system.hh"
 
 FSTranslatingPortProxy::FSTranslatingPortProxy(ThreadContext *tc)
-    : PortProxy(tc->getCpuPtr()->getDataPort(),
+    : PortProxy(tc->getCpuPtr()->getSendFunctional(),
                 tc->getSystemPtr()->cacheLineSize()), _tc(tc)
 {
 }