faults.hh revision 8568
12131SN/A/* 25268Sksewell@umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan 35224Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc. 45224Sksewell@umich.edu * All rights reserved. 52131SN/A * 65224Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 75224Sksewell@umich.edu * modification, are permitted provided that the following conditions are 85224Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 95224Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 105224Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 115224Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 125224Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 135224Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 145224Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 155224Sksewell@umich.edu * this software without specific prior written permission. 162131SN/A * 175224Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185224Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195224Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205224Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215224Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225224Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235224Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245224Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255224Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265224Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275224Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu * 295224Sksewell@umich.edu * Authors: Gabe Black 305224Sksewell@umich.edu * Korey Sewell 315222Sksewell@umich.edu * Jaidev Patwardhan 322131SN/A */ 332131SN/A 342239SN/A#ifndef __MIPS_FAULTS_HH__ 352239SN/A#define __MIPS_FAULTS_HH__ 362131SN/A 372131SN/A#include "sim/faults.hh" 382447SN/A 392447SN/Anamespace MipsISA 402447SN/A{ 416378Sgblack@eecs.umich.edu 422447SN/Atypedef const Addr FaultVect; 432131SN/A 448566Sgblack@eecs.umich.educlass MipsFaultBase : public FaultBase 452131SN/A{ 462447SN/A protected: 472447SN/A virtual bool skipFaultingInstruction() {return false;} 482447SN/A virtual bool setRestartAddress() {return true;} 492131SN/A public: 508566Sgblack@eecs.umich.edu struct FaultVals 518566Sgblack@eecs.umich.edu { 528566Sgblack@eecs.umich.edu const FaultName name; 538566Sgblack@eecs.umich.edu const FaultVect vect; 548566Sgblack@eecs.umich.edu FaultStat count; 558566Sgblack@eecs.umich.edu }; 568566Sgblack@eecs.umich.edu 576379Sgblack@eecs.umich.edu Addr badVAddr; 586379Sgblack@eecs.umich.edu Addr entryHiAsid; 596379Sgblack@eecs.umich.edu Addr entryHiVPN2; 606379Sgblack@eecs.umich.edu Addr entryHiVPN2X; 616379Sgblack@eecs.umich.edu Addr contextBadVPN2; 622447SN/A#if FULL_SYSTEM 637678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 647678Sgblack@eecs.umich.edu StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr) 657678Sgblack@eecs.umich.edu {} 666378Sgblack@eecs.umich.edu void setExceptionState(ThreadContext *, uint8_t); 676378Sgblack@eecs.umich.edu void setHandlerPC(Addr, ThreadContext *); 682447SN/A#endif 692131SN/A}; 702131SN/A 718566Sgblack@eecs.umich.edutemplate <typename T> 728566Sgblack@eecs.umich.educlass MipsFault : public MipsFaultBase 732131SN/A{ 748566Sgblack@eecs.umich.edu protected: 758566Sgblack@eecs.umich.edu static FaultVals vals; 762131SN/A public: 778566Sgblack@eecs.umich.edu FaultName name() const { return vals.name; } 788566Sgblack@eecs.umich.edu FaultVect vect() const { return vals.vect; } 798566Sgblack@eecs.umich.edu FaultStat & countStat() { return vals.count; } 808566Sgblack@eecs.umich.edu}; 818566Sgblack@eecs.umich.edu 828566Sgblack@eecs.umich.educlass MachineCheckFault : public MipsFault<MachineCheckFault> 838566Sgblack@eecs.umich.edu{ 848566Sgblack@eecs.umich.edu public: 855222Sksewell@umich.edu bool isMachineCheckFault() {return true;} 865222Sksewell@umich.edu}; 875222Sksewell@umich.edu 888566Sgblack@eecs.umich.educlass NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt> 895222Sksewell@umich.edu{ 905222Sksewell@umich.edu public: 915222Sksewell@umich.edu bool isNonMaskableInterrupt() {return true;} 922447SN/A}; 932131SN/A 948566Sgblack@eecs.umich.educlass AddressErrorFault : public MipsFault<AddressErrorFault> 955222Sksewell@umich.edu{ 965222Sksewell@umich.edu public: 978567Sgblack@eecs.umich.edu AddressErrorFault(Addr vaddr) { badVAddr = vaddr; } 985222Sksewell@umich.edu#if FULL_SYSTEM 997678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1007678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1015222Sksewell@umich.edu#endif 1025222Sksewell@umich.edu 1035222Sksewell@umich.edu}; 1046378Sgblack@eecs.umich.edu 1058566Sgblack@eecs.umich.educlass StoreAddressErrorFault : public MipsFault<StoreAddressErrorFault> 1065222Sksewell@umich.edu{ 1075222Sksewell@umich.edu public: 1088567Sgblack@eecs.umich.edu StoreAddressErrorFault(Addr vaddr) { badVAddr = vaddr; } 1095222Sksewell@umich.edu#if FULL_SYSTEM 1107678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1117678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1125222Sksewell@umich.edu#endif 1136378Sgblack@eecs.umich.edu}; 1145222Sksewell@umich.edu 1155222Sksewell@umich.edustatic inline Fault genMachineCheckFault() 1165222Sksewell@umich.edu{ 1175222Sksewell@umich.edu return new MachineCheckFault; 1185222Sksewell@umich.edu} 1195222Sksewell@umich.edu 1208566Sgblack@eecs.umich.educlass ResetFault : public MipsFault<ResetFault> 1215222Sksewell@umich.edu{ 1225222Sksewell@umich.edu public: 1237678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1247678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1255222Sksewell@umich.edu 1265222Sksewell@umich.edu}; 1276378Sgblack@eecs.umich.edu 1288566Sgblack@eecs.umich.educlass SystemCallFault : public MipsFault<SystemCallFault> 1295222Sksewell@umich.edu{ 1305222Sksewell@umich.edu public: 1318563Sgblack@eecs.umich.edu#if FULL_SYSTEM 1327678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1337678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1348563Sgblack@eecs.umich.edu#endif 1355222Sksewell@umich.edu}; 1365222Sksewell@umich.edu 1378566Sgblack@eecs.umich.educlass SoftResetFault : public MipsFault<SoftResetFault> 1385222Sksewell@umich.edu{ 1395222Sksewell@umich.edu public: 1407678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1417678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1425222Sksewell@umich.edu}; 1436378Sgblack@eecs.umich.edu 1448566Sgblack@eecs.umich.educlass CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault> 1455222Sksewell@umich.edu{ 1468566Sgblack@eecs.umich.edu protected: 1475222Sksewell@umich.edu int coProcID; 1485222Sksewell@umich.edu public: 1498566Sgblack@eecs.umich.edu CoprocessorUnusableFault(int _procid) : coProcID(_procid) 1508566Sgblack@eecs.umich.edu {} 1515222Sksewell@umich.edu 1527678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1537678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1545222Sksewell@umich.edu}; 1555222Sksewell@umich.edu 1568566Sgblack@eecs.umich.educlass ReservedInstructionFault : public MipsFault<ReservedInstructionFault> 1575222Sksewell@umich.edu{ 1585222Sksewell@umich.edu public: 1597678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1607678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1615222Sksewell@umich.edu}; 1625222Sksewell@umich.edu 1638566Sgblack@eecs.umich.educlass ThreadFault : public MipsFault<ThreadFault> 1648566Sgblack@eecs.umich.edu{ 1658566Sgblack@eecs.umich.edu public: 1668566Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1678566Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1688566Sgblack@eecs.umich.edu}; 1698566Sgblack@eecs.umich.edu 1708568Sgblack@eecs.umich.educlass IntegerOverflowFault : public MipsFault<IntegerOverflowFault> 1715222Sksewell@umich.edu{ 1725222Sksewell@umich.edu protected: 1735222Sksewell@umich.edu bool skipFaultingInstruction() {return true;} 1745222Sksewell@umich.edu public: 1755222Sksewell@umich.edu#if FULL_SYSTEM 1767678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1777678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1785222Sksewell@umich.edu#endif 1795222Sksewell@umich.edu}; 1805222Sksewell@umich.edu 1818566Sgblack@eecs.umich.educlass InterruptFault : public MipsFault<InterruptFault> 1825222Sksewell@umich.edu{ 1835222Sksewell@umich.edu protected: 1845222Sksewell@umich.edu bool setRestartAddress() {return false;} 1855222Sksewell@umich.edu public: 1865222Sksewell@umich.edu#if FULL_SYSTEM 1877678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1887678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1895222Sksewell@umich.edu#endif 1905222Sksewell@umich.edu}; 1915222Sksewell@umich.edu 1928566Sgblack@eecs.umich.educlass TrapFault : public MipsFault<TrapFault> 1935222Sksewell@umich.edu{ 1945222Sksewell@umich.edu public: 1955222Sksewell@umich.edu#if FULL_SYSTEM 1967678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1977678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1985222Sksewell@umich.edu#endif 1995222Sksewell@umich.edu}; 2005222Sksewell@umich.edu 2018566Sgblack@eecs.umich.educlass BreakpointFault : public MipsFault<BreakpointFault> 2025222Sksewell@umich.edu{ 2035222Sksewell@umich.edu public: 2045222Sksewell@umich.edu#if FULL_SYSTEM 2057678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2067678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2075222Sksewell@umich.edu#endif 2085222Sksewell@umich.edu}; 2095222Sksewell@umich.edu 2108566Sgblack@eecs.umich.educlass ItbRefillFault : public MipsFault<ItbRefillFault> 2115222Sksewell@umich.edu{ 2125222Sksewell@umich.edu public: 2138567Sgblack@eecs.umich.edu ItbRefillFault(Addr asid, Addr vaddr, Addr vpn) 2148567Sgblack@eecs.umich.edu { 2158567Sgblack@eecs.umich.edu entryHiAsid = asid; 2168567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2178567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2188567Sgblack@eecs.umich.edu badVAddr = vaddr; 2198567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2208567Sgblack@eecs.umich.edu } 2215222Sksewell@umich.edu#if FULL_SYSTEM 2227678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2237678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2245222Sksewell@umich.edu#endif 2255222Sksewell@umich.edu}; 2266378Sgblack@eecs.umich.edu 2278566Sgblack@eecs.umich.educlass DtbRefillFault : public MipsFault<DtbRefillFault> 2285222Sksewell@umich.edu{ 2295222Sksewell@umich.edu public: 2308567Sgblack@eecs.umich.edu DtbRefillFault(Addr asid, Addr vaddr, Addr vpn) 2318567Sgblack@eecs.umich.edu { 2328567Sgblack@eecs.umich.edu entryHiAsid = asid; 2338567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2348567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2358567Sgblack@eecs.umich.edu badVAddr = vaddr; 2368567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2378567Sgblack@eecs.umich.edu } 2385222Sksewell@umich.edu#if FULL_SYSTEM 2397678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2407678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2415222Sksewell@umich.edu#endif 2425222Sksewell@umich.edu}; 2435222Sksewell@umich.edu 2448566Sgblack@eecs.umich.educlass ItbInvalidFault : public MipsFault<ItbInvalidFault> 2455222Sksewell@umich.edu{ 2465222Sksewell@umich.edu public: 2478567Sgblack@eecs.umich.edu ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 2488567Sgblack@eecs.umich.edu { 2498567Sgblack@eecs.umich.edu entryHiAsid = asid; 2508567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2518567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2528567Sgblack@eecs.umich.edu badVAddr = vaddr; 2538567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2548567Sgblack@eecs.umich.edu } 2555222Sksewell@umich.edu#if FULL_SYSTEM 2567678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2577678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2585222Sksewell@umich.edu#endif 2596378Sgblack@eecs.umich.edu}; 2605222Sksewell@umich.edu 2618566Sgblack@eecs.umich.educlass TLBModifiedFault : public MipsFault<TLBModifiedFault> 2625222Sksewell@umich.edu{ 2635222Sksewell@umich.edu public: 2648567Sgblack@eecs.umich.edu TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) 2658567Sgblack@eecs.umich.edu { 2668567Sgblack@eecs.umich.edu entryHiAsid = asid; 2678567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2688567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2698567Sgblack@eecs.umich.edu badVAddr = vaddr; 2708567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2718567Sgblack@eecs.umich.edu } 2725222Sksewell@umich.edu#if FULL_SYSTEM 2737678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2747678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2755222Sksewell@umich.edu#endif 2765222Sksewell@umich.edu}; 2775222Sksewell@umich.edu 2788566Sgblack@eecs.umich.educlass DtbInvalidFault : public MipsFault<DtbInvalidFault> 2795222Sksewell@umich.edu{ 2805222Sksewell@umich.edu public: 2818567Sgblack@eecs.umich.edu DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 2828567Sgblack@eecs.umich.edu { 2838567Sgblack@eecs.umich.edu entryHiAsid = asid; 2848567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2858567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2868567Sgblack@eecs.umich.edu badVAddr = vaddr; 2878567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2888567Sgblack@eecs.umich.edu } 2895222Sksewell@umich.edu#if FULL_SYSTEM 2907678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2917678Sgblack@eecs.umich.edu StaticInst::StaticInstPtr inst = nullStaticInstPtr); 2925222Sksewell@umich.edu#endif 2935222Sksewell@umich.edu}; 2945222Sksewell@umich.edu 2958566Sgblack@eecs.umich.educlass DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 2965222Sksewell@umich.edu{ 2975222Sksewell@umich.edu public: 2987678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2997678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 3004661Sksewell@umich.edu}; 3014661Sksewell@umich.edu 3027811Ssteve.reinhardt@amd.com} // namespace MipsISA 3032131SN/A 3045222Sksewell@umich.edu#endif // __MIPS_FAULTS_HH__ 305