faults.hh revision 8574
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 }; 558566Sgblack@eecs.umich.edu 566379Sgblack@eecs.umich.edu Addr badVAddr; 576379Sgblack@eecs.umich.edu Addr entryHiAsid; 586379Sgblack@eecs.umich.edu Addr entryHiVPN2; 596379Sgblack@eecs.umich.edu Addr entryHiVPN2X; 606379Sgblack@eecs.umich.edu Addr contextBadVPN2; 612447SN/A#if FULL_SYSTEM 627678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 637678Sgblack@eecs.umich.edu StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr) 647678Sgblack@eecs.umich.edu {} 656378Sgblack@eecs.umich.edu void setHandlerPC(Addr, ThreadContext *); 662447SN/A#endif 678574Sgblack@eecs.umich.edu void setExceptionState(ThreadContext *, uint8_t); 682131SN/A}; 692131SN/A 708566Sgblack@eecs.umich.edutemplate <typename T> 718566Sgblack@eecs.umich.educlass MipsFault : public MipsFaultBase 722131SN/A{ 738566Sgblack@eecs.umich.edu protected: 748566Sgblack@eecs.umich.edu static FaultVals vals; 752131SN/A public: 768566Sgblack@eecs.umich.edu FaultName name() const { return vals.name; } 778566Sgblack@eecs.umich.edu FaultVect vect() const { return vals.vect; } 788566Sgblack@eecs.umich.edu}; 798566Sgblack@eecs.umich.edu 808566Sgblack@eecs.umich.educlass MachineCheckFault : public MipsFault<MachineCheckFault> 818566Sgblack@eecs.umich.edu{ 828566Sgblack@eecs.umich.edu public: 835222Sksewell@umich.edu bool isMachineCheckFault() {return true;} 845222Sksewell@umich.edu}; 855222Sksewell@umich.edu 868571Sgblack@eecs.umich.edustatic inline Fault genMachineCheckFault() 878571Sgblack@eecs.umich.edu{ 888571Sgblack@eecs.umich.edu return new MachineCheckFault; 898571Sgblack@eecs.umich.edu} 908571Sgblack@eecs.umich.edu 918566Sgblack@eecs.umich.educlass NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt> 925222Sksewell@umich.edu{ 935222Sksewell@umich.edu public: 945222Sksewell@umich.edu bool isNonMaskableInterrupt() {return true;} 952447SN/A}; 962131SN/A 978566Sgblack@eecs.umich.educlass AddressErrorFault : public MipsFault<AddressErrorFault> 985222Sksewell@umich.edu{ 998570Sgblack@eecs.umich.edu protected: 1008570Sgblack@eecs.umich.edu Addr vaddr; 1018570Sgblack@eecs.umich.edu bool store; 1025222Sksewell@umich.edu public: 1038570Sgblack@eecs.umich.edu AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store) 1048570Sgblack@eecs.umich.edu {} 1055222Sksewell@umich.edu#if FULL_SYSTEM 1067678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1077678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1085222Sksewell@umich.edu#endif 1095222Sksewell@umich.edu 1105222Sksewell@umich.edu}; 1116378Sgblack@eecs.umich.edu 1128566Sgblack@eecs.umich.educlass ResetFault : public MipsFault<ResetFault> 1135222Sksewell@umich.edu{ 1145222Sksewell@umich.edu public: 1157678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1167678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1175222Sksewell@umich.edu 1185222Sksewell@umich.edu}; 1196378Sgblack@eecs.umich.edu 1208566Sgblack@eecs.umich.educlass SystemCallFault : public MipsFault<SystemCallFault> 1215222Sksewell@umich.edu{ 1225222Sksewell@umich.edu public: 1238563Sgblack@eecs.umich.edu#if FULL_SYSTEM 1247678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1257678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1268563Sgblack@eecs.umich.edu#endif 1275222Sksewell@umich.edu}; 1285222Sksewell@umich.edu 1298566Sgblack@eecs.umich.educlass SoftResetFault : public MipsFault<SoftResetFault> 1305222Sksewell@umich.edu{ 1315222Sksewell@umich.edu public: 1327678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1337678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1345222Sksewell@umich.edu}; 1356378Sgblack@eecs.umich.edu 1368566Sgblack@eecs.umich.educlass CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault> 1375222Sksewell@umich.edu{ 1388566Sgblack@eecs.umich.edu protected: 1395222Sksewell@umich.edu int coProcID; 1405222Sksewell@umich.edu public: 1418566Sgblack@eecs.umich.edu CoprocessorUnusableFault(int _procid) : coProcID(_procid) 1428566Sgblack@eecs.umich.edu {} 1435222Sksewell@umich.edu 1447678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1457678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1465222Sksewell@umich.edu}; 1475222Sksewell@umich.edu 1488566Sgblack@eecs.umich.educlass ReservedInstructionFault : public MipsFault<ReservedInstructionFault> 1495222Sksewell@umich.edu{ 1505222Sksewell@umich.edu public: 1517678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1527678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1535222Sksewell@umich.edu}; 1545222Sksewell@umich.edu 1558566Sgblack@eecs.umich.educlass ThreadFault : public MipsFault<ThreadFault> 1568566Sgblack@eecs.umich.edu{ 1578566Sgblack@eecs.umich.edu public: 1588566Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1598566Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1608566Sgblack@eecs.umich.edu}; 1618566Sgblack@eecs.umich.edu 1628568Sgblack@eecs.umich.educlass IntegerOverflowFault : public MipsFault<IntegerOverflowFault> 1635222Sksewell@umich.edu{ 1645222Sksewell@umich.edu protected: 1655222Sksewell@umich.edu bool skipFaultingInstruction() {return true;} 1665222Sksewell@umich.edu public: 1675222Sksewell@umich.edu#if FULL_SYSTEM 1687678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1697678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1705222Sksewell@umich.edu#endif 1715222Sksewell@umich.edu}; 1725222Sksewell@umich.edu 1738566Sgblack@eecs.umich.educlass InterruptFault : public MipsFault<InterruptFault> 1745222Sksewell@umich.edu{ 1755222Sksewell@umich.edu protected: 1765222Sksewell@umich.edu bool setRestartAddress() {return false;} 1775222Sksewell@umich.edu public: 1785222Sksewell@umich.edu#if FULL_SYSTEM 1797678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1807678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1815222Sksewell@umich.edu#endif 1825222Sksewell@umich.edu}; 1835222Sksewell@umich.edu 1848566Sgblack@eecs.umich.educlass TrapFault : public MipsFault<TrapFault> 1855222Sksewell@umich.edu{ 1865222Sksewell@umich.edu public: 1875222Sksewell@umich.edu#if FULL_SYSTEM 1887678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1897678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1905222Sksewell@umich.edu#endif 1915222Sksewell@umich.edu}; 1925222Sksewell@umich.edu 1938566Sgblack@eecs.umich.educlass BreakpointFault : public MipsFault<BreakpointFault> 1945222Sksewell@umich.edu{ 1955222Sksewell@umich.edu public: 1965222Sksewell@umich.edu#if FULL_SYSTEM 1977678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 1987678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 1995222Sksewell@umich.edu#endif 2005222Sksewell@umich.edu}; 2015222Sksewell@umich.edu 2028573Sgblack@eecs.umich.educlass TlbRefillFault : public MipsFault<TlbRefillFault> 2035222Sksewell@umich.edu{ 2048573Sgblack@eecs.umich.edu protected: 2058573Sgblack@eecs.umich.edu bool store; 2065222Sksewell@umich.edu public: 2078573Sgblack@eecs.umich.edu TlbRefillFault(Addr asid, Addr vaddr, Addr vpn, bool _store) : 2088573Sgblack@eecs.umich.edu store(_store) 2098567Sgblack@eecs.umich.edu { 2108567Sgblack@eecs.umich.edu entryHiAsid = asid; 2118567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2128567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2138567Sgblack@eecs.umich.edu badVAddr = vaddr; 2148567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2158567Sgblack@eecs.umich.edu } 2165222Sksewell@umich.edu#if FULL_SYSTEM 2177678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2187678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2195222Sksewell@umich.edu#endif 2205222Sksewell@umich.edu}; 2216378Sgblack@eecs.umich.edu 2228573Sgblack@eecs.umich.educlass TlbInvalidFault : public MipsFault<TlbInvalidFault> 2235222Sksewell@umich.edu{ 2248573Sgblack@eecs.umich.edu protected: 2258573Sgblack@eecs.umich.edu bool store; 2265222Sksewell@umich.edu public: 2278573Sgblack@eecs.umich.edu TlbInvalidFault(Addr asid, Addr vaddr, Addr vpn, bool _store) : 2288573Sgblack@eecs.umich.edu store(_store) 2298567Sgblack@eecs.umich.edu { 2308567Sgblack@eecs.umich.edu entryHiAsid = asid; 2318567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2328567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2338567Sgblack@eecs.umich.edu badVAddr = vaddr; 2348567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2358567Sgblack@eecs.umich.edu } 2365222Sksewell@umich.edu#if FULL_SYSTEM 2377678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2387678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2395222Sksewell@umich.edu#endif 2406378Sgblack@eecs.umich.edu}; 2415222Sksewell@umich.edu 2428566Sgblack@eecs.umich.educlass TLBModifiedFault : public MipsFault<TLBModifiedFault> 2435222Sksewell@umich.edu{ 2445222Sksewell@umich.edu public: 2458567Sgblack@eecs.umich.edu TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn) 2468567Sgblack@eecs.umich.edu { 2478567Sgblack@eecs.umich.edu entryHiAsid = asid; 2488567Sgblack@eecs.umich.edu entryHiVPN2 = vpn >> 2; 2498567Sgblack@eecs.umich.edu entryHiVPN2X = vpn & 0x3; 2508567Sgblack@eecs.umich.edu badVAddr = vaddr; 2518567Sgblack@eecs.umich.edu contextBadVPN2 = vpn >> 2; 2528567Sgblack@eecs.umich.edu } 2535222Sksewell@umich.edu#if FULL_SYSTEM 2547678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2557678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2565222Sksewell@umich.edu#endif 2575222Sksewell@umich.edu}; 2585222Sksewell@umich.edu 2598566Sgblack@eecs.umich.educlass DspStateDisabledFault : public MipsFault<DspStateDisabledFault> 2605222Sksewell@umich.edu{ 2615222Sksewell@umich.edu public: 2627678Sgblack@eecs.umich.edu void invoke(ThreadContext * tc, 2637678Sgblack@eecs.umich.edu StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2644661Sksewell@umich.edu}; 2654661Sksewell@umich.edu 2667811Ssteve.reinhardt@amd.com} // namespace MipsISA 2672131SN/A 2685222Sksewell@umich.edu#endif // __MIPS_FAULTS_HH__ 269