faults.hh revision 2935
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 * Korey Sewell 30 */ 31 32#ifndef __MIPS_FAULTS_HH__ 33#define __MIPS_FAULTS_HH__ 34 35#include "sim/faults.hh" 36 37// The design of the "name" and "vect" functions is in sim/faults.hh 38 39namespace MipsISA 40{ 41 42typedef const Addr FaultVect; 43 44class MipsFault : public FaultBase 45{ 46 protected: 47 virtual bool skipFaultingInstruction() {return false;} 48 virtual bool setRestartAddress() {return true;} 49 public: 50#if FULL_SYSTEM 51 void invoke(ThreadContext * tc); 52#endif 53 virtual FaultVect vect() = 0; 54 virtual FaultStat & countStat() = 0; 55}; 56 57class MachineCheckFault : public MipsFault 58{ 59 private: 60 static FaultName _name; 61 static FaultVect _vect; 62 static FaultStat _count; 63 public: 64 FaultName name() {return _name;} 65 FaultVect vect() {return _vect;} 66 FaultStat & countStat() {return _count;} 67 bool isMachineCheckFault() {return true;} 68}; 69 70class AlignmentFault : public MipsFault 71{ 72 private: 73 static FaultName _name; 74 static FaultVect _vect; 75 static FaultStat _count; 76 public: 77 FaultName name() {return _name;} 78 FaultVect vect() {return _vect;} 79 FaultStat & countStat() {return _count;} 80 bool isAlignmentFault() {return true;} 81}; 82 83#if !FULL_SYSTEM 84class PageTableFault : public MipsFault 85{ 86 private: 87 Addr vaddr; 88 static FaultName _name; 89 static FaultVect _vect; 90 static FaultStat _count; 91 public: 92 PageTableFault(Addr va) 93 : vaddr(va) {} 94 FaultName name() {return _name;} 95 FaultVect vect() {return _vect;} 96 FaultStat & countStat() {return _count;} 97 void invoke(ThreadContext * tc); 98}; 99 100static inline Fault genPageTableFault(Addr va) 101{ 102 return new PageTableFault(va); 103} 104#endif 105 106 107static inline Fault genMachineCheckFault() 108{ 109 return new MachineCheckFault; 110} 111 112static inline Fault genAlignmentFault() 113{ 114 return new AlignmentFault; 115} 116 117class ResetFault : public MipsFault 118{ 119 private: 120 static FaultName _name; 121 static FaultVect _vect; 122 static FaultStat _count; 123 public: 124 FaultName name() {return _name;} 125 FaultVect vect() {return _vect;} 126 FaultStat & countStat() {return _count;} 127}; 128 129class ArithmeticFault : public MipsFault 130{ 131 protected: 132 bool skipFaultingInstruction() {return true;} 133 private: 134 static FaultName _name; 135 static FaultVect _vect; 136 static FaultStat _count; 137 public: 138 FaultName name() {return _name;} 139 FaultVect vect() {return _vect;} 140 FaultStat & countStat() {return _count;} 141#if FULL_SYSTEM 142 void invoke(ThreadContext * tc); 143#endif 144}; 145 146class InterruptFault : public MipsFault 147{ 148 protected: 149 bool setRestartAddress() {return false;} 150 private: 151 static FaultName _name; 152 static FaultVect _vect; 153 static FaultStat _count; 154 public: 155 FaultName name() {return _name;} 156 FaultVect vect() {return _vect;} 157 FaultStat & countStat() {return _count;} 158}; 159 160class NDtbMissFault : public MipsFault 161{ 162 private: 163 static FaultName _name; 164 static FaultVect _vect; 165 static FaultStat _count; 166 public: 167 FaultName name() {return _name;} 168 FaultVect vect() {return _vect;} 169 FaultStat & countStat() {return _count;} 170}; 171 172class PDtbMissFault : public MipsFault 173{ 174 private: 175 static FaultName _name; 176 static FaultVect _vect; 177 static FaultStat _count; 178 public: 179 FaultName name() {return _name;} 180 FaultVect vect() {return _vect;} 181 FaultStat & countStat() {return _count;} 182}; 183 184class DtbPageFault : public MipsFault 185{ 186 private: 187 static FaultName _name; 188 static FaultVect _vect; 189 static FaultStat _count; 190 public: 191 FaultName name() {return _name;} 192 FaultVect vect() {return _vect;} 193 FaultStat & countStat() {return _count;} 194}; 195 196class DtbAcvFault : public MipsFault 197{ 198 private: 199 static FaultName _name; 200 static FaultVect _vect; 201 static FaultStat _count; 202 public: 203 FaultName name() {return _name;} 204 FaultVect vect() {return _vect;} 205 FaultStat & countStat() {return _count;} 206}; 207 208class ItbMissFault : public MipsFault 209{ 210 private: 211 static FaultName _name; 212 static FaultVect _vect; 213 static FaultStat _count; 214 public: 215 FaultName name() {return _name;} 216 FaultVect vect() {return _vect;} 217 FaultStat & countStat() {return _count;} 218}; 219 220class ItbPageFault : public MipsFault 221{ 222 private: 223 static FaultName _name; 224 static FaultVect _vect; 225 static FaultStat _count; 226 public: 227 FaultName name() {return _name;} 228 FaultVect vect() {return _vect;} 229 FaultStat & countStat() {return _count;} 230}; 231 232class ItbAcvFault : public MipsFault 233{ 234 private: 235 static FaultName _name; 236 static FaultVect _vect; 237 static FaultStat _count; 238 public: 239 FaultName name() {return _name;} 240 FaultVect vect() {return _vect;} 241 FaultStat & countStat() {return _count;} 242}; 243 244class UnimplementedOpcodeFault : public MipsFault 245{ 246 private: 247 static FaultName _name; 248 static FaultVect _vect; 249 static FaultStat _count; 250 public: 251 FaultName name() {return _name;} 252 FaultVect vect() {return _vect;} 253 FaultStat & countStat() {return _count;} 254}; 255 256class FloatEnableFault : public MipsFault 257{ 258 private: 259 static FaultName _name; 260 static FaultVect _vect; 261 static FaultStat _count; 262 public: 263 FaultName name() {return _name;} 264 FaultVect vect() {return _vect;} 265 FaultStat & countStat() {return _count;} 266}; 267 268class PalFault : public MipsFault 269{ 270 protected: 271 bool skipFaultingInstruction() {return true;} 272 private: 273 static FaultName _name; 274 static FaultVect _vect; 275 static FaultStat _count; 276 public: 277 FaultName name() {return _name;} 278 FaultVect vect() {return _vect;} 279 FaultStat & countStat() {return _count;} 280}; 281 282class IntegerOverflowFault : public MipsFault 283{ 284 private: 285 static FaultName _name; 286 static FaultVect _vect; 287 static FaultStat _count; 288 public: 289 FaultName name() {return _name;} 290 FaultVect vect() {return _vect;} 291 FaultStat & countStat() {return _count;} 292}; 293 294} // MipsISA namespace 295 296#endif // __FAULTS_HH__ 297