faults.hh revision 4183:3d19c1d46946
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 83static inline Fault genMachineCheckFault() 84{ 85 return new MachineCheckFault; 86} 87 88static inline Fault genAlignmentFault() 89{ 90 return new AlignmentFault; 91} 92 93class ResetFault : public MipsFault 94{ 95 private: 96 static FaultName _name; 97 static FaultVect _vect; 98 static FaultStat _count; 99 public: 100 FaultName name() {return _name;} 101 FaultVect vect() {return _vect;} 102 FaultStat & countStat() {return _count;} 103}; 104 105class ArithmeticFault : public MipsFault 106{ 107 protected: 108 bool skipFaultingInstruction() {return true;} 109 private: 110 static FaultName _name; 111 static FaultVect _vect; 112 static FaultStat _count; 113 public: 114 FaultName name() {return _name;} 115 FaultVect vect() {return _vect;} 116 FaultStat & countStat() {return _count;} 117#if FULL_SYSTEM 118 void invoke(ThreadContext * tc); 119#endif 120}; 121 122class InterruptFault : public MipsFault 123{ 124 protected: 125 bool setRestartAddress() {return false;} 126 private: 127 static FaultName _name; 128 static FaultVect _vect; 129 static FaultStat _count; 130 public: 131 FaultName name() {return _name;} 132 FaultVect vect() {return _vect;} 133 FaultStat & countStat() {return _count;} 134}; 135 136class NDtbMissFault : public MipsFault 137{ 138 private: 139 static FaultName _name; 140 static FaultVect _vect; 141 static FaultStat _count; 142 public: 143 FaultName name() {return _name;} 144 FaultVect vect() {return _vect;} 145 FaultStat & countStat() {return _count;} 146}; 147 148class PDtbMissFault : public MipsFault 149{ 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 DtbPageFault : 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 DtbAcvFault : 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 ItbMissFault : 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 ItbPageFault : 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 ItbAcvFault : 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 UnimplementedOpcodeFault : 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 FloatEnableFault : 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 PalFault : public MipsFault 245{ 246 protected: 247 bool skipFaultingInstruction() {return true;} 248 private: 249 static FaultName _name; 250 static FaultVect _vect; 251 static FaultStat _count; 252 public: 253 FaultName name() {return _name;} 254 FaultVect vect() {return _vect;} 255 FaultStat & countStat() {return _count;} 256}; 257 258class IntegerOverflowFault : public MipsFault 259{ 260 private: 261 static FaultName _name; 262 static FaultVect _vect; 263 static FaultStat _count; 264 public: 265 FaultName name() {return _name;} 266 FaultVect vect() {return _vect;} 267 FaultStat & countStat() {return _count;} 268}; 269 270} // MipsISA namespace 271 272#endif // __FAULTS_HH__ 273