faults.hh revision 8571
12SN/A/* 21762SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32SN/A * Copyright (c) 2007 MIPS Technologies, Inc. 42SN/A * All rights reserved. 52SN/A * 62SN/A * Redistribution and use in source and binary forms, with or without 72SN/A * modification, are permitted provided that the following conditions are 82SN/A * met: redistributions of source code must retain the above copyright 92SN/A * notice, this list of conditions and the following disclaimer; 102SN/A * redistributions in binary form must reproduce the above copyright 112SN/A * notice, this list of conditions and the following disclaimer in the 122SN/A * documentation and/or other materials provided with the distribution; 132SN/A * neither the name of the copyright holders nor the names of its 142SN/A * contributors may be used to endorse or promote products derived from 152SN/A * this software without specific prior written permission. 162SN/A * 172SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272665Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu * 292665Ssaidi@eecs.umich.edu * Authors: Gabe Black 302SN/A * Korey Sewell 312SN/A * Jaidev Patwardhan 321111SN/A */ 331111SN/A 342SN/A#ifndef __MIPS_FAULTS_HH__ 351110SN/A#define __MIPS_FAULTS_HH__ 362984Sgblack@eecs.umich.edu 372984Sgblack@eecs.umich.edu#include "sim/faults.hh" 382SN/A 392680Sktlim@umich.edunamespace MipsISA 408706Sandreas.hansson@arm.com{ 412SN/A 422521SN/Atypedef const Addr FaultVect; 431111SN/A 448852Sandreas.hansson@arm.comclass MipsFaultBase : public FaultBase 455569Snate@binkert.org{ 462521SN/A protected: 475569Snate@binkert.org virtual bool skipFaultingInstruction() {return false;} 485569Snate@binkert.org virtual bool setRestartAddress() {return true;} 492SN/A public: 505569Snate@binkert.org struct FaultVals 515569Snate@binkert.org { 521111SN/A const FaultName name; 532SN/A const FaultVect vect; 54 FaultStat count; 55 }; 56 57 Addr badVAddr; 58 Addr entryHiAsid; 59 Addr entryHiVPN2; 60 Addr entryHiVPN2X; 61 Addr contextBadVPN2; 62#if FULL_SYSTEM 63 void invoke(ThreadContext * tc, 64 StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr) 65 {} 66 void setExceptionState(ThreadContext *, uint8_t); 67 void setHandlerPC(Addr, ThreadContext *); 68#endif 69}; 70 71template <typename T> 72class MipsFault : public MipsFaultBase 73{ 74 protected: 75 static FaultVals vals; 76 public: 77 FaultName name() const { return vals.name; } 78 FaultVect vect() const { return vals.vect; } 79 FaultStat & countStat() { return vals.count; } 80}; 81 82class MachineCheckFault : public MipsFault<MachineCheckFault> 83{ 84 public: 85 bool isMachineCheckFault() {return true;} 86}; 87 88static inline Fault genMachineCheckFault() 89{ 90 return new MachineCheckFault; 91} 92 93class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt> 94{ 95 public: 96 bool isNonMaskableInterrupt() {return true;} 97}; 98 99class AddressErrorFault : public MipsFault<AddressErrorFault> 100{ 101 protected: 102 Addr vaddr; 103 bool store; 104 public: 105 AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store) 106 {} 107#if FULL_SYSTEM 108 void invoke(ThreadContext * tc, 109 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 110#endif 111 112}; 113 114class ResetFault : public MipsFault<ResetFault> 115{ 116 public: 117 void invoke(ThreadContext * tc, 118 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 119 120}; 121 122class SystemCallFault : public MipsFault<SystemCallFault> 123{ 124 public: 125#if FULL_SYSTEM 126 void invoke(ThreadContext * tc, 127 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 128#endif 129}; 130 131class SoftResetFault : public MipsFault<SoftResetFault> 132{ 133 public: 134 void invoke(ThreadContext * tc, 135 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 136}; 137 138class CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault> 139{ 140 protected: 141 int coProcID; 142 public: 143 CoprocessorUnusableFault(int _procid) : coProcID(_procid) 144 {} 145 146 void invoke(ThreadContext * tc, 147 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 148}; 149 150class ReservedInstructionFault : public MipsFault<ReservedInstructionFault> 151{ 152 public: 153 void invoke(ThreadContext * tc, 154 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 155}; 156 157class ThreadFault : public MipsFault<ThreadFault> 158{ 159 public: 160 void invoke(ThreadContext * tc, 161 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 162}; 163 164class IntegerOverflowFault : public MipsFault<IntegerOverflowFault> 165{ 166 protected: 167 bool skipFaultingInstruction() {return true;} 168 public: 169#if FULL_SYSTEM 170 void invoke(ThreadContext * tc, 171 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 172#endif 173}; 174 175class InterruptFault : public MipsFault<InterruptFault> 176{ 177 protected: 178 bool setRestartAddress() {return false;} 179 public: 180#if FULL_SYSTEM 181 void invoke(ThreadContext * tc, 182 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 183#endif 184}; 185 186class TrapFault : public MipsFault<TrapFault> 187{ 188 public: 189#if FULL_SYSTEM 190 void invoke(ThreadContext * tc, 191 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 192#endif 193}; 194 195class BreakpointFault : public MipsFault<BreakpointFault> 196{ 197 public: 198#if FULL_SYSTEM 199 void invoke(ThreadContext * tc, 200 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 201#endif 202}; 203 204class ItbRefillFault : public MipsFault<ItbRefillFault> 205{ 206 public: 207 ItbRefillFault(Addr asid, Addr vaddr, Addr vpn) 208 { 209 entryHiAsid = asid; 210 entryHiVPN2 = vpn >> 2; 211 entryHiVPN2X = vpn & 0x3; 212 badVAddr = vaddr; 213 contextBadVPN2 = vpn >> 2; 214 } 215#if FULL_SYSTEM 216 void invoke(ThreadContext * tc, 217 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 218#endif 219}; 220 221class DtbRefillFault : public MipsFault<DtbRefillFault> 222{ 223 public: 224 DtbRefillFault(Addr asid, Addr vaddr, Addr vpn) 225 { 226 entryHiAsid = asid; 227 entryHiVPN2 = vpn >> 2; 228 entryHiVPN2X = vpn & 0x3; 229 badVAddr = vaddr; 230 contextBadVPN2 = vpn >> 2; 231 } 232#if FULL_SYSTEM 233 void invoke(ThreadContext * tc, 234 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 235#endif 236}; 237 238class ItbInvalidFault : public MipsFault<ItbInvalidFault> 239{ 240 public: 241 ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 242 { 243 entryHiAsid = asid; 244 entryHiVPN2 = vpn >> 2; 245 entryHiVPN2X = vpn & 0x3; 246 badVAddr = vaddr; 247 contextBadVPN2 = vpn >> 2; 248 } 249#if FULL_SYSTEM 250 void invoke(ThreadContext * tc, 251 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 252#endif 253}; 254 255class TLBModifiedFault : public MipsFault<TLBModifiedFault> 256{ 257 public: 258 TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) 259 { 260 entryHiAsid = asid; 261 entryHiVPN2 = vpn >> 2; 262 entryHiVPN2X = vpn & 0x3; 263 badVAddr = vaddr; 264 contextBadVPN2 = vpn >> 2; 265 } 266#if FULL_SYSTEM 267 void invoke(ThreadContext * tc, 268 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 269#endif 270}; 271 272class DtbInvalidFault : public MipsFault<DtbInvalidFault> 273{ 274 public: 275 DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 276 { 277 entryHiAsid = asid; 278 entryHiVPN2 = vpn >> 2; 279 entryHiVPN2X = vpn & 0x3; 280 badVAddr = vaddr; 281 contextBadVPN2 = vpn >> 2; 282 } 283#if FULL_SYSTEM 284 void invoke(ThreadContext * tc, 285 StaticInst::StaticInstPtr inst = nullStaticInstPtr); 286#endif 287}; 288 289class DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 290{ 291 public: 292 void invoke(ThreadContext * tc, 293 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 294}; 295 296} // namespace MipsISA 297 298#endif // __MIPS_FAULTS_HH__ 299