faults.hh revision 7678
12221SN/A/*
22221SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32221SN/A * All rights reserved.
42221SN/A *
52221SN/A * Redistribution and use in source and binary forms, with or without
62221SN/A * modification, are permitted provided that the following conditions are
72221SN/A * met: redistributions of source code must retain the above copyright
82221SN/A * notice, this list of conditions and the following disclaimer;
92221SN/A * redistributions in binary form must reproduce the above copyright
102221SN/A * notice, this list of conditions and the following disclaimer in the
112221SN/A * documentation and/or other materials provided with the distribution;
122221SN/A * neither the name of the copyright holders nor the names of its
132221SN/A * contributors may be used to endorse or promote products derived from
142221SN/A * this software without specific prior written permission.
152221SN/A *
162221SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172221SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182221SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192221SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202221SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212221SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222221SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232221SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242221SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252221SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262221SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292665Ssaidi@eecs.umich.edu *          Kevin Lim
302221SN/A */
312221SN/A
323890Ssaidi@eecs.umich.edu#ifndef __SPARC_FAULTS_HH__
333890Ssaidi@eecs.umich.edu#define __SPARC_FAULTS_HH__
342221SN/A
354997Sgblack@eecs.umich.edu#include "config/full_system.hh"
367678Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
372221SN/A#include "sim/faults.hh"
382221SN/A
392221SN/A// The design of the "name" and "vect" functions is in sim/faults.hh
402221SN/A
412223SN/Anamespace SparcISA
422221SN/A{
432221SN/A
443415Sgblack@eecs.umich.edutypedef uint32_t TrapType;
453415Sgblack@eecs.umich.edutypedef uint32_t FaultPriority;
462221SN/A
474997Sgblack@eecs.umich.educlass ITB;
484997Sgblack@eecs.umich.edu
493573Sgblack@eecs.umich.educlass SparcFaultBase : public FaultBase
502221SN/A{
512221SN/A  public:
523576Sgblack@eecs.umich.edu    enum PrivilegeLevel
533576Sgblack@eecs.umich.edu    {
543576Sgblack@eecs.umich.edu        U, User = U,
553576Sgblack@eecs.umich.edu        P, Privileged = P,
563576Sgblack@eecs.umich.edu        H, Hyperprivileged = H,
573576Sgblack@eecs.umich.edu        NumLevels,
583576Sgblack@eecs.umich.edu        SH = -1,
593576Sgblack@eecs.umich.edu        ShouldntHappen = SH
603576Sgblack@eecs.umich.edu    };
613573Sgblack@eecs.umich.edu    struct FaultVals
623573Sgblack@eecs.umich.edu    {
633573Sgblack@eecs.umich.edu        const FaultName name;
643573Sgblack@eecs.umich.edu        const TrapType trapType;
653573Sgblack@eecs.umich.edu        const FaultPriority priority;
663576Sgblack@eecs.umich.edu        const PrivilegeLevel nextPrivilegeLevel[NumLevels];
673573Sgblack@eecs.umich.edu        FaultStat count;
683573Sgblack@eecs.umich.edu    };
692221SN/A#if FULL_SYSTEM
707678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
717678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
722221SN/A#endif
732223SN/A    virtual TrapType trapType() = 0;
742223SN/A    virtual FaultPriority priority() = 0;
752223SN/A    virtual FaultStat & countStat() = 0;
763576Sgblack@eecs.umich.edu    virtual PrivilegeLevel getNextLevel(PrivilegeLevel current) = 0;
772221SN/A};
782221SN/A
793573Sgblack@eecs.umich.edutemplate<typename T>
803573Sgblack@eecs.umich.educlass SparcFault : public SparcFaultBase
812221SN/A{
823573Sgblack@eecs.umich.edu  protected:
833573Sgblack@eecs.umich.edu    static FaultVals vals;
842221SN/A  public:
854695Sgblack@eecs.umich.edu    FaultName name() const {return vals.name;}
863573Sgblack@eecs.umich.edu    TrapType trapType() {return vals.trapType;}
873573Sgblack@eecs.umich.edu    FaultPriority priority() {return vals.priority;}
883573Sgblack@eecs.umich.edu    FaultStat & countStat() {return vals.count;}
893576Sgblack@eecs.umich.edu    PrivilegeLevel getNextLevel(PrivilegeLevel current)
903576Sgblack@eecs.umich.edu    {
913576Sgblack@eecs.umich.edu        return vals.nextPrivilegeLevel[current];
923576Sgblack@eecs.umich.edu    }
933573Sgblack@eecs.umich.edu};
943573Sgblack@eecs.umich.edu
953576Sgblack@eecs.umich.educlass PowerOnReset : public SparcFault<PowerOnReset>
963576Sgblack@eecs.umich.edu{
977678Sgblack@eecs.umich.edu#if FULL_SYSTEM
987678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
997678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
1007678Sgblack@eecs.umich.edu#endif
1013576Sgblack@eecs.umich.edu};
1023576Sgblack@eecs.umich.edu
1033576Sgblack@eecs.umich.educlass WatchDogReset : public SparcFault<WatchDogReset> {};
1043576Sgblack@eecs.umich.edu
1053576Sgblack@eecs.umich.educlass ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
1063576Sgblack@eecs.umich.edu
1073576Sgblack@eecs.umich.educlass SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
1083576Sgblack@eecs.umich.edu
1093576Sgblack@eecs.umich.educlass REDStateException : public SparcFault<REDStateException> {};
1103576Sgblack@eecs.umich.edu
1113576Sgblack@eecs.umich.educlass StoreError : public SparcFault<StoreError> {};
1123576Sgblack@eecs.umich.edu
1133576Sgblack@eecs.umich.educlass InstructionAccessException : public SparcFault<InstructionAccessException> {};
1143576Sgblack@eecs.umich.edu
1153576Sgblack@eecs.umich.edu//class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
1163576Sgblack@eecs.umich.edu
1173576Sgblack@eecs.umich.educlass InstructionAccessError : public SparcFault<InstructionAccessError> {};
1183576Sgblack@eecs.umich.edu
1193576Sgblack@eecs.umich.educlass IllegalInstruction : public SparcFault<IllegalInstruction> {};
1203576Sgblack@eecs.umich.edu
1213576Sgblack@eecs.umich.educlass PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
1223576Sgblack@eecs.umich.edu
1233576Sgblack@eecs.umich.edu//class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
1243576Sgblack@eecs.umich.edu
1253576Sgblack@eecs.umich.edu//class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
1263576Sgblack@eecs.umich.edu
1273576Sgblack@eecs.umich.educlass FpDisabled : public SparcFault<FpDisabled> {};
1283576Sgblack@eecs.umich.edu
1293576Sgblack@eecs.umich.educlass FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
1303576Sgblack@eecs.umich.edu
1313576Sgblack@eecs.umich.educlass FpExceptionOther : public SparcFault<FpExceptionOther> {};
1323576Sgblack@eecs.umich.edu
1333576Sgblack@eecs.umich.educlass TagOverflow : public SparcFault<TagOverflow> {};
1343576Sgblack@eecs.umich.edu
1353576Sgblack@eecs.umich.educlass CleanWindow : public SparcFault<CleanWindow> {};
1363576Sgblack@eecs.umich.edu
1373576Sgblack@eecs.umich.educlass DivisionByZero : public SparcFault<DivisionByZero> {};
1383576Sgblack@eecs.umich.edu
1393573Sgblack@eecs.umich.educlass InternalProcessorError :
1403573Sgblack@eecs.umich.edu    public SparcFault<InternalProcessorError>
1413573Sgblack@eecs.umich.edu{
1423573Sgblack@eecs.umich.edu  public:
1434695Sgblack@eecs.umich.edu    bool isMachineCheckFault() const {return true;}
1442221SN/A};
1452221SN/A
1463576Sgblack@eecs.umich.educlass InstructionInvalidTSBEntry : public SparcFault<InstructionInvalidTSBEntry> {};
1473576Sgblack@eecs.umich.edu
1483576Sgblack@eecs.umich.educlass DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
1493576Sgblack@eecs.umich.edu
1503576Sgblack@eecs.umich.educlass DataAccessException : public SparcFault<DataAccessException> {};
1513576Sgblack@eecs.umich.edu
1523576Sgblack@eecs.umich.edu//class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
1533576Sgblack@eecs.umich.edu
1543576Sgblack@eecs.umich.educlass DataAccessError : public SparcFault<DataAccessError> {};
1553576Sgblack@eecs.umich.edu
1563576Sgblack@eecs.umich.educlass DataAccessProtection : public SparcFault<DataAccessProtection> {};
1573576Sgblack@eecs.umich.edu
1583573Sgblack@eecs.umich.educlass MemAddressNotAligned :
1593573Sgblack@eecs.umich.edu    public SparcFault<MemAddressNotAligned>
1602221SN/A{
1612221SN/A  public:
1624695Sgblack@eecs.umich.edu    bool isAlignmentFault() const {return true;}
1632221SN/A};
1642221SN/A
1653576Sgblack@eecs.umich.educlass LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
1663576Sgblack@eecs.umich.edu
1673576Sgblack@eecs.umich.educlass STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
1683576Sgblack@eecs.umich.edu
1693576Sgblack@eecs.umich.educlass PrivilegedAction : public SparcFault<PrivilegedAction> {};
1703576Sgblack@eecs.umich.edu
1713576Sgblack@eecs.umich.educlass LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
1723576Sgblack@eecs.umich.edu
1733576Sgblack@eecs.umich.educlass STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
1743576Sgblack@eecs.umich.edu
1753576Sgblack@eecs.umich.educlass InstructionRealTranslationMiss :
1763576Sgblack@eecs.umich.edu    public SparcFault<InstructionRealTranslationMiss> {};
1773576Sgblack@eecs.umich.edu
1783576Sgblack@eecs.umich.educlass DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
1793576Sgblack@eecs.umich.edu
1803576Sgblack@eecs.umich.edu//class AsyncDataError : public SparcFault<AsyncDataError> {};
1813576Sgblack@eecs.umich.edu
1823576Sgblack@eecs.umich.edutemplate <class T>
1833576Sgblack@eecs.umich.educlass EnumeratedFault : public SparcFault<T>
1843576Sgblack@eecs.umich.edu{
1853576Sgblack@eecs.umich.edu  protected:
1863576Sgblack@eecs.umich.edu    uint32_t _n;
1873576Sgblack@eecs.umich.edu  public:
1883576Sgblack@eecs.umich.edu    EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
1893576Sgblack@eecs.umich.edu    TrapType trapType() {return SparcFault<T>::trapType() + _n;}
1903576Sgblack@eecs.umich.edu};
1913576Sgblack@eecs.umich.edu
1923576Sgblack@eecs.umich.educlass InterruptLevelN : public EnumeratedFault<InterruptLevelN>
1933576Sgblack@eecs.umich.edu{
1943576Sgblack@eecs.umich.edu  public:
1953576Sgblack@eecs.umich.edu    InterruptLevelN(uint32_t n) : EnumeratedFault<InterruptLevelN>(n) {;}
1963576Sgblack@eecs.umich.edu    FaultPriority priority() {return 3200 - _n*100;}
1973576Sgblack@eecs.umich.edu};
1983576Sgblack@eecs.umich.edu
1993576Sgblack@eecs.umich.educlass HstickMatch : public SparcFault<HstickMatch> {};
2003576Sgblack@eecs.umich.edu
2013576Sgblack@eecs.umich.educlass TrapLevelZero : public SparcFault<TrapLevelZero> {};
2023576Sgblack@eecs.umich.edu
2034103Ssaidi@eecs.umich.educlass InterruptVector : public SparcFault<InterruptVector> {};
2044103Ssaidi@eecs.umich.edu
2053576Sgblack@eecs.umich.educlass PAWatchpoint : public SparcFault<PAWatchpoint> {};
2063576Sgblack@eecs.umich.edu
2073576Sgblack@eecs.umich.educlass VAWatchpoint : public SparcFault<VAWatchpoint> {};
2083576Sgblack@eecs.umich.edu
2093576Sgblack@eecs.umich.educlass FastInstructionAccessMMUMiss :
2104997Sgblack@eecs.umich.edu    public SparcFault<FastInstructionAccessMMUMiss>
2114997Sgblack@eecs.umich.edu{
2124997Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2134997Sgblack@eecs.umich.edu  protected:
2144997Sgblack@eecs.umich.edu    Addr vaddr;
2154997Sgblack@eecs.umich.edu  public:
2164997Sgblack@eecs.umich.edu    FastInstructionAccessMMUMiss(Addr addr) : vaddr(addr)
2174997Sgblack@eecs.umich.edu    {}
2187678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2197678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2204997Sgblack@eecs.umich.edu#endif
2214997Sgblack@eecs.umich.edu};
2223576Sgblack@eecs.umich.edu
2234997Sgblack@eecs.umich.educlass FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss>
2244997Sgblack@eecs.umich.edu{
2254997Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2264997Sgblack@eecs.umich.edu  protected:
2274997Sgblack@eecs.umich.edu    Addr vaddr;
2284997Sgblack@eecs.umich.edu  public:
2294997Sgblack@eecs.umich.edu    FastDataAccessMMUMiss(Addr addr) : vaddr(addr)
2304997Sgblack@eecs.umich.edu    {}
2317678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2327678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2334997Sgblack@eecs.umich.edu#endif
2344997Sgblack@eecs.umich.edu};
2353576Sgblack@eecs.umich.edu
2363576Sgblack@eecs.umich.educlass FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
2373576Sgblack@eecs.umich.edu
2383576Sgblack@eecs.umich.educlass InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
2393576Sgblack@eecs.umich.edu
2403576Sgblack@eecs.umich.educlass CpuMondo : public SparcFault<CpuMondo> {};
2413576Sgblack@eecs.umich.edu
2423576Sgblack@eecs.umich.educlass DevMondo : public SparcFault<DevMondo> {};
2433576Sgblack@eecs.umich.edu
2443893Shsul@eecs.umich.educlass ResumableError : public SparcFault<ResumableError> {};
2453576Sgblack@eecs.umich.edu
2463576Sgblack@eecs.umich.educlass SpillNNormal : public EnumeratedFault<SpillNNormal>
2473576Sgblack@eecs.umich.edu{
2483576Sgblack@eecs.umich.edu  public:
2493576Sgblack@eecs.umich.edu    SpillNNormal(uint32_t n) : EnumeratedFault<SpillNNormal>(n) {;}
2503576Sgblack@eecs.umich.edu    //These need to be handled specially to enable spill traps in SE
2513576Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2527678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2537678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2543576Sgblack@eecs.umich.edu#endif
2553576Sgblack@eecs.umich.edu};
2563576Sgblack@eecs.umich.edu
2573576Sgblack@eecs.umich.educlass SpillNOther : public EnumeratedFault<SpillNOther>
2583576Sgblack@eecs.umich.edu{
2593576Sgblack@eecs.umich.edu  public:
2603576Sgblack@eecs.umich.edu    SpillNOther(uint32_t n) : EnumeratedFault<SpillNOther>(n) {;}
2613576Sgblack@eecs.umich.edu};
2623576Sgblack@eecs.umich.edu
2633576Sgblack@eecs.umich.educlass FillNNormal : public EnumeratedFault<FillNNormal>
2643576Sgblack@eecs.umich.edu{
2653576Sgblack@eecs.umich.edu  public:
2663576Sgblack@eecs.umich.edu    FillNNormal(uint32_t n) : EnumeratedFault<FillNNormal>(n) {;}
2673576Sgblack@eecs.umich.edu    //These need to be handled specially to enable fill traps in SE
2683576Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2697678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2707678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2713576Sgblack@eecs.umich.edu#endif
2723576Sgblack@eecs.umich.edu};
2733576Sgblack@eecs.umich.edu
2743576Sgblack@eecs.umich.educlass FillNOther : public EnumeratedFault<FillNOther>
2753576Sgblack@eecs.umich.edu{
2763576Sgblack@eecs.umich.edu  public:
2773576Sgblack@eecs.umich.edu    FillNOther(uint32_t n) : EnumeratedFault<FillNOther>(n) {;}
2783576Sgblack@eecs.umich.edu};
2793576Sgblack@eecs.umich.edu
2803576Sgblack@eecs.umich.educlass TrapInstruction : public EnumeratedFault<TrapInstruction>
2813576Sgblack@eecs.umich.edu{
2823576Sgblack@eecs.umich.edu  public:
2833576Sgblack@eecs.umich.edu    TrapInstruction(uint32_t n) : EnumeratedFault<TrapInstruction>(n) {;}
2844111Sgblack@eecs.umich.edu    //In SE, trap instructions are requesting services from the OS.
2854111Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2867678Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc,
2877678Sgblack@eecs.umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
2884111Sgblack@eecs.umich.edu#endif
2893576Sgblack@eecs.umich.edu};
2903576Sgblack@eecs.umich.edu
2912221SN/Astatic inline Fault genMachineCheckFault()
2922221SN/A{
2932223SN/A    return new InternalProcessorError;
2942221SN/A}
2952221SN/A
2962800Ssaidi@eecs.umich.edu
2972223SN/A} // SparcISA namespace
2982221SN/A
2993890Ssaidi@eecs.umich.edu#endif // __SPARC_FAULTS_HH__
300