faults.hh revision 8572:62d4b366546f
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 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 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 "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 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 setExceptionState(ThreadContext *, uint8_t); 66 void setHandlerPC(Addr, ThreadContext *); 67#endif 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 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 97class AddressErrorFault : public MipsFault<AddressErrorFault> 98{ 99 protected: 100 Addr vaddr; 101 bool store; 102 public: 103 AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store) 104 {} 105#if FULL_SYSTEM 106 void invoke(ThreadContext * tc, 107 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 108#endif 109 110}; 111 112class ResetFault : public MipsFault<ResetFault> 113{ 114 public: 115 void invoke(ThreadContext * tc, 116 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 117 118}; 119 120class SystemCallFault : public MipsFault<SystemCallFault> 121{ 122 public: 123#if FULL_SYSTEM 124 void invoke(ThreadContext * tc, 125 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 126#endif 127}; 128 129class SoftResetFault : public MipsFault<SoftResetFault> 130{ 131 public: 132 void invoke(ThreadContext * tc, 133 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 134}; 135 136class CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault> 137{ 138 protected: 139 int coProcID; 140 public: 141 CoprocessorUnusableFault(int _procid) : coProcID(_procid) 142 {} 143 144 void invoke(ThreadContext * tc, 145 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 146}; 147 148class ReservedInstructionFault : public MipsFault<ReservedInstructionFault> 149{ 150 public: 151 void invoke(ThreadContext * tc, 152 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 153}; 154 155class ThreadFault : public MipsFault<ThreadFault> 156{ 157 public: 158 void invoke(ThreadContext * tc, 159 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 160}; 161 162class IntegerOverflowFault : public MipsFault<IntegerOverflowFault> 163{ 164 protected: 165 bool skipFaultingInstruction() {return true;} 166 public: 167#if FULL_SYSTEM 168 void invoke(ThreadContext * tc, 169 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 170#endif 171}; 172 173class InterruptFault : public MipsFault<InterruptFault> 174{ 175 protected: 176 bool setRestartAddress() {return false;} 177 public: 178#if FULL_SYSTEM 179 void invoke(ThreadContext * tc, 180 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 181#endif 182}; 183 184class TrapFault : public MipsFault<TrapFault> 185{ 186 public: 187#if FULL_SYSTEM 188 void invoke(ThreadContext * tc, 189 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 190#endif 191}; 192 193class BreakpointFault : public MipsFault<BreakpointFault> 194{ 195 public: 196#if FULL_SYSTEM 197 void invoke(ThreadContext * tc, 198 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 199#endif 200}; 201 202class ItbRefillFault : public MipsFault<ItbRefillFault> 203{ 204 public: 205 ItbRefillFault(Addr asid, Addr vaddr, Addr vpn) 206 { 207 entryHiAsid = asid; 208 entryHiVPN2 = vpn >> 2; 209 entryHiVPN2X = vpn & 0x3; 210 badVAddr = vaddr; 211 contextBadVPN2 = vpn >> 2; 212 } 213#if FULL_SYSTEM 214 void invoke(ThreadContext * tc, 215 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 216#endif 217}; 218 219class DtbRefillFault : public MipsFault<DtbRefillFault> 220{ 221 public: 222 DtbRefillFault(Addr asid, Addr vaddr, Addr vpn) 223 { 224 entryHiAsid = asid; 225 entryHiVPN2 = vpn >> 2; 226 entryHiVPN2X = vpn & 0x3; 227 badVAddr = vaddr; 228 contextBadVPN2 = vpn >> 2; 229 } 230#if FULL_SYSTEM 231 void invoke(ThreadContext * tc, 232 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 233#endif 234}; 235 236class ItbInvalidFault : public MipsFault<ItbInvalidFault> 237{ 238 public: 239 ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 240 { 241 entryHiAsid = asid; 242 entryHiVPN2 = vpn >> 2; 243 entryHiVPN2X = vpn & 0x3; 244 badVAddr = vaddr; 245 contextBadVPN2 = vpn >> 2; 246 } 247#if FULL_SYSTEM 248 void invoke(ThreadContext * tc, 249 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 250#endif 251}; 252 253class TLBModifiedFault : public MipsFault<TLBModifiedFault> 254{ 255 public: 256 TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) 257 { 258 entryHiAsid = asid; 259 entryHiVPN2 = vpn >> 2; 260 entryHiVPN2X = vpn & 0x3; 261 badVAddr = vaddr; 262 contextBadVPN2 = vpn >> 2; 263 } 264#if FULL_SYSTEM 265 void invoke(ThreadContext * tc, 266 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 267#endif 268}; 269 270class DtbInvalidFault : public MipsFault<DtbInvalidFault> 271{ 272 public: 273 DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 274 { 275 entryHiAsid = asid; 276 entryHiVPN2 = vpn >> 2; 277 entryHiVPN2X = vpn & 0x3; 278 badVAddr = vaddr; 279 contextBadVPN2 = vpn >> 2; 280 } 281#if FULL_SYSTEM 282 void invoke(ThreadContext * tc, 283 StaticInst::StaticInstPtr inst = nullStaticInstPtr); 284#endif 285}; 286 287class DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 288{ 289 public: 290 void invoke(ThreadContext * tc, 291 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 292}; 293 294} // namespace MipsISA 295 296#endif // __MIPS_FAULTS_HH__ 297