faults.hh revision 8571
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 888571Sgblack@eecs.umich.edustatic inline Fault genMachineCheckFault() 898571Sgblack@eecs.umich.edu{ 908571Sgblack@eecs.umich.edu return new MachineCheckFault; 918571Sgblack@eecs.umich.edu} 928571Sgblack@eecs.umich.edu 938566Sgblack@eecs.umich.educlass NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt> 945222Sksewell@umich.edu{ 955222Sksewell@umich.edu public: 965222Sksewell@umich.edu bool isNonMaskableInterrupt() {return true;} 972447SN/A}; 982131SN/A 998566Sgblack@eecs.umich.educlass AddressErrorFault : public MipsFault<AddressErrorFault> 1005222Sksewell@umich.edu{ 1018570Sgblack@eecs.umich.edu protected: 1028570Sgblack@eecs.umich.edu Addr vaddr; 1038570Sgblack@eecs.umich.edu bool store; 1045222Sksewell@umich.edu public: 1058570Sgblack@eecs.umich.edu AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store) 1068570Sgblack@eecs.umich.edu {} 1075222Sksewell@umich.edu#if FULL_SYSTEM 1087678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1097678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1105222Sksewell@umich.edu#endif 1115222Sksewell@umich.edu 1125222Sksewell@umich.edu}; 1136378Sgblack@eecs.umich.edu 1148566Sgblack@eecs.umich.educlass ResetFault : public MipsFault<ResetFault> 1155222Sksewell@umich.edu{ 1165222Sksewell@umich.edu public: 1177678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1187678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1195222Sksewell@umich.edu 1205222Sksewell@umich.edu}; 1216378Sgblack@eecs.umich.edu 1228566Sgblack@eecs.umich.educlass SystemCallFault : public MipsFault<SystemCallFault> 1235222Sksewell@umich.edu{ 1245222Sksewell@umich.edu public: 1258563Sgblack@eecs.umich.edu#if FULL_SYSTEM 1267678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1277678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1288563Sgblack@eecs.umich.edu#endif 1295222Sksewell@umich.edu}; 1305222Sksewell@umich.edu 1318566Sgblack@eecs.umich.educlass SoftResetFault : public MipsFault<SoftResetFault> 1325222Sksewell@umich.edu{ 1335222Sksewell@umich.edu public: 1347678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1357678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1365222Sksewell@umich.edu}; 1376378Sgblack@eecs.umich.edu 1388566Sgblack@eecs.umich.educlass CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault> 1395222Sksewell@umich.edu{ 1408566Sgblack@eecs.umich.edu protected: 1415222Sksewell@umich.edu int coProcID; 1425222Sksewell@umich.edu public: 1438566Sgblack@eecs.umich.edu CoprocessorUnusableFault(int _procid) : coProcID(_procid) 1448566Sgblack@eecs.umich.edu {} 1455222Sksewell@umich.edu 1467678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1477678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1485222Sksewell@umich.edu}; 1495222Sksewell@umich.edu 1508566Sgblack@eecs.umich.educlass ReservedInstructionFault : public MipsFault<ReservedInstructionFault> 1515222Sksewell@umich.edu{ 1525222Sksewell@umich.edu public: 1537678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1547678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1555222Sksewell@umich.edu}; 1565222Sksewell@umich.edu 1578566Sgblack@eecs.umich.educlass ThreadFault : public MipsFault<ThreadFault> 1588566Sgblack@eecs.umich.edu{ 1598566Sgblack@eecs.umich.edu public: 1608566Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1618566Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1628566Sgblack@eecs.umich.edu}; 1638566Sgblack@eecs.umich.edu 1648568Sgblack@eecs.umich.educlass IntegerOverflowFault : public MipsFault<IntegerOverflowFault> 1655222Sksewell@umich.edu{ 1665222Sksewell@umich.edu protected: 1675222Sksewell@umich.edu bool skipFaultingInstruction() {return true;} 1685222Sksewell@umich.edu public: 1695222Sksewell@umich.edu#if FULL_SYSTEM 1707678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1717678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1725222Sksewell@umich.edu#endif 1735222Sksewell@umich.edu}; 1745222Sksewell@umich.edu 1758566Sgblack@eecs.umich.educlass InterruptFault : public MipsFault<InterruptFault> 1765222Sksewell@umich.edu{ 1775222Sksewell@umich.edu protected: 1785222Sksewell@umich.edu bool setRestartAddress() {return false;} 1795222Sksewell@umich.edu public: 1805222Sksewell@umich.edu#if FULL_SYSTEM 1817678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1827678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1835222Sksewell@umich.edu#endif 1845222Sksewell@umich.edu}; 1855222Sksewell@umich.edu 1868566Sgblack@eecs.umich.educlass TrapFault : public MipsFault<TrapFault> 1875222Sksewell@umich.edu{ 1885222Sksewell@umich.edu public: 1895222Sksewell@umich.edu#if FULL_SYSTEM 1907678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1917678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1925222Sksewell@umich.edu#endif 1935222Sksewell@umich.edu}; 1945222Sksewell@umich.edu 1958566Sgblack@eecs.umich.educlass BreakpointFault : public MipsFault<BreakpointFault> 1965222Sksewell@umich.edu{ 1975222Sksewell@umich.edu public: 1985222Sksewell@umich.edu#if FULL_SYSTEM 1997678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2007678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2015222Sksewell@umich.edu#endif 2025222Sksewell@umich.edu}; 2035222Sksewell@umich.edu 2048566Sgblack@eecs.umich.educlass ItbRefillFault : public MipsFault<ItbRefillFault> 2055222Sksewell@umich.edu{ 2065222Sksewell@umich.edu public: 2078567Sgblack@eecs.umich.edu ItbRefillFault(Addr asid, Addr vaddr, Addr vpn) 2088567Sgblack@eecs.umich.edu { 2098567Sgblack@eecs.umich.edu entryHiAsid = asid; 2108567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2118567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2128567Sgblack@eecs.umich.edu badVAddr = vaddr; 2138567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2148567Sgblack@eecs.umich.edu } 2155222Sksewell@umich.edu#if FULL_SYSTEM 2167678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2177678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2185222Sksewell@umich.edu#endif 2195222Sksewell@umich.edu}; 2206378Sgblack@eecs.umich.edu 2218566Sgblack@eecs.umich.educlass DtbRefillFault : public MipsFault<DtbRefillFault> 2225222Sksewell@umich.edu{ 2235222Sksewell@umich.edu public: 2248567Sgblack@eecs.umich.edu DtbRefillFault(Addr asid, Addr vaddr, Addr vpn) 2258567Sgblack@eecs.umich.edu { 2268567Sgblack@eecs.umich.edu entryHiAsid = asid; 2278567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2288567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2298567Sgblack@eecs.umich.edu badVAddr = vaddr; 2308567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2318567Sgblack@eecs.umich.edu } 2325222Sksewell@umich.edu#if FULL_SYSTEM 2337678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2347678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2355222Sksewell@umich.edu#endif 2365222Sksewell@umich.edu}; 2375222Sksewell@umich.edu 2388566Sgblack@eecs.umich.educlass ItbInvalidFault : public MipsFault<ItbInvalidFault> 2395222Sksewell@umich.edu{ 2405222Sksewell@umich.edu public: 2418567Sgblack@eecs.umich.edu ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 2428567Sgblack@eecs.umich.edu { 2438567Sgblack@eecs.umich.edu entryHiAsid = asid; 2448567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2458567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2468567Sgblack@eecs.umich.edu badVAddr = vaddr; 2478567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2488567Sgblack@eecs.umich.edu } 2495222Sksewell@umich.edu#if FULL_SYSTEM 2507678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2517678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2525222Sksewell@umich.edu#endif 2536378Sgblack@eecs.umich.edu}; 2545222Sksewell@umich.edu 2558566Sgblack@eecs.umich.educlass TLBModifiedFault : public MipsFault<TLBModifiedFault> 2565222Sksewell@umich.edu{ 2575222Sksewell@umich.edu public: 2588567Sgblack@eecs.umich.edu TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) 2598567Sgblack@eecs.umich.edu { 2608567Sgblack@eecs.umich.edu entryHiAsid = asid; 2618567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2628567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2638567Sgblack@eecs.umich.edu badVAddr = vaddr; 2648567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2658567Sgblack@eecs.umich.edu } 2665222Sksewell@umich.edu#if FULL_SYSTEM 2677678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2687678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2695222Sksewell@umich.edu#endif 2705222Sksewell@umich.edu}; 2715222Sksewell@umich.edu 2728566Sgblack@eecs.umich.educlass DtbInvalidFault : public MipsFault<DtbInvalidFault> 2735222Sksewell@umich.edu{ 2745222Sksewell@umich.edu public: 2758567Sgblack@eecs.umich.edu DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn) 2768567Sgblack@eecs.umich.edu { 2778567Sgblack@eecs.umich.edu entryHiAsid = asid; 2788567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2798567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2808567Sgblack@eecs.umich.edu badVAddr = vaddr; 2818567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2828567Sgblack@eecs.umich.edu } 2835222Sksewell@umich.edu#if FULL_SYSTEM 2847678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2857678Sgblack@eecs.umich.edu StaticInst::StaticInstPtr inst = nullStaticInstPtr); 2865222Sksewell@umich.edu#endif 2875222Sksewell@umich.edu}; 2885222Sksewell@umich.edu 2898566Sgblack@eecs.umich.educlass DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 2905222Sksewell@umich.edu{ 2915222Sksewell@umich.edu public: 2927678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2937678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2944661Sksewell@umich.edu}; 2954661Sksewell@umich.edu 2967811Ssteve.reinhardt@amd.com} // namespace MipsISA 2972131SN/A 2985222Sksewell@umich.edu#endif // __MIPS_FAULTS_HH__ 299