faults.hh revision 8563
112855Sgabeblack@google.com/* 212855Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 312855Sgabeblack@google.com * Copyright (c) 2007 MIPS Technologies, Inc. 412855Sgabeblack@google.com * All rights reserved. 512855Sgabeblack@google.com * 612855Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 712855Sgabeblack@google.com * modification, are permitted provided that the following conditions are 812855Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 912855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1012855Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1112855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1212855Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1312855Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1412855Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1512855Sgabeblack@google.com * this software without specific prior written permission. 1612855Sgabeblack@google.com * 1712855Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812855Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912855Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012855Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112855Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212855Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312855Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412855Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512855Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612855Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712855Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812855Sgabeblack@google.com * 2912855Sgabeblack@google.com * Authors: Gabe Black 3012855Sgabeblack@google.com * Korey Sewell 3112855Sgabeblack@google.com * Jaidev Patwardhan 3212855Sgabeblack@google.com */ 3312855Sgabeblack@google.com 3412855Sgabeblack@google.com#ifndef __MIPS_FAULTS_HH__ 3512855Sgabeblack@google.com#define __MIPS_FAULTS_HH__ 3612855Sgabeblack@google.com 3712855Sgabeblack@google.com#include "sim/faults.hh" 3812855Sgabeblack@google.com 3912855Sgabeblack@google.comnamespace MipsISA 4012855Sgabeblack@google.com{ 4112855Sgabeblack@google.com 4212855Sgabeblack@google.comtypedef const Addr FaultVect; 4312855Sgabeblack@google.com 4412855Sgabeblack@google.comclass MipsFault : public FaultBase 4512855Sgabeblack@google.com{ 4612855Sgabeblack@google.com protected: 4712855Sgabeblack@google.com virtual bool skipFaultingInstruction() {return false;} 4812855Sgabeblack@google.com virtual bool setRestartAddress() {return true;} 4912855Sgabeblack@google.com public: 5012855Sgabeblack@google.com Addr badVAddr; 5112855Sgabeblack@google.com Addr entryHiAsid; 5212855Sgabeblack@google.com Addr entryHiVPN2; 5312855Sgabeblack@google.com Addr entryHiVPN2X; 5412855Sgabeblack@google.com Addr contextBadVPN2; 5512855Sgabeblack@google.com#if FULL_SYSTEM 5612855Sgabeblack@google.com void invoke(ThreadContext * tc, 5712855Sgabeblack@google.com StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr) 5812855Sgabeblack@google.com {} 5912855Sgabeblack@google.com void setExceptionState(ThreadContext *, uint8_t); 6012855Sgabeblack@google.com void setHandlerPC(Addr, ThreadContext *); 6112855Sgabeblack@google.com#endif 6212855Sgabeblack@google.com virtual FaultVect vect() = 0; 6312855Sgabeblack@google.com virtual FaultStat & countStat() = 0; 6412855Sgabeblack@google.com}; 6512855Sgabeblack@google.com 6612855Sgabeblack@google.comclass MachineCheckFault : public MipsFault 6712855Sgabeblack@google.com{ 6812855Sgabeblack@google.com private: 6912855Sgabeblack@google.com static FaultName _name; 7012855Sgabeblack@google.com static FaultVect _vect; 7112855Sgabeblack@google.com static FaultStat _count; 7212855Sgabeblack@google.com public: 7312855Sgabeblack@google.com FaultName name() const {return _name;} 7412855Sgabeblack@google.com FaultVect vect() {return _vect;} 7512855Sgabeblack@google.com FaultStat & countStat() {return _count;} 7612855Sgabeblack@google.com bool isMachineCheckFault() {return true;} 7712855Sgabeblack@google.com}; 7812855Sgabeblack@google.com 7912855Sgabeblack@google.comclass NonMaskableInterrupt : public MipsFault 8012855Sgabeblack@google.com{ 8112855Sgabeblack@google.com private: 8212855Sgabeblack@google.com static FaultName _name; 8312855Sgabeblack@google.com static FaultVect _vect; 8412855Sgabeblack@google.com static FaultStat _count; 8512855Sgabeblack@google.com public: 8612855Sgabeblack@google.com FaultName name() const {return _name;} 8712855Sgabeblack@google.com FaultVect vect() {return _vect;} 8812855Sgabeblack@google.com FaultStat & countStat() {return _count;} 8912855Sgabeblack@google.com bool isNonMaskableInterrupt() {return true;} 9012855Sgabeblack@google.com}; 9112855Sgabeblack@google.com 9212855Sgabeblack@google.comclass AlignmentFault : public MipsFault 9312855Sgabeblack@google.com{ 9412855Sgabeblack@google.com private: 9512855Sgabeblack@google.com static FaultName _name; 9612855Sgabeblack@google.com static FaultVect _vect; 9712855Sgabeblack@google.com static FaultStat _count; 9812855Sgabeblack@google.com public: 9912855Sgabeblack@google.com FaultName name() const {return _name;} 10012855Sgabeblack@google.com FaultVect vect() {return _vect;} 10112855Sgabeblack@google.com FaultStat & countStat() {return _count;} 10212855Sgabeblack@google.com bool isAlignmentFault() {return true;} 10312855Sgabeblack@google.com}; 10412855Sgabeblack@google.com 10512855Sgabeblack@google.comclass AddressErrorFault : public MipsFault 10612855Sgabeblack@google.com{ 10712855Sgabeblack@google.com private: 10812855Sgabeblack@google.com static FaultName _name; 10912855Sgabeblack@google.com static FaultVect _vect; 11012855Sgabeblack@google.com static FaultStat _count; 11112855Sgabeblack@google.com public: 11212855Sgabeblack@google.com FaultName name() const {return _name;} 11312855Sgabeblack@google.com FaultVect vect() {return _vect;} 11412855Sgabeblack@google.com FaultStat & countStat() {return _count;} 11512855Sgabeblack@google.com#if FULL_SYSTEM 11612855Sgabeblack@google.com void invoke(ThreadContext * tc, 11712855Sgabeblack@google.com StaticInstPtr inst = StaticInst::nullStaticInstPtr); 11812855Sgabeblack@google.com#endif 11912855Sgabeblack@google.com 12012855Sgabeblack@google.com}; 12112855Sgabeblack@google.com 12212855Sgabeblack@google.comclass StoreAddressErrorFault : public MipsFault 12312855Sgabeblack@google.com{ 12412855Sgabeblack@google.com private: 12512855Sgabeblack@google.com static FaultName _name; 12612855Sgabeblack@google.com static FaultVect _vect; 12712855Sgabeblack@google.com static FaultStat _count; 12812855Sgabeblack@google.com public: 12912855Sgabeblack@google.com FaultName name() const {return _name;} 130 FaultVect vect() {return _vect;} 131 FaultStat & countStat() {return _count;} 132#if FULL_SYSTEM 133 void invoke(ThreadContext * tc, 134 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 135#endif 136}; 137 138class UnimplementedOpcodeFault : public MipsFault 139{ 140 private: 141 static FaultName _name; 142 static FaultVect _vect; 143 static FaultStat _count; 144 public: 145 FaultName name() const {return _name;} 146 FaultVect vect() {return _vect;} 147 FaultStat & countStat() {return _count;} 148}; 149 150 151class TLBRefillIFetchFault : public MipsFault 152{ 153 private: 154 Addr vaddr; 155 static FaultName _name; 156 static FaultVect _vect; 157 static FaultStat _count; 158 public: 159 FaultName name() const {return _name;} 160 FaultVect vect() {return _vect;} 161 FaultStat & countStat() {return _count;} 162 void invoke(ThreadContext * tc, 163 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 164}; 165 166class TLBInvalidIFetchFault : public MipsFault 167{ 168 private: 169 Addr vaddr; 170 static FaultName _name; 171 static FaultVect _vect; 172 static FaultStat _count; 173 public: 174 FaultName name() const {return _name;} 175 FaultVect vect() {return _vect;} 176 FaultStat & countStat() {return _count;} 177 void invoke(ThreadContext * tc, 178 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 179}; 180 181class NDtbMissFault : public MipsFault 182{ 183 private: 184 static FaultName _name; 185 static FaultVect _vect; 186 static FaultStat _count; 187 public: 188 FaultName name() const {return _name;} 189 FaultVect vect() {return _vect;} 190 FaultStat & countStat() {return _count;} 191}; 192 193class PDtbMissFault : public MipsFault 194{ 195 private: 196 static FaultName _name; 197 static FaultVect _vect; 198 static FaultStat _count; 199 public: 200 FaultName name() const {return _name;} 201 FaultVect vect() {return _vect;} 202 FaultStat & countStat() {return _count;} 203}; 204 205class DtbPageFault : public MipsFault 206{ 207 private: 208 static FaultName _name; 209 static FaultVect _vect; 210 static FaultStat _count; 211 public: 212 FaultName name() const {return _name;} 213 FaultVect vect() {return _vect;} 214 FaultStat & countStat() {return _count;} 215}; 216 217class DtbAcvFault : public MipsFault 218{ 219 private: 220 static FaultName _name; 221 static FaultVect _vect; 222 static FaultStat _count; 223 public: 224 FaultName name() const {return _name;} 225 FaultVect vect() {return _vect;} 226 FaultStat & countStat() {return _count;} 227}; 228 229 230static inline Fault genMachineCheckFault() 231{ 232 return new MachineCheckFault; 233} 234 235static inline Fault genAlignmentFault() 236{ 237 return new AlignmentFault; 238} 239 240class ResetFault : public MipsFault 241{ 242 private: 243 static FaultName _name; 244 static FaultVect _vect; 245 static FaultStat _count; 246 public: 247 FaultName name() const {return _name;} 248 FaultVect vect() {return _vect;} 249 FaultStat & countStat() {return _count;} 250 void invoke(ThreadContext * tc, 251 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 252 253}; 254 255class SystemCallFault : public MipsFault 256{ 257 private: 258 static FaultName _name; 259 static FaultVect _vect; 260 static FaultStat _count; 261 public: 262 FaultName name() const {return _name;} 263 FaultVect vect() {return _vect;} 264 FaultStat & countStat() {return _count;} 265#if FULL_SYSTEM 266 void invoke(ThreadContext * tc, 267 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 268#endif 269}; 270 271class SoftResetFault : public MipsFault 272{ 273 private: 274 static FaultName _name; 275 static FaultVect _vect; 276 static FaultStat _count; 277 public: 278 FaultName name() const {return _name;} 279 FaultVect vect() {return _vect;} 280 FaultStat & countStat() {return _count;} 281 void invoke(ThreadContext * tc, 282 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 283}; 284 285class DebugSingleStep : public MipsFault 286{ 287 private: 288 static FaultName _name; 289 static FaultVect _vect; 290 static FaultStat _count; 291 public: 292 FaultName name() const {return _name;} 293 FaultVect vect() {return _vect;} 294 FaultStat & countStat() {return _count;} 295 void invoke(ThreadContext * tc, 296 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 297}; 298 299class DebugInterrupt : public MipsFault 300{ 301 private: 302 static FaultName _name; 303 static FaultVect _vect; 304 static FaultStat _count; 305 public: 306 FaultName name() const {return _name;} 307 FaultVect vect() {return _vect;} 308 FaultStat & countStat() {return _count;} 309 void invoke(ThreadContext * tc, 310 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 311}; 312 313class CoprocessorUnusableFault : public MipsFault 314{ 315 private: 316 static FaultName _name; 317 static FaultVect _vect; 318 static FaultStat _count; 319 int coProcID; 320 public: 321 FaultName name() const {return _name;} 322 FaultVect vect() {return _vect;} 323 FaultStat & countStat() {return _count;} 324 void invoke(ThreadContext * tc, 325 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 326 CoprocessorUnusableFault(int _procid){ coProcID = _procid;} 327}; 328 329class ReservedInstructionFault : public MipsFault 330{ 331 private: 332 static FaultName _name; 333 static FaultVect _vect; 334 static FaultStat _count; 335 public: 336 FaultName name() const {return _name;} 337 FaultVect vect() {return _vect;} 338 FaultStat & countStat() {return _count;} 339 void invoke(ThreadContext * tc, 340 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 341}; 342 343class ThreadFault : public MipsFault 344{ 345 private: 346 static FaultName _name; 347 static FaultVect _vect; 348 static FaultStat _count; 349 public: 350 FaultName name() const {return _name;} 351 FaultVect vect() {return _vect;} 352 FaultStat & countStat() {return _count;} 353 void invoke(ThreadContext * tc, 354 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 355}; 356 357class ArithmeticFault : public MipsFault 358{ 359 protected: 360 bool skipFaultingInstruction() {return true;} 361 private: 362 static FaultName _name; 363 static FaultVect _vect; 364 static FaultStat _count; 365 public: 366 FaultName name() const {return _name;} 367 FaultVect vect() {return _vect;} 368 FaultStat & countStat() {return _count;} 369#if FULL_SYSTEM 370 void invoke(ThreadContext * tc, 371 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 372#endif 373}; 374 375class InterruptFault : public MipsFault 376{ 377 protected: 378 bool setRestartAddress() {return false;} 379 private: 380 static FaultName _name; 381 static FaultVect _vect; 382 static FaultStat _count; 383 public: 384 FaultName name() const {return _name;} 385 FaultVect vect() {return _vect;} 386 FaultStat & countStat() {return _count;} 387 388#if FULL_SYSTEM 389 void invoke(ThreadContext * tc, 390 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 391#endif 392}; 393 394class TrapFault : public MipsFault 395{ 396 private: 397 static FaultName _name; 398 static FaultVect _vect; 399 static FaultStat _count; 400 public: 401 FaultName name() const {return _name;} 402 FaultVect vect() {return _vect;} 403 FaultStat & countStat() {return _count;} 404#if FULL_SYSTEM 405 void invoke(ThreadContext * tc, 406 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 407#endif 408}; 409 410class BreakpointFault : public MipsFault 411{ 412 private: 413 static FaultName _name; 414 static FaultVect _vect; 415 static FaultStat _count; 416 public: 417 FaultName name() const {return _name;} 418 FaultVect vect() {return _vect;} 419 FaultStat & countStat() {return _count;} 420#if FULL_SYSTEM 421 void invoke(ThreadContext * tc, 422 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 423#endif 424}; 425 426class ItbRefillFault : public MipsFault 427{ 428 private: 429 static FaultName _name; 430 static FaultVect _vect; 431 static FaultStat _count; 432 public: 433 FaultName name() const {return _name;} 434 FaultVect vect() {return _vect;} 435 FaultStat & countStat() {return _count;} 436#if FULL_SYSTEM 437 void invoke(ThreadContext * tc, 438 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 439#endif 440}; 441 442class DtbRefillFault : public MipsFault 443{ 444 private: 445 static FaultName _name; 446 static FaultVect _vect; 447 static FaultStat _count; 448 public: 449 FaultName name() const {return _name;} 450 FaultVect vect() {return _vect;} 451 FaultStat & countStat() {return _count;} 452#if FULL_SYSTEM 453 void invoke(ThreadContext * tc, 454 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 455#endif 456}; 457 458class ItbPageFault : public MipsFault 459{ 460 private: 461 static FaultName _name; 462 static FaultVect _vect; 463 static FaultStat _count; 464 public: 465 FaultName name() const {return _name;} 466 FaultVect vect() {return _vect;} 467 FaultStat & countStat() {return _count;} 468#if FULL_SYSTEM 469 void invoke(ThreadContext * tc, 470 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 471#endif 472}; 473 474class ItbInvalidFault : public MipsFault 475{ 476 private: 477 static FaultName _name; 478 static FaultVect _vect; 479 static FaultStat _count; 480 public: 481 FaultName name() const {return _name;} 482 FaultVect vect() {return _vect;} 483 FaultStat & countStat() {return _count;} 484#if FULL_SYSTEM 485 void invoke(ThreadContext * tc, 486 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 487#endif 488}; 489 490class TLBModifiedFault : public MipsFault 491{ 492 private: 493 static FaultName _name; 494 static FaultVect _vect; 495 static FaultStat _count; 496 public: 497 FaultName name() const {return _name;} 498 FaultVect vect() {return _vect;} 499 FaultStat & countStat() {return _count;} 500#if FULL_SYSTEM 501 void invoke(ThreadContext * tc, 502 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 503#endif 504}; 505 506class DtbInvalidFault : public MipsFault 507{ 508 private: 509 static FaultName _name; 510 static FaultVect _vect; 511 static FaultStat _count; 512 public: 513 FaultName name() const {return _name;} 514 FaultVect vect() {return _vect;} 515 FaultStat & countStat() {return _count;} 516#if FULL_SYSTEM 517 void invoke(ThreadContext * tc, 518 StaticInst::StaticInstPtr inst = nullStaticInstPtr); 519#endif 520}; 521 522class FloatEnableFault : public MipsFault 523{ 524 private: 525 static FaultName _name; 526 static FaultVect _vect; 527 static FaultStat _count; 528 public: 529 FaultName name() const {return _name;} 530 FaultVect vect() {return _vect;} 531 FaultStat & countStat() {return _count;} 532}; 533 534class ItbMissFault : public MipsFault 535{ 536 private: 537 static FaultName _name; 538 static FaultVect _vect; 539 static FaultStat _count; 540 public: 541 FaultName name() const {return _name;} 542 FaultVect vect() {return _vect;} 543 FaultStat & countStat() {return _count;} 544}; 545 546class ItbAcvFault : public MipsFault 547{ 548 private: 549 static FaultName _name; 550 static FaultVect _vect; 551 static FaultStat _count; 552 public: 553 FaultName name() const {return _name;} 554 FaultVect vect() {return _vect;} 555 FaultStat & countStat() {return _count;} 556}; 557 558class IntegerOverflowFault : public MipsFault 559{ 560 private: 561 static FaultName _name; 562 static FaultVect _vect; 563 static FaultStat _count; 564 public: 565 FaultName name() const {return _name;} 566 FaultVect vect() {return _vect;} 567 FaultStat & countStat() {return _count;} 568}; 569 570class DspStateDisabledFault : public MipsFault 571{ 572 private: 573 static FaultName _name; 574 static FaultVect _vect; 575 static FaultStat _count; 576 public: 577 FaultName name() const {return _name;} 578 FaultVect vect() {return _vect;} 579 FaultStat & countStat() {return _count;} 580 void invoke(ThreadContext * tc, 581 StaticInstPtr inst = StaticInst::nullStaticInstPtr); 582}; 583 584} // namespace MipsISA 585 586#endif // __MIPS_FAULTS_HH__ 587