faults.hh revision 8575
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
378575Sgblack@eecs.umich.edu#include "arch/mips/pra_constants.hh"
388575Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
398575Sgblack@eecs.umich.edu#include "debug/MipsPRA.hh"
402131SN/A#include "sim/faults.hh"
412447SN/A
422447SN/Anamespace MipsISA
432447SN/A{
446378Sgblack@eecs.umich.edu
452447SN/Atypedef const Addr FaultVect;
462131SN/A
478566Sgblack@eecs.umich.educlass MipsFaultBase : public FaultBase
482131SN/A{
492447SN/A  protected:
502447SN/A    virtual bool skipFaultingInstruction() {return false;}
512447SN/A    virtual bool setRestartAddress() {return true;}
522131SN/A  public:
538566Sgblack@eecs.umich.edu    struct FaultVals
548566Sgblack@eecs.umich.edu    {
558566Sgblack@eecs.umich.edu        const FaultName name;
568566Sgblack@eecs.umich.edu        const FaultVect vect;
578566Sgblack@eecs.umich.edu    };
588566Sgblack@eecs.umich.edu
592447SN/A#if FULL_SYSTEM
607678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
617678Sgblack@eecs.umich.edu            StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr)
627678Sgblack@eecs.umich.edu    {}
636378Sgblack@eecs.umich.edu    void setHandlerPC(Addr, ThreadContext *);
642447SN/A#endif
658574Sgblack@eecs.umich.edu    void setExceptionState(ThreadContext *, uint8_t);
662131SN/A};
672131SN/A
688566Sgblack@eecs.umich.edutemplate <typename T>
698566Sgblack@eecs.umich.educlass MipsFault : public MipsFaultBase
702131SN/A{
718566Sgblack@eecs.umich.edu  protected:
728566Sgblack@eecs.umich.edu    static FaultVals vals;
732131SN/A  public:
748566Sgblack@eecs.umich.edu    FaultName name() const { return vals.name; }
758566Sgblack@eecs.umich.edu    FaultVect vect() const { return vals.vect; }
768566Sgblack@eecs.umich.edu};
778566Sgblack@eecs.umich.edu
788575Sgblack@eecs.umich.edutemplate <typename T>
798575Sgblack@eecs.umich.educlass AddressFault : public MipsFault<T>
808575Sgblack@eecs.umich.edu{
818575Sgblack@eecs.umich.edu  protected:
828575Sgblack@eecs.umich.edu    Addr vaddr;
838575Sgblack@eecs.umich.edu    bool store;
848575Sgblack@eecs.umich.edu
858575Sgblack@eecs.umich.edu    AddressFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store)
868575Sgblack@eecs.umich.edu    {}
878575Sgblack@eecs.umich.edu};
888575Sgblack@eecs.umich.edu
898575Sgblack@eecs.umich.edutemplate <typename T>
908575Sgblack@eecs.umich.educlass TlbFault : public AddressFault<T>
918575Sgblack@eecs.umich.edu{
928575Sgblack@eecs.umich.edu  protected:
938575Sgblack@eecs.umich.edu    Addr asid;
948575Sgblack@eecs.umich.edu    Addr vpn;
958575Sgblack@eecs.umich.edu
968575Sgblack@eecs.umich.edu    TlbFault(Addr _asid, Addr _vaddr, Addr _vpn, bool _store) :
978575Sgblack@eecs.umich.edu        AddressFault<T>(_vaddr, _store), asid(_asid), vpn(_vpn)
988575Sgblack@eecs.umich.edu    {}
998575Sgblack@eecs.umich.edu
1008575Sgblack@eecs.umich.edu    void
1018575Sgblack@eecs.umich.edu    setTlbExceptionState(ThreadContext *tc, uint8_t excCode)
1028575Sgblack@eecs.umich.edu    {
1038575Sgblack@eecs.umich.edu        DPRINTF(MipsPRA, "%s encountered.\n", name());
1048575Sgblack@eecs.umich.edu        this->setExceptionState(tc, excCode);
1058575Sgblack@eecs.umich.edu
1068575Sgblack@eecs.umich.edu        tc->setMiscRegNoEffect(MISCREG_BADVADDR, this->vaddr);
1078575Sgblack@eecs.umich.edu        EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI);
1088575Sgblack@eecs.umich.edu        entryHi.asid = this->asid;
1098575Sgblack@eecs.umich.edu        entryHi.vpn2 = this->vpn >> 2;
1108575Sgblack@eecs.umich.edu        entryHi.vpn2x = this->vpn & 0x3;
1118575Sgblack@eecs.umich.edu        tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi);
1128575Sgblack@eecs.umich.edu
1138575Sgblack@eecs.umich.edu        ContextReg context = tc->readMiscReg(MISCREG_CONTEXT);
1148575Sgblack@eecs.umich.edu        context.badVPN2 = this->vpn >> 2;
1158575Sgblack@eecs.umich.edu        tc->setMiscRegNoEffect(MISCREG_CONTEXT, context);
1168575Sgblack@eecs.umich.edu    }
1178575Sgblack@eecs.umich.edu};
1188575Sgblack@eecs.umich.edu
1198566Sgblack@eecs.umich.educlass MachineCheckFault : public MipsFault<MachineCheckFault>
1208566Sgblack@eecs.umich.edu{
1218566Sgblack@eecs.umich.edu  public:
1225222Sksewell@umich.edu    bool isMachineCheckFault() {return true;}
1235222Sksewell@umich.edu};
1245222Sksewell@umich.edu
1258571Sgblack@eecs.umich.edustatic inline Fault genMachineCheckFault()
1268571Sgblack@eecs.umich.edu{
1278571Sgblack@eecs.umich.edu    return new MachineCheckFault;
1288571Sgblack@eecs.umich.edu}
1298571Sgblack@eecs.umich.edu
1308566Sgblack@eecs.umich.educlass NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt>
1315222Sksewell@umich.edu{
1325222Sksewell@umich.edu  public:
1335222Sksewell@umich.edu    bool isNonMaskableInterrupt() {return true;}
1342447SN/A};
1352131SN/A
1368575Sgblack@eecs.umich.educlass AddressErrorFault : public AddressFault<AddressErrorFault>
1375222Sksewell@umich.edu{
1385222Sksewell@umich.edu  public:
1398575Sgblack@eecs.umich.edu    AddressErrorFault(Addr _vaddr, bool _store) :
1408575Sgblack@eecs.umich.edu        AddressFault<AddressErrorFault>(_vaddr, _store)
1418570Sgblack@eecs.umich.edu    {}
1425222Sksewell@umich.edu#if FULL_SYSTEM
1437678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1447678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1455222Sksewell@umich.edu#endif
1465222Sksewell@umich.edu
1475222Sksewell@umich.edu};
1486378Sgblack@eecs.umich.edu
1498566Sgblack@eecs.umich.educlass ResetFault : public MipsFault<ResetFault>
1505222Sksewell@umich.edu{
1515222Sksewell@umich.edu  public:
1527678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1537678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1545222Sksewell@umich.edu
1555222Sksewell@umich.edu};
1566378Sgblack@eecs.umich.edu
1578566Sgblack@eecs.umich.educlass SystemCallFault : public MipsFault<SystemCallFault>
1585222Sksewell@umich.edu{
1595222Sksewell@umich.edu  public:
1608563Sgblack@eecs.umich.edu#if FULL_SYSTEM
1617678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1627678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1638563Sgblack@eecs.umich.edu#endif
1645222Sksewell@umich.edu};
1655222Sksewell@umich.edu
1668566Sgblack@eecs.umich.educlass SoftResetFault : public MipsFault<SoftResetFault>
1675222Sksewell@umich.edu{
1685222Sksewell@umich.edu  public:
1697678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1707678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1715222Sksewell@umich.edu};
1726378Sgblack@eecs.umich.edu
1738566Sgblack@eecs.umich.educlass CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault>
1745222Sksewell@umich.edu{
1758566Sgblack@eecs.umich.edu  protected:
1765222Sksewell@umich.edu    int coProcID;
1775222Sksewell@umich.edu  public:
1788566Sgblack@eecs.umich.edu    CoprocessorUnusableFault(int _procid) : coProcID(_procid)
1798566Sgblack@eecs.umich.edu    {}
1805222Sksewell@umich.edu
1817678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1827678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1835222Sksewell@umich.edu};
1845222Sksewell@umich.edu
1858566Sgblack@eecs.umich.educlass ReservedInstructionFault : public MipsFault<ReservedInstructionFault>
1865222Sksewell@umich.edu{
1875222Sksewell@umich.edu  public:
1887678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1897678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1905222Sksewell@umich.edu};
1915222Sksewell@umich.edu
1928566Sgblack@eecs.umich.educlass ThreadFault : public MipsFault<ThreadFault>
1938566Sgblack@eecs.umich.edu{
1948566Sgblack@eecs.umich.edu  public:
1958566Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
1968566Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1978566Sgblack@eecs.umich.edu};
1988566Sgblack@eecs.umich.edu
1998568Sgblack@eecs.umich.educlass IntegerOverflowFault : public MipsFault<IntegerOverflowFault>
2005222Sksewell@umich.edu{
2015222Sksewell@umich.edu  protected:
2025222Sksewell@umich.edu    bool skipFaultingInstruction() {return true;}
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 InterruptFault : public MipsFault<InterruptFault>
2115222Sksewell@umich.edu{
2125222Sksewell@umich.edu  protected:
2135222Sksewell@umich.edu    bool setRestartAddress() {return false;}
2145222Sksewell@umich.edu  public:
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};
2205222Sksewell@umich.edu
2218566Sgblack@eecs.umich.educlass TrapFault : public MipsFault<TrapFault>
2225222Sksewell@umich.edu{
2235222Sksewell@umich.edu  public:
2245222Sksewell@umich.edu#if FULL_SYSTEM
2257678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2267678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2275222Sksewell@umich.edu#endif
2285222Sksewell@umich.edu};
2295222Sksewell@umich.edu
2308566Sgblack@eecs.umich.educlass BreakpointFault : public MipsFault<BreakpointFault>
2315222Sksewell@umich.edu{
2325222Sksewell@umich.edu  public:
2335222Sksewell@umich.edu#if FULL_SYSTEM
2347678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2357678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2365222Sksewell@umich.edu#endif
2375222Sksewell@umich.edu};
2385222Sksewell@umich.edu
2398575Sgblack@eecs.umich.educlass TlbRefillFault : public TlbFault<TlbRefillFault>
2405222Sksewell@umich.edu{
2415222Sksewell@umich.edu  public:
2428575Sgblack@eecs.umich.edu    TlbRefillFault(Addr asid, Addr vaddr, Addr vpn, bool store) :
2438575Sgblack@eecs.umich.edu        TlbFault<TlbRefillFault>(asid, vaddr, vpn, store)
2448575Sgblack@eecs.umich.edu    {}
2455222Sksewell@umich.edu#if FULL_SYSTEM
2467678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2477678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2485222Sksewell@umich.edu#endif
2495222Sksewell@umich.edu};
2506378Sgblack@eecs.umich.edu
2518575Sgblack@eecs.umich.educlass TlbInvalidFault : public TlbFault<TlbInvalidFault>
2525222Sksewell@umich.edu{
2535222Sksewell@umich.edu  public:
2548575Sgblack@eecs.umich.edu    TlbInvalidFault(Addr asid, Addr vaddr, Addr vpn, bool store) :
2558575Sgblack@eecs.umich.edu        TlbFault<TlbInvalidFault>(asid, vaddr, vpn, store)
2568575Sgblack@eecs.umich.edu    {}
2575222Sksewell@umich.edu#if FULL_SYSTEM
2587678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2597678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2605222Sksewell@umich.edu#endif
2616378Sgblack@eecs.umich.edu};
2625222Sksewell@umich.edu
2638575Sgblack@eecs.umich.educlass TlbModifiedFault : public TlbFault<TlbModifiedFault>
2645222Sksewell@umich.edu{
2655222Sksewell@umich.edu  public:
2668575Sgblack@eecs.umich.edu    TlbModifiedFault(Addr asid, Addr vaddr, Addr vpn) :
2678575Sgblack@eecs.umich.edu        TlbFault<TlbModifiedFault>(asid, vaddr, vpn, false)
2688575Sgblack@eecs.umich.edu    {}
2695222Sksewell@umich.edu#if FULL_SYSTEM
2707678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2717678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2725222Sksewell@umich.edu#endif
2735222Sksewell@umich.edu};
2745222Sksewell@umich.edu
2758566Sgblack@eecs.umich.educlass DspStateDisabledFault : public MipsFault<DspStateDisabledFault>
2765222Sksewell@umich.edu{
2775222Sksewell@umich.edu  public:
2787678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2797678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2804661Sksewell@umich.edu};
2814661Sksewell@umich.edu
2827811Ssteve.reinhardt@amd.com} // namespace MipsISA
2832131SN/A
2845222Sksewell@umich.edu#endif // __MIPS_FAULTS_HH__
285