fastmodel: Implement port proxies.
authorGabe Black <gabeblack@google.com>
Sat, 19 Oct 2019 00:49:45 +0000 (17:49 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 17 Dec 2019 23:17:28 +0000 (23:17 +0000)
This plumbing is simple and largely copied from other implementations
within gem5. This mechanism should be refactored so that the
duplication is unnecessary.

Change-Id: Ibcdf759b7fba1d574e8e2ba04249afdd92c6560c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22120
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Chun-Chen TK Hsu <chunchenhsu@google.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/fastmodel/iris/cpu.cc
src/arch/arm/fastmodel/iris/cpu.hh
src/arch/arm/fastmodel/iris/thread_context.cc
src/arch/arm/fastmodel/iris/thread_context.hh

index 8284d1717f0063fcb0a4f141c5792713ae5120e2..d66cf1dbcdde7ecc6b7bfc3422d71d013c7e3993 100644 (file)
@@ -78,4 +78,12 @@ BaseCPU::totalInsts() const
     return count;
 }
 
+void
+BaseCPU::init()
+{
+    ::BaseCPU::init();
+    for (auto *tc: threadContexts)
+        tc->initMemProxies(tc);
+}
+
 } // namespace Iris
index ef839784cc0a524b5371b843a859c9098d2630ec..0d15fc82a4f0f4855b2cd8fe50cc10b007ae2810 100644 (file)
@@ -116,6 +116,8 @@ class BaseCPU : public ::BaseCPU
         periodAttribute->value = clockPeriod();
         clockEvent->notify();
     }
+
+    void init() override;
 };
 
 // This class specializes the one above and sets up ThreadContexts based on
index 89748957cc08eada9496714f5b6db68f6e81ff77..00c41ba9c90ccd723cbce01fd77837998cd14f3a 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "iris/detail/IrisCppAdapter.h"
 #include "iris/detail/IrisObjects.h"
+#include "mem/fs_translating_port_proxy.hh"
+#include "mem/se_translating_port_proxy.hh"
 
 namespace Iris
 {
@@ -291,6 +293,22 @@ ThreadContext::getCurrentInstCount()
     return count;
 }
 
+void
+ThreadContext::initMemProxies(::ThreadContext *tc)
+{
+    if (FullSystem) {
+        assert(!physProxy && !virtProxy);
+        physProxy.reset(new PortProxy(_cpu->getSendFunctional(),
+                                      _cpu->cacheLineSize()));
+        virtProxy.reset(new FSTranslatingPortProxy(tc));
+    } else {
+        assert(!virtProxy);
+        virtProxy.reset(new SETranslatingPortProxy(
+                        _cpu->getSendFunctional(), getProcessPtr(),
+                        SETranslatingPortProxy::NextPage));
+    }
+}
+
 ThreadContext::Status
 ThreadContext::status() const
 {
index 49b3325e76c0dece29f1f2c27c5eb3eee1816d23..8d2070a023b6a08a31503bff92399b91a9c8546b 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef __ARCH_ARM_FASTMODEL_IRIS_THREAD_CONTEXT_HH__
 #define __ARCH_ARM_FASTMODEL_IRIS_THREAD_CONTEXT_HH__
 
+#include <memory>
+
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
 #include "iris/IrisInstance.h"
@@ -77,6 +79,9 @@ class ThreadContext : public ::ThreadContext
     std::vector<iris::MemorySpaceInfo> memorySpaces;
     std::vector<iris::MemorySupportedAddressTranslationResult> translations;
 
+    std::unique_ptr<PortProxy> virtProxy = nullptr;
+    std::unique_ptr<PortProxy> physProxy = nullptr;
+
 
     // A queue to keep track of instruction count based events.
     EventQueue comInstEventQueue;
@@ -161,21 +166,11 @@ class ThreadContext : public ::ThreadContext
     {
         panic("%s not implemented.", __FUNCTION__);
     }
-    PortProxy &
-    getPhysProxy() override
-    {
-        panic("%s not implemented.", __FUNCTION__);
-    }
-    PortProxy &
-    getVirtProxy() override
-    {
-        panic("%s not implemented.", __FUNCTION__);
-    }
-    void
-    initMemProxies(::ThreadContext *tc) override
-    {
-        panic("%s not implemented.", __FUNCTION__);
-    }
+
+    PortProxy &getPhysProxy() override { return *physProxy; }
+    PortProxy &getVirtProxy() override { return *virtProxy; }
+    void initMemProxies(::ThreadContext *tc) override;
+
     Process *
     getProcessPtr() override
     {