MIPS: Add constructors to the fault classes.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 19 Sep 2011 13:17:19 +0000 (06:17 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 19 Sep 2011 13:17:19 +0000 (06:17 -0700)
src/arch/mips/faults.hh
src/arch/mips/tlb.cc

index 049140229e6d0b5fbdbc14cec0c1224f9f17666a..055aa597ece245b2954de64f7aecacb382693165 100644 (file)
@@ -100,6 +100,7 @@ class AlignmentFault : public MipsFault<AlignmentFault>
 class AddressErrorFault : public MipsFault<AddressErrorFault>
 {
   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<AddressErrorFault>
 class StoreAddressErrorFault : public MipsFault<StoreAddressErrorFault>
 {
   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<BreakpointFault>
 class ItbRefillFault : public MipsFault<ItbRefillFault>
 {
   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<ItbRefillFault>
 class DtbRefillFault : public MipsFault<DtbRefillFault>
 {
   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<ItbPageFault>
 class ItbInvalidFault : public MipsFault<ItbInvalidFault>
 {
   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<ItbInvalidFault>
 class TLBModifiedFault : public MipsFault<TLBModifiedFault>
 {
   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<TLBModifiedFault>
 class DtbInvalidFault : public MipsFault<DtbInvalidFault>
 {
   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);
index 0f76363c8efbf616fdee946c650aacabdca4b6ee..b2286850ed470027b852607e1b997c2d0d3665dd 100644 (file)
@@ -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);