faults.hh revision 3893
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
352221SN/A#include "sim/faults.hh"
362221SN/A
372221SN/A// The design of the "name" and "vect" functions is in sim/faults.hh
382221SN/A
392223SN/Anamespace SparcISA
402221SN/A{
412221SN/A
423415Sgblack@eecs.umich.edutypedef uint32_t TrapType;
433415Sgblack@eecs.umich.edutypedef uint32_t FaultPriority;
442221SN/A
453573Sgblack@eecs.umich.educlass SparcFaultBase : public FaultBase
462221SN/A{
472221SN/A  public:
483576Sgblack@eecs.umich.edu    enum PrivilegeLevel
493576Sgblack@eecs.umich.edu    {
503576Sgblack@eecs.umich.edu        U, User = U,
513576Sgblack@eecs.umich.edu        P, Privileged = P,
523576Sgblack@eecs.umich.edu        H, Hyperprivileged = H,
533576Sgblack@eecs.umich.edu        NumLevels,
543576Sgblack@eecs.umich.edu        SH = -1,
553576Sgblack@eecs.umich.edu        ShouldntHappen = SH
563576Sgblack@eecs.umich.edu    };
573573Sgblack@eecs.umich.edu    struct FaultVals
583573Sgblack@eecs.umich.edu    {
593573Sgblack@eecs.umich.edu        const FaultName name;
603573Sgblack@eecs.umich.edu        const TrapType trapType;
613573Sgblack@eecs.umich.edu        const FaultPriority priority;
623576Sgblack@eecs.umich.edu        const PrivilegeLevel nextPrivilegeLevel[NumLevels];
633573Sgblack@eecs.umich.edu        FaultStat count;
643573Sgblack@eecs.umich.edu    };
652221SN/A#if FULL_SYSTEM
662680Sktlim@umich.edu    void invoke(ThreadContext * tc);
672221SN/A#endif
683573Sgblack@eecs.umich.edu    virtual FaultName name() = 0;
692223SN/A    virtual TrapType trapType() = 0;
702223SN/A    virtual FaultPriority priority() = 0;
712223SN/A    virtual FaultStat & countStat() = 0;
723576Sgblack@eecs.umich.edu    virtual PrivilegeLevel getNextLevel(PrivilegeLevel current) = 0;
732221SN/A};
742221SN/A
753573Sgblack@eecs.umich.edutemplate<typename T>
763573Sgblack@eecs.umich.educlass SparcFault : public SparcFaultBase
772221SN/A{
783573Sgblack@eecs.umich.edu  protected:
793573Sgblack@eecs.umich.edu    static FaultVals vals;
802221SN/A  public:
813573Sgblack@eecs.umich.edu    FaultName name() {return vals.name;}
823573Sgblack@eecs.umich.edu    TrapType trapType() {return vals.trapType;}
833573Sgblack@eecs.umich.edu    FaultPriority priority() {return vals.priority;}
843573Sgblack@eecs.umich.edu    FaultStat & countStat() {return vals.count;}
853576Sgblack@eecs.umich.edu    PrivilegeLevel getNextLevel(PrivilegeLevel current)
863576Sgblack@eecs.umich.edu    {
873576Sgblack@eecs.umich.edu        return vals.nextPrivilegeLevel[current];
883576Sgblack@eecs.umich.edu    }
893573Sgblack@eecs.umich.edu};
903573Sgblack@eecs.umich.edu
913576Sgblack@eecs.umich.educlass PowerOnReset : public SparcFault<PowerOnReset>
923576Sgblack@eecs.umich.edu{
933576Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc);
943576Sgblack@eecs.umich.edu};
953576Sgblack@eecs.umich.edu
963576Sgblack@eecs.umich.educlass WatchDogReset : public SparcFault<WatchDogReset> {};
973576Sgblack@eecs.umich.edu
983576Sgblack@eecs.umich.educlass ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
993576Sgblack@eecs.umich.edu
1003576Sgblack@eecs.umich.educlass SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
1013576Sgblack@eecs.umich.edu
1023576Sgblack@eecs.umich.educlass REDStateException : public SparcFault<REDStateException> {};
1033576Sgblack@eecs.umich.edu
1043576Sgblack@eecs.umich.educlass StoreError : public SparcFault<StoreError> {};
1053576Sgblack@eecs.umich.edu
1063576Sgblack@eecs.umich.educlass InstructionAccessException : public SparcFault<InstructionAccessException> {};
1073576Sgblack@eecs.umich.edu
1083576Sgblack@eecs.umich.edu//class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
1093576Sgblack@eecs.umich.edu
1103576Sgblack@eecs.umich.educlass InstructionAccessError : public SparcFault<InstructionAccessError> {};
1113576Sgblack@eecs.umich.edu
1123576Sgblack@eecs.umich.educlass IllegalInstruction : public SparcFault<IllegalInstruction> {};
1133576Sgblack@eecs.umich.edu
1143576Sgblack@eecs.umich.educlass PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
1153576Sgblack@eecs.umich.edu
1163576Sgblack@eecs.umich.edu//class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
1173576Sgblack@eecs.umich.edu
1183576Sgblack@eecs.umich.edu//class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
1193576Sgblack@eecs.umich.edu
1203576Sgblack@eecs.umich.educlass FpDisabled : public SparcFault<FpDisabled> {};
1213576Sgblack@eecs.umich.edu
1223576Sgblack@eecs.umich.educlass FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
1233576Sgblack@eecs.umich.edu
1243576Sgblack@eecs.umich.educlass FpExceptionOther : public SparcFault<FpExceptionOther> {};
1253576Sgblack@eecs.umich.edu
1263576Sgblack@eecs.umich.educlass TagOverflow : public SparcFault<TagOverflow> {};
1273576Sgblack@eecs.umich.edu
1283576Sgblack@eecs.umich.educlass CleanWindow : public SparcFault<CleanWindow> {};
1293576Sgblack@eecs.umich.edu
1303576Sgblack@eecs.umich.educlass DivisionByZero : public SparcFault<DivisionByZero> {};
1313576Sgblack@eecs.umich.edu
1323573Sgblack@eecs.umich.educlass InternalProcessorError :
1333573Sgblack@eecs.umich.edu    public SparcFault<InternalProcessorError>
1343573Sgblack@eecs.umich.edu{
1353573Sgblack@eecs.umich.edu  public:
1362221SN/A    bool isMachineCheckFault() {return true;}
1372221SN/A};
1382221SN/A
1393576Sgblack@eecs.umich.educlass InstructionInvalidTSBEntry : public SparcFault<InstructionInvalidTSBEntry> {};
1403576Sgblack@eecs.umich.edu
1413576Sgblack@eecs.umich.educlass DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
1423576Sgblack@eecs.umich.edu
1433576Sgblack@eecs.umich.educlass DataAccessException : public SparcFault<DataAccessException> {};
1443576Sgblack@eecs.umich.edu
1453576Sgblack@eecs.umich.edu//class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
1463576Sgblack@eecs.umich.edu
1473576Sgblack@eecs.umich.educlass DataAccessError : public SparcFault<DataAccessError> {};
1483576Sgblack@eecs.umich.edu
1493576Sgblack@eecs.umich.educlass DataAccessProtection : public SparcFault<DataAccessProtection> {};
1503576Sgblack@eecs.umich.edu
1513573Sgblack@eecs.umich.educlass MemAddressNotAligned :
1523573Sgblack@eecs.umich.edu    public SparcFault<MemAddressNotAligned>
1532221SN/A{
1542221SN/A  public:
1552221SN/A    bool isAlignmentFault() {return true;}
1562221SN/A};
1572221SN/A
1583576Sgblack@eecs.umich.educlass LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
1593576Sgblack@eecs.umich.edu
1603576Sgblack@eecs.umich.educlass STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
1613576Sgblack@eecs.umich.edu
1623576Sgblack@eecs.umich.educlass PrivilegedAction : public SparcFault<PrivilegedAction> {};
1633576Sgblack@eecs.umich.edu
1643576Sgblack@eecs.umich.educlass LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
1653576Sgblack@eecs.umich.edu
1663576Sgblack@eecs.umich.educlass STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
1673576Sgblack@eecs.umich.edu
1683576Sgblack@eecs.umich.educlass InstructionRealTranslationMiss :
1693576Sgblack@eecs.umich.edu    public SparcFault<InstructionRealTranslationMiss> {};
1703576Sgblack@eecs.umich.edu
1713576Sgblack@eecs.umich.educlass DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
1723576Sgblack@eecs.umich.edu
1733576Sgblack@eecs.umich.edu//class AsyncDataError : public SparcFault<AsyncDataError> {};
1743576Sgblack@eecs.umich.edu
1753576Sgblack@eecs.umich.edutemplate <class T>
1763576Sgblack@eecs.umich.educlass EnumeratedFault : public SparcFault<T>
1773576Sgblack@eecs.umich.edu{
1783576Sgblack@eecs.umich.edu  protected:
1793576Sgblack@eecs.umich.edu    uint32_t _n;
1803576Sgblack@eecs.umich.edu  public:
1813576Sgblack@eecs.umich.edu    EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
1823576Sgblack@eecs.umich.edu    TrapType trapType() {return SparcFault<T>::trapType() + _n;}
1833576Sgblack@eecs.umich.edu};
1843576Sgblack@eecs.umich.edu
1853576Sgblack@eecs.umich.educlass InterruptLevelN : public EnumeratedFault<InterruptLevelN>
1863576Sgblack@eecs.umich.edu{
1873576Sgblack@eecs.umich.edu  public:
1883576Sgblack@eecs.umich.edu    InterruptLevelN(uint32_t n) : EnumeratedFault<InterruptLevelN>(n) {;}
1893576Sgblack@eecs.umich.edu    FaultPriority priority() {return 3200 - _n*100;}
1903576Sgblack@eecs.umich.edu};
1913576Sgblack@eecs.umich.edu
1923576Sgblack@eecs.umich.educlass HstickMatch : public SparcFault<HstickMatch> {};
1933576Sgblack@eecs.umich.edu
1943576Sgblack@eecs.umich.educlass TrapLevelZero : public SparcFault<TrapLevelZero> {};
1953576Sgblack@eecs.umich.edu
1963576Sgblack@eecs.umich.educlass PAWatchpoint : public SparcFault<PAWatchpoint> {};
1973576Sgblack@eecs.umich.edu
1983576Sgblack@eecs.umich.educlass VAWatchpoint : public SparcFault<VAWatchpoint> {};
1993576Sgblack@eecs.umich.edu
2003576Sgblack@eecs.umich.educlass FastInstructionAccessMMUMiss :
2013576Sgblack@eecs.umich.edu    public SparcFault<FastInstructionAccessMMUMiss> {};
2023576Sgblack@eecs.umich.edu
2033576Sgblack@eecs.umich.educlass FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss> {};
2043576Sgblack@eecs.umich.edu
2053576Sgblack@eecs.umich.educlass FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
2063576Sgblack@eecs.umich.edu
2073576Sgblack@eecs.umich.educlass InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
2083576Sgblack@eecs.umich.edu
2093576Sgblack@eecs.umich.educlass CpuMondo : public SparcFault<CpuMondo> {};
2103576Sgblack@eecs.umich.edu
2113576Sgblack@eecs.umich.educlass DevMondo : public SparcFault<DevMondo> {};
2123576Sgblack@eecs.umich.edu
2133893Shsul@eecs.umich.educlass ResumableError : public SparcFault<ResumableError> {};
2143576Sgblack@eecs.umich.edu
2153576Sgblack@eecs.umich.educlass SpillNNormal : public EnumeratedFault<SpillNNormal>
2163576Sgblack@eecs.umich.edu{
2173576Sgblack@eecs.umich.edu  public:
2183576Sgblack@eecs.umich.edu    SpillNNormal(uint32_t n) : EnumeratedFault<SpillNNormal>(n) {;}
2193576Sgblack@eecs.umich.edu    //These need to be handled specially to enable spill traps in SE
2203576Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2213576Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc);
2223576Sgblack@eecs.umich.edu#endif
2233576Sgblack@eecs.umich.edu};
2243576Sgblack@eecs.umich.edu
2253576Sgblack@eecs.umich.educlass SpillNOther : public EnumeratedFault<SpillNOther>
2263576Sgblack@eecs.umich.edu{
2273576Sgblack@eecs.umich.edu  public:
2283576Sgblack@eecs.umich.edu    SpillNOther(uint32_t n) : EnumeratedFault<SpillNOther>(n) {;}
2293576Sgblack@eecs.umich.edu};
2303576Sgblack@eecs.umich.edu
2313576Sgblack@eecs.umich.educlass FillNNormal : public EnumeratedFault<FillNNormal>
2323576Sgblack@eecs.umich.edu{
2333576Sgblack@eecs.umich.edu  public:
2343576Sgblack@eecs.umich.edu    FillNNormal(uint32_t n) : EnumeratedFault<FillNNormal>(n) {;}
2353576Sgblack@eecs.umich.edu    //These need to be handled specially to enable fill traps in SE
2363576Sgblack@eecs.umich.edu#if !FULL_SYSTEM
2373576Sgblack@eecs.umich.edu    void invoke(ThreadContext * tc);
2383576Sgblack@eecs.umich.edu#endif
2393576Sgblack@eecs.umich.edu};
2403576Sgblack@eecs.umich.edu
2413576Sgblack@eecs.umich.educlass FillNOther : public EnumeratedFault<FillNOther>
2423576Sgblack@eecs.umich.edu{
2433576Sgblack@eecs.umich.edu  public:
2443576Sgblack@eecs.umich.edu    FillNOther(uint32_t n) : EnumeratedFault<FillNOther>(n) {;}
2453576Sgblack@eecs.umich.edu};
2463576Sgblack@eecs.umich.edu
2473576Sgblack@eecs.umich.educlass TrapInstruction : public EnumeratedFault<TrapInstruction>
2483576Sgblack@eecs.umich.edu{
2493576Sgblack@eecs.umich.edu
2503576Sgblack@eecs.umich.edu  public:
2513576Sgblack@eecs.umich.edu    TrapInstruction(uint32_t n) : EnumeratedFault<TrapInstruction>(n) {;}
2523576Sgblack@eecs.umich.edu};
2533576Sgblack@eecs.umich.edu
2542800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM
2553573Sgblack@eecs.umich.educlass PageTableFault : public SparcFault<PageTableFault>
2562800Ssaidi@eecs.umich.edu{
2572800Ssaidi@eecs.umich.edu  private:
2582800Ssaidi@eecs.umich.edu    Addr vaddr;
2592800Ssaidi@eecs.umich.edu  public:
2603573Sgblack@eecs.umich.edu    PageTableFault(Addr va) : vaddr(va) {}
2612800Ssaidi@eecs.umich.edu    void invoke(ThreadContext * tc);
2622800Ssaidi@eecs.umich.edu};
2632800Ssaidi@eecs.umich.edu
2642800Ssaidi@eecs.umich.edustatic inline Fault genPageTableFault(Addr va)
2652800Ssaidi@eecs.umich.edu{
2662800Ssaidi@eecs.umich.edu    return new PageTableFault(va);
2672800Ssaidi@eecs.umich.edu}
2682800Ssaidi@eecs.umich.edu#endif
2692800Ssaidi@eecs.umich.edu
2702221SN/Astatic inline Fault genMachineCheckFault()
2712221SN/A{
2722223SN/A    return new InternalProcessorError;
2732221SN/A}
2742221SN/A
2752221SN/Astatic inline Fault genAlignmentFault()
2762221SN/A{
2772223SN/A    return new MemAddressNotAligned;
2782221SN/A}
2792221SN/A
2802800Ssaidi@eecs.umich.edu
2812223SN/A} // SparcISA namespace
2822221SN/A
2833890Ssaidi@eecs.umich.edu#endif // __SPARC_FAULTS_HH__
284