From: Giacomo Travaglini Date: Tue, 6 Oct 2020 10:18:46 +0000 (+0100) Subject: arch: Use getTlb in BaseMMU to reduce boilerplate X-Git-Tag: develop-gem5-snapshot~594 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1217f4e89e26cbd3704e0cad1b7765e40c4d9f3;p=gem5.git arch: Use getTlb in BaseMMU to reduce boilerplate Change-Id: I22dcdf0769e854c252788d415d46da113cb8c60a Signed-off-by: Giacomo Travaglini Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35735 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/arch/generic/mmu.hh b/src/arch/generic/mmu.hh index 8f7ea883f..976527397 100644 --- a/src/arch/generic/mmu.hh +++ b/src/arch/generic/mmu.hh @@ -51,6 +51,15 @@ class BaseMMU : public SimObject : SimObject(p), dtb(p.dtb), itb(p.itb) {} + BaseTLB* + getTlb(BaseTLB::Mode mode) const + { + if (mode == BaseTLB::Execute) + return itb; + else + return dtb; + } + public: void flushAll() @@ -70,40 +79,28 @@ class BaseMMU : public SimObject translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode) { - if (mode == BaseTLB::Execute) - return itb->translateAtomic(req, tc, mode); - else - return dtb->translateAtomic(req, tc, mode); + return getTlb(mode)->translateAtomic(req, tc, mode); } void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseTLB::Translation *translation, BaseTLB::Mode mode) { - if (mode == BaseTLB::Execute) - return itb->translateTiming(req, tc, translation, mode); - else - return dtb->translateTiming(req, tc, translation, mode); + return getTlb(mode)->translateTiming(req, tc, translation, mode); } Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode) { - if (mode == BaseTLB::Execute) - return itb->translateFunctional(req, tc, mode); - else - return dtb->translateFunctional(req, tc, mode); + return getTlb(mode)->translateFunctional(req, tc, mode); } Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode) const { - if (mode == BaseTLB::Execute) - return itb->finalizePhysical(req, tc, mode); - else - return dtb->finalizePhysical(req, tc, mode); + return getTlb(mode)->finalizePhysical(req, tc, mode); } void takeOverFrom(BaseMMU *old_mmu);