faults.hh (8574:16a168a366d8) | faults.hh (8575:02332ce6d7da) |
---|---|
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * Copyright (c) 2007 MIPS Technologies, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * Authors: Gabe Black 30 * Korey Sewell 31 * Jaidev Patwardhan 32 */ 33 34#ifndef __MIPS_FAULTS_HH__ 35#define __MIPS_FAULTS_HH__ 36 | 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * Copyright (c) 2007 MIPS Technologies, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * Authors: Gabe Black 30 * Korey Sewell 31 * Jaidev Patwardhan 32 */ 33 34#ifndef __MIPS_FAULTS_HH__ 35#define __MIPS_FAULTS_HH__ 36 |
37#include "arch/mips/pra_constants.hh" 38#include "cpu/thread_context.hh" 39#include "debug/MipsPRA.hh" |
|
37#include "sim/faults.hh" 38 39namespace MipsISA 40{ 41 42typedef const Addr FaultVect; 43 44class MipsFaultBase : public FaultBase 45{ 46 protected: 47 virtual bool skipFaultingInstruction() {return false;} 48 virtual bool setRestartAddress() {return true;} 49 public: 50 struct FaultVals 51 { 52 const FaultName name; 53 const FaultVect vect; 54 }; 55 | 40#include "sim/faults.hh" 41 42namespace MipsISA 43{ 44 45typedef const Addr FaultVect; 46 47class MipsFaultBase : public FaultBase 48{ 49 protected: 50 virtual bool skipFaultingInstruction() {return false;} 51 virtual bool setRestartAddress() {return true;} 52 public: 53 struct FaultVals 54 { 55 const FaultName name; 56 const FaultVect vect; 57 }; 58 |
56 Addr badVAddr; 57 Addr entryHiAsid; 58 Addr entryHiVPN2; 59 Addr entryHiVPN2X; 60 Addr contextBadVPN2; | |
61#if FULL_SYSTEM 62 void invoke(ThreadContext * tc, 63 StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr) 64 {} 65 void setHandlerPC(Addr, ThreadContext *); 66#endif 67 void setExceptionState(ThreadContext *, uint8_t); 68}; 69 70template <typename T> 71class MipsFault : public MipsFaultBase 72{ 73 protected: 74 static FaultVals vals; 75 public: 76 FaultName name() const { return vals.name; } 77 FaultVect vect() const { return vals.vect; } 78}; 79 | 59#if FULL_SYSTEM 60 void invoke(ThreadContext * tc, 61 StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr) 62 {} 63 void setHandlerPC(Addr, ThreadContext *); 64#endif 65 void setExceptionState(ThreadContext *, uint8_t); 66}; 67 68template <typename T> 69class MipsFault : public MipsFaultBase 70{ 71 protected: 72 static FaultVals vals; 73 public: 74 FaultName name() const { return vals.name; } 75 FaultVect vect() const { return vals.vect; } 76}; 77 |
78template <typename T> 79class AddressFault : public MipsFault<T> 80{ 81 protected: 82 Addr vaddr; 83 bool store; 84 85 AddressFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store) 86 {} 87}; 88 89template <typename T> 90class TlbFault : public AddressFault<T> 91{ 92 protected: 93 Addr asid; 94 Addr vpn; 95 96 TlbFault(Addr _asid, Addr _vaddr, Addr _vpn, bool _store) : 97 AddressFault<T>(_vaddr, _store), asid(_asid), vpn(_vpn) 98 {} 99 100 void 101 setTlbExceptionState(ThreadContext *tc, uint8_t excCode) 102 { 103 DPRINTF(MipsPRA, "%s encountered.\n", name()); 104 this->setExceptionState(tc, excCode); 105 106 tc->setMiscRegNoEffect(MISCREG_BADVADDR, this->vaddr); 107 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 108 entryHi.asid = this->asid; 109 entryHi.vpn2 = this->vpn >> 2; 110 entryHi.vpn2x = this->vpn & 0x3; 111 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 112 113 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 114 context.badVPN2 = this->vpn >> 2; 115 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 116 } 117}; 118 |
|
80class MachineCheckFault : public MipsFault<MachineCheckFault> 81{ 82 public: 83 bool isMachineCheckFault() {return true;} 84}; 85 86static inline Fault genMachineCheckFault() 87{ 88 return new MachineCheckFault; 89} 90 91class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt> 92{ 93 public: 94 bool isNonMaskableInterrupt() {return true;} 95}; 96 | 119class MachineCheckFault : public MipsFault<MachineCheckFault> 120{ 121 public: 122 bool isMachineCheckFault() {return true;} 123}; 124 125static inline Fault genMachineCheckFault() 126{ 127 return new MachineCheckFault; 128} 129 130class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt> 131{ 132 public: 133 bool isNonMaskableInterrupt() {return true;} 134}; 135 |
97class AddressErrorFault : public MipsFault<AddressErrorFault> | 136class AddressErrorFault : public AddressFault<AddressErrorFault> |
98{ | 137{ |
99 protected: 100 Addr vaddr; 101 bool store; | |
102 public: | 138 public: |
103 AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store) | 139 AddressErrorFault(Addr _vaddr, bool _store) : 140 AddressFault<AddressErrorFault>(_vaddr, _store) |
104 {} 105#if FULL_SYSTEM 106 void invoke(ThreadContext * tc, 107 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 108#endif 109 110}; 111 --- 82 unchanged lines hidden (view full) --- 194{ 195 public: 196#if FULL_SYSTEM 197 void invoke(ThreadContext * tc, 198 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 199#endif 200}; 201 | 141 {} 142#if FULL_SYSTEM 143 void invoke(ThreadContext * tc, 144 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 145#endif 146 147}; 148 --- 82 unchanged lines hidden (view full) --- 231{ 232 public: 233#if FULL_SYSTEM 234 void invoke(ThreadContext * tc, 235 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 236#endif 237}; 238 |
202class TlbRefillFault : public MipsFault<TlbRefillFault> | 239class TlbRefillFault : public TlbFault<TlbRefillFault> |
203{ | 240{ |
204 protected: 205 bool store; | |
206 public: | 241 public: |
207 TlbRefillFault(Addr asid, Addr vaddr, Addr vpn, bool _store) : 208 store(_store) 209 { 210 entryHiAsid = asid; 211 entryHiVPN2 = vpn >> 2; 212 entryHiVPN2X = vpn & 0x3; 213 badVAddr = vaddr; 214 contextBadVPN2 = vpn >> 2; 215 } | 242 TlbRefillFault(Addr asid, Addr vaddr, Addr vpn, bool store) : 243 TlbFault<TlbRefillFault>(asid, vaddr, vpn, store) 244 {} |
216#if FULL_SYSTEM 217 void invoke(ThreadContext * tc, 218 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 219#endif 220}; 221 | 245#if FULL_SYSTEM 246 void invoke(ThreadContext * tc, 247 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 248#endif 249}; 250 |
222class TlbInvalidFault : public MipsFault<TlbInvalidFault> | 251class TlbInvalidFault : public TlbFault<TlbInvalidFault> |
223{ | 252{ |
224 protected: 225 bool store; | |
226 public: | 253 public: |
227 TlbInvalidFault(Addr asid, Addr vaddr, Addr vpn, bool _store) : 228 store(_store) 229 { 230 entryHiAsid = asid; 231 entryHiVPN2 = vpn >> 2; 232 entryHiVPN2X = vpn & 0x3; 233 badVAddr = vaddr; 234 contextBadVPN2 = vpn >> 2; 235 } | 254 TlbInvalidFault(Addr asid, Addr vaddr, Addr vpn, bool store) : 255 TlbFault<TlbInvalidFault>(asid, vaddr, vpn, store) 256 {} |
236#if FULL_SYSTEM 237 void invoke(ThreadContext * tc, 238 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 239#endif 240}; 241 | 257#if FULL_SYSTEM 258 void invoke(ThreadContext * tc, 259 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 260#endif 261}; 262 |
242class TLBModifiedFault : public MipsFault<TLBModifiedFault> | 263class TlbModifiedFault : public TlbFault<TlbModifiedFault> |
243{ 244 public: | 264{ 265 public: |
245 TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) 246 { 247 entryHiAsid = asid; 248 entryHiVPN2 = vpn >> 2; 249 entryHiVPN2X = vpn & 0x3; 250 badVAddr = vaddr; 251 contextBadVPN2 = vpn >> 2; 252 } | 266 TlbModifiedFault(Addr asid, Addr vaddr, Addr vpn) : 267 TlbFault<TlbModifiedFault>(asid, vaddr, vpn, false) 268 {} |
253#if FULL_SYSTEM 254 void invoke(ThreadContext * tc, 255 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 256#endif 257}; 258 259class DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 260{ 261 public: 262 void invoke(ThreadContext * tc, 263 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 264}; 265 266} // namespace MipsISA 267 268#endif // __MIPS_FAULTS_HH__ | 269#if FULL_SYSTEM 270 void invoke(ThreadContext * tc, 271 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 272#endif 273}; 274 275class DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 276{ 277 public: 278 void invoke(ThreadContext * tc, 279 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 280}; 281 282} // namespace MipsISA 283 284#endif // __MIPS_FAULTS_HH__ |