From: Gabe Black Date: Mon, 19 Sep 2011 13:17:19 +0000 (-0700) Subject: MIPS: Add constructors to the fault classes. X-Git-Tag: stable_2012_02_02~68 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e704c9f51a5ed60e46299f7b1dcef6d668b3ff6;p=gem5.git MIPS: Add constructors to the fault classes. --- diff --git a/src/arch/mips/faults.hh b/src/arch/mips/faults.hh index 049140229..055aa597e 100644 --- a/src/arch/mips/faults.hh +++ b/src/arch/mips/faults.hh @@ -100,6 +100,7 @@ class AlignmentFault : public MipsFault class AddressErrorFault : public MipsFault { public: + AddressErrorFault(Addr vaddr) { badVAddr = vaddr; } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInstPtr inst = StaticInst::nullStaticInstPtr); @@ -110,6 +111,7 @@ class AddressErrorFault : public MipsFault class StoreAddressErrorFault : public MipsFault { public: + StoreAddressErrorFault(Addr vaddr) { badVAddr = vaddr; } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInstPtr inst = StaticInst::nullStaticInstPtr); @@ -254,6 +256,14 @@ class BreakpointFault : public MipsFault class ItbRefillFault : public MipsFault { public: + ItbRefillFault(Addr asid, Addr vaddr, Addr vpn) + { + entryHiAsid = asid; + entryHiVPN2 = vpn >> 2; + entryHiVPN2X = vpn & 0x3; + badVAddr = vaddr; + contextBadVPN2 = vpn >> 2; + } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInstPtr inst = StaticInst::nullStaticInstPtr); @@ -263,6 +273,14 @@ class ItbRefillFault : public MipsFault class DtbRefillFault : public MipsFault { public: + DtbRefillFault(Addr asid, Addr vaddr, Addr vpn) + { + entryHiAsid = asid; + entryHiVPN2 = vpn >> 2; + entryHiVPN2X = vpn & 0x3; + badVAddr = vaddr; + contextBadVPN2 = vpn >> 2; + } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInstPtr inst = StaticInst::nullStaticInstPtr); @@ -281,6 +299,14 @@ class ItbPageFault : public MipsFault class ItbInvalidFault : public MipsFault { public: + ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn) + { + entryHiAsid = asid; + entryHiVPN2 = vpn >> 2; + entryHiVPN2X = vpn & 0x3; + badVAddr = vaddr; + contextBadVPN2 = vpn >> 2; + } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInstPtr inst = StaticInst::nullStaticInstPtr); @@ -290,6 +316,14 @@ class ItbInvalidFault : public MipsFault class TLBModifiedFault : public MipsFault { public: + TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) + { + entryHiAsid = asid; + entryHiVPN2 = vpn >> 2; + entryHiVPN2X = vpn & 0x3; + badVAddr = vaddr; + contextBadVPN2 = vpn >> 2; + } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInstPtr inst = StaticInst::nullStaticInstPtr); @@ -299,6 +333,14 @@ class TLBModifiedFault : public MipsFault class DtbInvalidFault : public MipsFault { public: + DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn) + { + entryHiAsid = asid; + entryHiVPN2 = vpn >> 2; + entryHiVPN2X = vpn & 0x3; + badVAddr = vaddr; + contextBadVPN2 = vpn >> 2; + } #if FULL_SYSTEM void invoke(ThreadContext * tc, StaticInst::StaticInstPtr inst = nullStaticInstPtr); diff --git a/src/arch/mips/tlb.cc b/src/arch/mips/tlb.cc index 0f76363c8..b2286850e 100644 --- a/src/arch/mips/tlb.cc +++ b/src/arch/mips/tlb.cc @@ -313,10 +313,7 @@ TLB::translateInst(RequestPtr req, ThreadContext *tc) req->setPaddr(KSeg02Phys(vaddr)); if (getOperatingMode(tc->readMiscReg(MISCREG_STATUS)) != mode_kernel || misaligned) { - AddressErrorFault *Flt = new AddressErrorFault(); - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - return Flt; + return new AddressErrorFault(vaddr); } } else if(IsKSeg1(vaddr)) { // Address will not be translated through TLB, set response, and go! @@ -336,10 +333,7 @@ TLB::translateInst(RequestPtr req, ThreadContext *tc) uint8_t Asid = req->getAsid(); if (misaligned) { // Unaligned address! - AddressErrorFault *Flt = new AddressErrorFault(); - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - return Flt; + return new AddressErrorFault(vaddr); } PTE *pte = lookup(VPN,Asid); if (pte != NULL) { @@ -358,19 +352,7 @@ TLB::translateInst(RequestPtr req, ThreadContext *tc) } if (Valid == false) { - //Invalid entry - ItbInvalidFault *Flt = new ItbInvalidFault(); - /* EntryHi VPN, ASID fields must be set */ - Flt->entryHiAsid = Asid; - Flt->entryHiVPN2 = (VPN >> 2); - Flt->entryHiVPN2X = (VPN & 0x3); - - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - - /* Context must be set */ - Flt->contextBadVPN2 = (VPN >> 2); - return Flt; + return new ItbInvalidFault(Asid, vaddr, vpn); } else { // Ok, this is really a match, set paddr Addr PAddr; @@ -386,18 +368,7 @@ TLB::translateInst(RequestPtr req, ThreadContext *tc) } } else { // Didn't find any match, return a TLB Refill Exception - ItbRefillFault *Flt = new ItbRefillFault(); - /* EntryHi VPN, ASID fields must be set */ - Flt->entryHiAsid = Asid; - Flt->entryHiVPN2 = (VPN >> 2); - Flt->entryHiVPN2X = (VPN & 0x3); - - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - - /* Context must be set */ - Flt->contextBadVPN2 = (VPN >> 2); - return Flt; + return new ItbRefillFault(Asid, vaddr, vpn); } } return checkCacheability(req); @@ -437,11 +408,7 @@ TLB::translateData(RequestPtr req, ThreadContext *tc, bool write) req->setPaddr(KSeg02Phys(vaddr)); if (getOperatingMode(tc->readMiscReg(MISCREG_STATUS)) != mode_kernel || misaligned) { - StoreAddressErrorFault *Flt = new StoreAddressErrorFault(); - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - - return Flt; + return new StoreAddressErrorFault(vaddr); } } else if(IsKSeg1(vaddr)) { // Address will not be translated through TLB, set response, and go! @@ -459,11 +426,7 @@ TLB::translateData(RequestPtr req, ThreadContext *tc, bool write) uint8_t Asid = req->getAsid(); PTE *pte = lookup(VPN, Asid); if (misaligned) { - // Unaligned address! - StoreAddressErrorFault *Flt = new StoreAddressErrorFault(); - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - return Flt; + return new StoreAddressErrorFault(vaddr); } if (pte != NULL) { // Ok, found something @@ -484,35 +447,11 @@ TLB::translateData(RequestPtr req, ThreadContext *tc, bool write) } if (Valid == false) { - //Invalid entry - DtbInvalidFault *Flt = new DtbInvalidFault(); - /* EntryHi VPN, ASID fields must be set */ - Flt->entryHiAsid = Asid; - Flt->entryHiVPN2 = (VPN>>2); - Flt->entryHiVPN2X = (VPN & 0x3); - - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - - /* Context must be set */ - Flt->contextBadVPN2 = (VPN >> 2); - - return Flt; + return new DtbInvalidFault(Asid, vaddr, VPN); } else { // Ok, this is really a match, set paddr if (!Dirty) { - TLBModifiedFault *Flt = new TLBModifiedFault(); - /* EntryHi VPN, ASID fields must be set */ - Flt->entryHiAsid = Asid; - Flt->entryHiVPN2 = (VPN >> 2); - Flt->entryHiVPN2X = (VPN & 0x3); - - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - - /* Context must be set */ - Flt->contextBadVPN2 = (VPN >> 2); - return Flt; + return new TLBModifiedFault(Asid, vaddr, VPN); } Addr PAddr; if (EvenOdd == 0) { @@ -527,18 +466,7 @@ TLB::translateData(RequestPtr req, ThreadContext *tc, bool write) } } else { // Didn't find any match, return a TLB Refill Exception - DtbRefillFault *Flt = new DtbRefillFault(); - /* EntryHi VPN, ASID fields must be set */ - Flt->entryHiAsid = Asid; - Flt->entryHiVPN2 = (VPN >> 2); - Flt->entryHiVPN2X = (VPN & 0x3); - - /* BadVAddr must be set */ - Flt->badVAddr = vaddr; - - /* Context must be set */ - Flt->contextBadVPN2 = (VPN >> 2); - return Flt; + return new DtbRefillFault(Asid, vaddr, VPN); } } return checkCacheability(req);