Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/50759 )

Change subject: arch: Add a MMUTranslationGen class to the BaseMMU.
......................................................................

arch: Add a MMUTranslationGen class to the BaseMMU.

This translation generator is returned by the new version of the
TranslateFunctional method which translates a region rather than a
single address. That method is currently virtual with a default
implementation which is not overloaded, but the plan is for the other
MMUs to override that method and inject their own page size minimally.
In the future, the MMUTranslationGen class and the implementations in
the MMUs may be updated so that they can, for instance, handle varying
page sizes across a single translation.

Change-Id: I39479f0f0e8150fc6e3e1a7097a0c8bd8d22d4e0
---
M src/arch/generic/mmu.cc
M src/arch/generic/mmu.hh
2 files changed, 59 insertions(+), 1 deletion(-)



diff --git a/src/arch/generic/mmu.cc b/src/arch/generic/mmu.cc
index 1d2f2b7..3d1de81 100644
--- a/src/arch/generic/mmu.cc
+++ b/src/arch/generic/mmu.cc
@@ -43,6 +43,8 @@

 #include "arch/generic/mmu.hh"
 #include "arch/generic/tlb.hh"
+#include "cpu/thread_context.hh"
+#include "sim/system.hh"

 namespace gem5
 {
@@ -126,6 +128,40 @@
     return getTlb(mode)->finalizePhysical(req, tc, mode);
 }

+BaseMMU::MMUTranslationGen::MMUTranslationGen(Addr page_bytes,
+        Addr new_start, Addr new_size, ThreadContext *new_tc,
+ BaseMMU *new_mmu, BaseMMU::Mode new_mode, Request::Flags new_flags) :
+    TranslationGen(new_start, new_size), tc(new_tc), cid(tc->contextId()),
+    mmu(new_mmu), mode(new_mode), flags(new_flags),
+    pageBytes(page_bytes)
+{}
+
+void
+BaseMMU::MMUTranslationGen::translate(Range &range) const
+{
+    Addr next = roundUp(range.vaddr, pageBytes);
+    if (next == range.vaddr)
+        next += pageBytes;
+    range.size = std::min(range.size, next - range.vaddr);
+
+    auto req = std::make_shared<Request>(
+ range.vaddr, range.size, flags, Request::funcRequestorId, 0, cid);
+
+    range.fault = mmu->translateFunctional(req, tc, mode);
+
+    if (range.fault == NoFault)
+        range.paddr = req->getPaddr();
+}
+
+TranslationGenPtr
+BaseMMU::translateFunctional(Addr start, Addr size, ThreadContext *tc,
+                    BaseMMU::Mode mode, Request::Flags flags)
+{
+    return TranslationGenPtr(new MMUTranslationGen(
+                tc->getSystemPtr()->getPageBytes(), start, size, tc, this,
+                mode, flags));
+}
+
 void
 BaseMMU::takeOverFrom(BaseMMU *old_mmu)
 {
diff --git a/src/arch/generic/mmu.hh b/src/arch/generic/mmu.hh
index e12ad6f..92752ec 100644
--- a/src/arch/generic/mmu.hh
+++ b/src/arch/generic/mmu.hh
@@ -40,8 +40,9 @@

 #include <set>

-#include "params/BaseMMU.hh"
 #include "mem/request.hh"
+#include "mem/translation_gen.hh"
+#include "params/BaseMMU.hh"
 #include "sim/sim_object.hh"

 namespace gem5
@@ -122,6 +123,27 @@
     translateFunctional(const RequestPtr &req, ThreadContext *tc,
                         Mode mode);

+    class MMUTranslationGen : public TranslationGen
+    {
+      private:
+        ThreadContext *tc;
+        ContextID cid;
+        BaseMMU *mmu;
+        BaseMMU::Mode mode;
+        Request::Flags flags;
+        const Addr pageBytes;
+
+        void translate(Range &range) const override;
+
+      public:
+        MMUTranslationGen(Addr page_bytes, Addr new_start, Addr new_size,
+                ThreadContext *new_tc, BaseMMU *new_mmu,
+                BaseMMU::Mode new_mode, Request::Flags new_flags);
+    };
+
+    virtual TranslationGenPtr translateFunctional(Addr start, Addr size,
+            ThreadContext *tc, BaseMMU::Mode mode, Request::Flags flags);
+
     virtual Fault
     finalizePhysical(const RequestPtr &req, ThreadContext *tc,
                      Mode mode) const;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50759
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I39479f0f0e8150fc6e3e1a7097a0c8bd8d22d4e0
Gerrit-Change-Number: 50759
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to