faults.hh revision 10417
12810SN/A/*
211375Sandreas.hansson@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
39663Suri.wiener@arm.com * All rights reserved.
49663Suri.wiener@arm.com *
59663Suri.wiener@arm.com * Redistribution and use in source and binary forms, with or without
69663Suri.wiener@arm.com * modification, are permitted provided that the following conditions are
79663Suri.wiener@arm.com * met: redistributions of source code must retain the above copyright
89663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer;
99663Suri.wiener@arm.com * redistributions in binary form must reproduce the above copyright
109663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer in the
119663Suri.wiener@arm.com * documentation and/or other materials provided with the distribution;
129663Suri.wiener@arm.com * neither the name of the copyright holders nor the names of its
139663Suri.wiener@arm.com * contributors may be used to endorse or promote products derived from
142810SN/A * this software without specific prior written permission.
157636Ssteve.reinhardt@amd.com *
162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272810SN/A *
282810SN/A * Authors: Gabe Black
292810SN/A *          Kevin Lim
302810SN/A */
312810SN/A
322810SN/A#ifndef __SPARC_FAULTS_HH__
332810SN/A#define __SPARC_FAULTS_HH__
342810SN/A
352810SN/A#include "cpu/static_inst.hh"
362810SN/A#include "sim/faults.hh"
372810SN/A
382810SN/A// The design of the "name" and "vect" functions is in sim/faults.hh
392810SN/A
402810SN/Anamespace SparcISA
412810SN/A{
422810SN/A
432810SN/Atypedef uint32_t TrapType;
442810SN/Atypedef uint32_t FaultPriority;
452810SN/A
462810SN/Aclass ITB;
472810SN/A
482810SN/Aclass SparcFaultBase : public FaultBase
492810SN/A{
506216Snate@binkert.org  public:
516216Snate@binkert.org    enum PrivilegeLevel
522810SN/A    {
532810SN/A        U, User = U,
542810SN/A        P, Privileged = P,
556216Snate@binkert.org        H, Hyperprivileged = H,
566216Snate@binkert.org        NumLevels,
578232Snate@binkert.org        SH = -1,
586216Snate@binkert.org        ShouldntHappen = SH
595338Sstever@gmail.com    };
606216Snate@binkert.org    struct FaultVals
612810SN/A    {
622810SN/A        const FaultName name;
632810SN/A        const TrapType trapType;
6411375Sandreas.hansson@arm.com        const FaultPriority priority;
6511284Sandreas.hansson@arm.com        const PrivilegeLevel nextPrivilegeLevel[NumLevels];
6610503SCurtis.Dunham@arm.com        FaultStat count;
6711375Sandreas.hansson@arm.com    };
682810SN/A    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
692810SN/A                StaticInst::nullStaticInstPtr);
702810SN/A    virtual TrapType trapType() = 0;
714903SN/A    virtual FaultPriority priority() = 0;
7211284Sandreas.hansson@arm.com    virtual FaultStat & countStat() = 0;
734903SN/A    virtual PrivilegeLevel getNextLevel(PrivilegeLevel current) = 0;
744903SN/A};
754903SN/A
764903SN/Atemplate<typename T>
774908SN/Aclass SparcFault : public SparcFaultBase
785875Ssteve.reinhardt@amd.com{
794903SN/A  protected:
805875Ssteve.reinhardt@amd.com    static FaultVals vals;
8111284Sandreas.hansson@arm.com  public:
8211284Sandreas.hansson@arm.com    FaultName name() const { return vals.name; }
834903SN/A    TrapType trapType() { return vals.trapType; }
844903SN/A    FaultPriority priority() { return vals.priority; }
857669Ssteve.reinhardt@amd.com    FaultStat & countStat() { return vals.count; }
867669Ssteve.reinhardt@amd.com
877669Ssteve.reinhardt@amd.com    PrivilegeLevel
887669Ssteve.reinhardt@amd.com    getNextLevel(PrivilegeLevel current)
894903SN/A    {
904903SN/A        return vals.nextPrivilegeLevel[current];
915318SN/A    }
924908SN/A};
935318SN/A
949543Ssascha.bischoff@arm.comclass PowerOnReset : public SparcFault<PowerOnReset>
959543Ssascha.bischoff@arm.com{
969543Ssascha.bischoff@arm.com    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
979543Ssascha.bischoff@arm.com                StaticInst::nullStaticInstPtr);
9811484Snikos.nikoleris@arm.com};
994908SN/A
1004908SN/Aclass WatchDogReset : public SparcFault<WatchDogReset> {};
10111083Sandreas.hansson@arm.com
10211083Sandreas.hansson@arm.comclass ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
10311083Sandreas.hansson@arm.com
1044908SN/Aclass SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
1054903SN/A
1064903SN/Aclass REDStateException : public SparcFault<REDStateException> {};
10710922Sandreas.hansson@arm.com
1084903SN/Aclass StoreError : public SparcFault<StoreError> {};
1094903SN/A
1104903SN/Aclass InstructionAccessException : public SparcFault<InstructionAccessException> {};
1117667Ssteve.reinhardt@amd.com
1127667Ssteve.reinhardt@amd.com// class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
1137667Ssteve.reinhardt@amd.com
11411286Sandreas.hansson@arm.comclass InstructionAccessError : public SparcFault<InstructionAccessError> {};
11511286Sandreas.hansson@arm.com
11611286Sandreas.hansson@arm.comclass IllegalInstruction : public SparcFault<IllegalInstruction> {};
1177667Ssteve.reinhardt@amd.com
1187667Ssteve.reinhardt@amd.comclass PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
1197667Ssteve.reinhardt@amd.com
1207667Ssteve.reinhardt@amd.com// class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
1217667Ssteve.reinhardt@amd.com
1227667Ssteve.reinhardt@amd.com// class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
1237669Ssteve.reinhardt@amd.com
1247669Ssteve.reinhardt@amd.comclass FpDisabled : public SparcFault<FpDisabled> {};
1257669Ssteve.reinhardt@amd.com
1267667Ssteve.reinhardt@amd.comclass FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
12711286Sandreas.hansson@arm.com
12811286Sandreas.hansson@arm.comclass FpExceptionOther : public SparcFault<FpExceptionOther> {};
12911286Sandreas.hansson@arm.com
13011286Sandreas.hansson@arm.comclass TagOverflow : public SparcFault<TagOverflow> {};
13111286Sandreas.hansson@arm.com
13211286Sandreas.hansson@arm.comclass CleanWindow : public SparcFault<CleanWindow> {};
13311286Sandreas.hansson@arm.com
13411286Sandreas.hansson@arm.comclass DivisionByZero : public SparcFault<DivisionByZero> {};
13511286Sandreas.hansson@arm.com
13611286Sandreas.hansson@arm.comclass InternalProcessorError :
13711286Sandreas.hansson@arm.com    public SparcFault<InternalProcessorError> {};
13811286Sandreas.hansson@arm.com
13911286Sandreas.hansson@arm.comclass InstructionInvalidTSBEntry :
1407667Ssteve.reinhardt@amd.com    public SparcFault<InstructionInvalidTSBEntry> {};
1417667Ssteve.reinhardt@amd.com
1427667Ssteve.reinhardt@amd.comclass DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
1434903SN/A
1444903SN/Aclass DataAccessException : public SparcFault<DataAccessException> {};
1454903SN/A
1464903SN/A// class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
1474903SN/A
1484903SN/Aclass DataAccessError : public SparcFault<DataAccessError> {};
14910766Sandreas.hansson@arm.com
15010766Sandreas.hansson@arm.comclass DataAccessProtection : public SparcFault<DataAccessProtection> {};
1514903SN/A
1524903SN/Aclass MemAddressNotAligned :
1534903SN/A    public SparcFault<MemAddressNotAligned> {};
1544903SN/A
1554903SN/Aclass LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
1564903SN/A
1572810SN/Aclass STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
1584908SN/A
1594908SN/Aclass PrivilegedAction : public SparcFault<PrivilegedAction> {};
16010766Sandreas.hansson@arm.com
16110766Sandreas.hansson@arm.comclass LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
1629543Ssascha.bischoff@arm.com
1639543Ssascha.bischoff@arm.comclass STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
1649543Ssascha.bischoff@arm.com
1659543Ssascha.bischoff@arm.comclass InstructionRealTranslationMiss :
1669543Ssascha.bischoff@arm.com    public SparcFault<InstructionRealTranslationMiss> {};
1679543Ssascha.bischoff@arm.com
16810766Sandreas.hansson@arm.comclass DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
16911484Snikos.nikoleris@arm.com
1705318SN/A// class AsyncDataError : public SparcFault<AsyncDataError> {};
1715318SN/A
1724908SN/Atemplate <class T>
1734908SN/Aclass EnumeratedFault : public SparcFault<T>
1744908SN/A{
1754908SN/A  protected:
1764908SN/A    uint32_t _n;
1774920SN/A  public:
1784920SN/A    EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
1794920SN/A    TrapType trapType() { return SparcFault<T>::trapType() + _n; }
18010766Sandreas.hansson@arm.com};
18110766Sandreas.hansson@arm.com
1824920SN/Aclass InterruptLevelN : public EnumeratedFault<InterruptLevelN>
1834920SN/A{
1844920SN/A  public:
1854920SN/A    InterruptLevelN(uint32_t n) : EnumeratedFault<InterruptLevelN>(n) {;}
1864920SN/A    FaultPriority priority() { return 3200 - _n*100; }
1874920SN/A};
1884920SN/A
1894920SN/Aclass HstickMatch : public SparcFault<HstickMatch> {};
1904908SN/A
19110766Sandreas.hansson@arm.comclass TrapLevelZero : public SparcFault<TrapLevelZero> {};
19210766Sandreas.hansson@arm.com
1935314SN/Aclass InterruptVector : public SparcFault<InterruptVector> {};
19410766Sandreas.hansson@arm.com
1955875Ssteve.reinhardt@amd.comclass PAWatchpoint : public SparcFault<PAWatchpoint> {};
19610766Sandreas.hansson@arm.com
1978988SAli.Saidi@ARM.comclass VAWatchpoint : public SparcFault<VAWatchpoint> {};
1988988SAli.Saidi@ARM.com
1998988SAli.Saidi@ARM.comclass FastInstructionAccessMMUMiss :
2008988SAli.Saidi@ARM.com    public SparcFault<FastInstructionAccessMMUMiss>
2018988SAli.Saidi@ARM.com{
2028988SAli.Saidi@ARM.com  protected:
2038988SAli.Saidi@ARM.com    Addr vaddr;
2048988SAli.Saidi@ARM.com  public:
2058988SAli.Saidi@ARM.com    FastInstructionAccessMMUMiss(Addr addr) : vaddr(addr)
2068988SAli.Saidi@ARM.com    {}
2078988SAli.Saidi@ARM.com    FastInstructionAccessMMUMiss() : vaddr(0)
2088988SAli.Saidi@ARM.com    {}
2095875Ssteve.reinhardt@amd.com    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
2105875Ssteve.reinhardt@amd.com                StaticInst::nullStaticInstPtr);
21110766Sandreas.hansson@arm.com};
2125314SN/A
2135314SN/Aclass FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss>
2145314SN/A{
2155314SN/A  protected:
2165314SN/A    Addr vaddr;
21710764Sandreas.hansson@arm.com  public:
21811197Sandreas.hansson@arm.com    FastDataAccessMMUMiss(Addr addr) : vaddr(addr)
2192810SN/A    {}
22010764Sandreas.hansson@arm.com    FastDataAccessMMUMiss() : vaddr(0)
22110764Sandreas.hansson@arm.com    {}
22210028SGiacomo.Gabrielli@arm.com    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
22310764Sandreas.hansson@arm.com                StaticInst::nullStaticInstPtr);
2244666SN/A};
2254626SN/A
2265730SSteve.Reinhardt@amd.comclass FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
22711197Sandreas.hansson@arm.com
2284626SN/Aclass InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
2294626SN/A
2304908SN/Aclass CpuMondo : public SparcFault<CpuMondo> {};
2319725Sandreas.hansson@arm.com
2324626SN/Aclass DevMondo : public SparcFault<DevMondo> {};
2335875Ssteve.reinhardt@amd.com
2345875Ssteve.reinhardt@amd.comclass ResumableError : public SparcFault<ResumableError> {};
2355875Ssteve.reinhardt@amd.com
23610764Sandreas.hansson@arm.comclass SpillNNormal : public EnumeratedFault<SpillNNormal>
2379725Sandreas.hansson@arm.com{
2382810SN/A  public:
2392810SN/A    SpillNNormal(uint32_t n) : EnumeratedFault<SpillNNormal>(n) {;}
2404908SN/A    // These need to be handled specially to enable spill traps in SE
2415318SN/A    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
2425318SN/A                StaticInst::nullStaticInstPtr);
2435318SN/A};
2445318SN/A
2455318SN/Aclass SpillNOther : public EnumeratedFault<SpillNOther>
2465318SN/A{
2475318SN/A  public:
2489725Sandreas.hansson@arm.com    SpillNOther(uint32_t n) : EnumeratedFault<SpillNOther>(n)
2495318SN/A    {}
2505318SN/A};
25111375Sandreas.hansson@arm.com
25211284Sandreas.hansson@arm.comclass FillNNormal : public EnumeratedFault<FillNNormal>
2534908SN/A{
2544908SN/A  public:
25510424Sandreas.hansson@arm.com    FillNNormal(uint32_t n) : EnumeratedFault<FillNNormal>(n)
2564908SN/A    {}
25711284Sandreas.hansson@arm.com    // These need to be handled specially to enable fill traps in SE
2587667Ssteve.reinhardt@amd.com    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
2597667Ssteve.reinhardt@amd.com                StaticInst::nullStaticInstPtr);
2604908SN/A};
2614908SN/A
2624908SN/Aclass FillNOther : public EnumeratedFault<FillNOther>
2639725Sandreas.hansson@arm.com{
2644908SN/A  public:
2654908SN/A    FillNOther(uint32_t n) : EnumeratedFault<FillNOther>(n)
2664908SN/A    {}
2674908SN/A};
2682810SN/A
2692810SN/Aclass TrapInstruction : public EnumeratedFault<TrapInstruction>
2702810SN/A{
2719725Sandreas.hansson@arm.com  public:
2729725Sandreas.hansson@arm.com    TrapInstruction(uint32_t n) : EnumeratedFault<TrapInstruction>(n)
2739725Sandreas.hansson@arm.com    {}
2742810SN/A    // In SE, trap instructions are requesting services from the OS.
2752810SN/A    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
2762810SN/A                StaticInst::nullStaticInstPtr);
2772810SN/A};
2782810SN/A
2792810SN/Avoid enterREDState(ThreadContext *tc);
2802810SN/A
28111197Sandreas.hansson@arm.comvoid doREDFault(ThreadContext *tc, TrapType tt);
28211197Sandreas.hansson@arm.com
2832810SN/Avoid doNormalFault(ThreadContext *tc, TrapType tt, bool gotoHpriv);
28410768Sandreas.hansson@arm.com
28510768Sandreas.hansson@arm.comvoid getREDVector(MiscReg TT, Addr &PC, Addr &NPC);
28610768Sandreas.hansson@arm.com
28710768Sandreas.hansson@arm.comvoid getHyperVector(ThreadContext * tc, Addr &PC, Addr &NPC, MiscReg TT);
28810768Sandreas.hansson@arm.com
28910768Sandreas.hansson@arm.comvoid getPrivVector(ThreadContext *tc, Addr &PC, Addr &NPC, MiscReg TT,
29010768Sandreas.hansson@arm.com                   MiscReg TL);
29110768Sandreas.hansson@arm.com
29210768Sandreas.hansson@arm.com} // namespace SparcISA
29311197Sandreas.hansson@arm.com
29411197Sandreas.hansson@arm.com#endif // __SPARC_FAULTS_HH__
29511197Sandreas.hansson@arm.com