faults.hh revision 7741:340b6f01d69b
112027Sjungma@eit.uni-kl.de/*
212027Sjungma@eit.uni-kl.de * Copyright (c) 2003-2005 The Regents of The University of Michigan
312027Sjungma@eit.uni-kl.de * All rights reserved.
412027Sjungma@eit.uni-kl.de *
512027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without
612027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are
712027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright
812027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer;
912027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright
1012027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the
1112027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution;
1212027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its
1312027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from
1412027Sjungma@eit.uni-kl.de * this software without specific prior written permission.
1512027Sjungma@eit.uni-kl.de *
1612027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712027Sjungma@eit.uni-kl.de *
2812027Sjungma@eit.uni-kl.de * Authors: Gabe Black
2912027Sjungma@eit.uni-kl.de *          Kevin Lim
3012027Sjungma@eit.uni-kl.de */
3112027Sjungma@eit.uni-kl.de
3212027Sjungma@eit.uni-kl.de#ifndef __SPARC_FAULTS_HH__
3312027Sjungma@eit.uni-kl.de#define __SPARC_FAULTS_HH__
3412027Sjungma@eit.uni-kl.de
3512027Sjungma@eit.uni-kl.de#include "config/full_system.hh"
3612027Sjungma@eit.uni-kl.de#include "cpu/static_inst.hh"
3712027Sjungma@eit.uni-kl.de#include "sim/faults.hh"
3812027Sjungma@eit.uni-kl.de
3912027Sjungma@eit.uni-kl.de// The design of the "name" and "vect" functions is in sim/faults.hh
4012027Sjungma@eit.uni-kl.de
4112027Sjungma@eit.uni-kl.denamespace SparcISA
4212027Sjungma@eit.uni-kl.de{
4312027Sjungma@eit.uni-kl.de
4412027Sjungma@eit.uni-kl.detypedef uint32_t TrapType;
4512027Sjungma@eit.uni-kl.detypedef uint32_t FaultPriority;
4612027Sjungma@eit.uni-kl.de
4712027Sjungma@eit.uni-kl.declass ITB;
4812027Sjungma@eit.uni-kl.de
4912027Sjungma@eit.uni-kl.declass SparcFaultBase : public FaultBase
5012027Sjungma@eit.uni-kl.de{
5112027Sjungma@eit.uni-kl.de  public:
5212027Sjungma@eit.uni-kl.de    enum PrivilegeLevel
5312027Sjungma@eit.uni-kl.de    {
5412027Sjungma@eit.uni-kl.de        U, User = U,
5512027Sjungma@eit.uni-kl.de        P, Privileged = P,
5612027Sjungma@eit.uni-kl.de        H, Hyperprivileged = H,
5712027Sjungma@eit.uni-kl.de        NumLevels,
5812027Sjungma@eit.uni-kl.de        SH = -1,
5912027Sjungma@eit.uni-kl.de        ShouldntHappen = SH
6012027Sjungma@eit.uni-kl.de    };
6112027Sjungma@eit.uni-kl.de    struct FaultVals
6212027Sjungma@eit.uni-kl.de    {
6312027Sjungma@eit.uni-kl.de        const FaultName name;
6412027Sjungma@eit.uni-kl.de        const TrapType trapType;
6512027Sjungma@eit.uni-kl.de        const FaultPriority priority;
6612027Sjungma@eit.uni-kl.de        const PrivilegeLevel nextPrivilegeLevel[NumLevels];
6712027Sjungma@eit.uni-kl.de        FaultStat count;
6812027Sjungma@eit.uni-kl.de    };
6912027Sjungma@eit.uni-kl.de#if FULL_SYSTEM
7012027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
7112027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
7212027Sjungma@eit.uni-kl.de#endif
7312027Sjungma@eit.uni-kl.de    virtual TrapType trapType() = 0;
7412027Sjungma@eit.uni-kl.de    virtual FaultPriority priority() = 0;
7512027Sjungma@eit.uni-kl.de    virtual FaultStat & countStat() = 0;
7612027Sjungma@eit.uni-kl.de    virtual PrivilegeLevel getNextLevel(PrivilegeLevel current) = 0;
7712027Sjungma@eit.uni-kl.de};
7812027Sjungma@eit.uni-kl.de
7912027Sjungma@eit.uni-kl.detemplate<typename T>
8012027Sjungma@eit.uni-kl.declass SparcFault : public SparcFaultBase
8112027Sjungma@eit.uni-kl.de{
8212027Sjungma@eit.uni-kl.de  protected:
8312027Sjungma@eit.uni-kl.de    static FaultVals vals;
8412027Sjungma@eit.uni-kl.de  public:
8512027Sjungma@eit.uni-kl.de    FaultName name() const { return vals.name; }
8612027Sjungma@eit.uni-kl.de    TrapType trapType() { return vals.trapType; }
8712027Sjungma@eit.uni-kl.de    FaultPriority priority() { return vals.priority; }
8812027Sjungma@eit.uni-kl.de    FaultStat & countStat() { return vals.count; }
8912027Sjungma@eit.uni-kl.de
9012027Sjungma@eit.uni-kl.de    PrivilegeLevel
9112027Sjungma@eit.uni-kl.de    getNextLevel(PrivilegeLevel current)
9212027Sjungma@eit.uni-kl.de    {
9312027Sjungma@eit.uni-kl.de        return vals.nextPrivilegeLevel[current];
9412027Sjungma@eit.uni-kl.de    }
9512027Sjungma@eit.uni-kl.de};
9612027Sjungma@eit.uni-kl.de
9712027Sjungma@eit.uni-kl.declass PowerOnReset : public SparcFault<PowerOnReset>
9812027Sjungma@eit.uni-kl.de{
9912027Sjungma@eit.uni-kl.de#if FULL_SYSTEM
10012027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
10112027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
10212027Sjungma@eit.uni-kl.de#endif
10312027Sjungma@eit.uni-kl.de};
10412027Sjungma@eit.uni-kl.de
10512027Sjungma@eit.uni-kl.declass WatchDogReset : public SparcFault<WatchDogReset> {};
10612027Sjungma@eit.uni-kl.de
10712027Sjungma@eit.uni-kl.declass ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
10812027Sjungma@eit.uni-kl.de
10912027Sjungma@eit.uni-kl.declass SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
11012027Sjungma@eit.uni-kl.de
11112027Sjungma@eit.uni-kl.declass REDStateException : public SparcFault<REDStateException> {};
11212027Sjungma@eit.uni-kl.de
11312027Sjungma@eit.uni-kl.declass StoreError : public SparcFault<StoreError> {};
11412027Sjungma@eit.uni-kl.de
11512027Sjungma@eit.uni-kl.declass InstructionAccessException : public SparcFault<InstructionAccessException> {};
11612027Sjungma@eit.uni-kl.de
11712027Sjungma@eit.uni-kl.de// class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
11812027Sjungma@eit.uni-kl.de
11912027Sjungma@eit.uni-kl.declass InstructionAccessError : public SparcFault<InstructionAccessError> {};
12012027Sjungma@eit.uni-kl.de
12112027Sjungma@eit.uni-kl.declass IllegalInstruction : public SparcFault<IllegalInstruction> {};
12212027Sjungma@eit.uni-kl.de
12312027Sjungma@eit.uni-kl.declass PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
12412027Sjungma@eit.uni-kl.de
12512027Sjungma@eit.uni-kl.de// class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
12612027Sjungma@eit.uni-kl.de
12712027Sjungma@eit.uni-kl.de// class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
12812027Sjungma@eit.uni-kl.de
12912027Sjungma@eit.uni-kl.declass FpDisabled : public SparcFault<FpDisabled> {};
13012027Sjungma@eit.uni-kl.de
13112027Sjungma@eit.uni-kl.declass FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
13212027Sjungma@eit.uni-kl.de
13312027Sjungma@eit.uni-kl.declass FpExceptionOther : public SparcFault<FpExceptionOther> {};
13412027Sjungma@eit.uni-kl.de
13512027Sjungma@eit.uni-kl.declass TagOverflow : public SparcFault<TagOverflow> {};
13612027Sjungma@eit.uni-kl.de
13712027Sjungma@eit.uni-kl.declass CleanWindow : public SparcFault<CleanWindow> {};
13812027Sjungma@eit.uni-kl.de
13912027Sjungma@eit.uni-kl.declass DivisionByZero : public SparcFault<DivisionByZero> {};
14012027Sjungma@eit.uni-kl.de
14112027Sjungma@eit.uni-kl.declass InternalProcessorError :
14212027Sjungma@eit.uni-kl.de    public SparcFault<InternalProcessorError>
14312027Sjungma@eit.uni-kl.de{
14412027Sjungma@eit.uni-kl.de  public:
14512027Sjungma@eit.uni-kl.de    bool isMachineCheckFault() const { return true; }
14612027Sjungma@eit.uni-kl.de};
14712027Sjungma@eit.uni-kl.de
14812027Sjungma@eit.uni-kl.declass InstructionInvalidTSBEntry :
14912027Sjungma@eit.uni-kl.de    public SparcFault<InstructionInvalidTSBEntry> {};
15012027Sjungma@eit.uni-kl.de
15112027Sjungma@eit.uni-kl.declass DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
15212027Sjungma@eit.uni-kl.de
15312027Sjungma@eit.uni-kl.declass DataAccessException : public SparcFault<DataAccessException> {};
15412027Sjungma@eit.uni-kl.de
15512027Sjungma@eit.uni-kl.de// class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
15612027Sjungma@eit.uni-kl.de
15712027Sjungma@eit.uni-kl.declass DataAccessError : public SparcFault<DataAccessError> {};
15812027Sjungma@eit.uni-kl.de
15912027Sjungma@eit.uni-kl.declass DataAccessProtection : public SparcFault<DataAccessProtection> {};
16012027Sjungma@eit.uni-kl.de
16112027Sjungma@eit.uni-kl.declass MemAddressNotAligned :
16212027Sjungma@eit.uni-kl.de    public SparcFault<MemAddressNotAligned>
16312027Sjungma@eit.uni-kl.de{
16412027Sjungma@eit.uni-kl.de  public:
16512027Sjungma@eit.uni-kl.de    bool isAlignmentFault() const { return true; }
16612027Sjungma@eit.uni-kl.de};
16712027Sjungma@eit.uni-kl.de
16812027Sjungma@eit.uni-kl.declass LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
16912027Sjungma@eit.uni-kl.de
17012027Sjungma@eit.uni-kl.declass STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
17112027Sjungma@eit.uni-kl.de
17212027Sjungma@eit.uni-kl.declass PrivilegedAction : public SparcFault<PrivilegedAction> {};
17312027Sjungma@eit.uni-kl.de
17412027Sjungma@eit.uni-kl.declass LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
17512027Sjungma@eit.uni-kl.de
17612027Sjungma@eit.uni-kl.declass STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
17712027Sjungma@eit.uni-kl.de
17812027Sjungma@eit.uni-kl.declass InstructionRealTranslationMiss :
17912027Sjungma@eit.uni-kl.de    public SparcFault<InstructionRealTranslationMiss> {};
18012027Sjungma@eit.uni-kl.de
18112027Sjungma@eit.uni-kl.declass DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
18212027Sjungma@eit.uni-kl.de
18312027Sjungma@eit.uni-kl.de// class AsyncDataError : public SparcFault<AsyncDataError> {};
18412027Sjungma@eit.uni-kl.de
18512027Sjungma@eit.uni-kl.detemplate <class T>
18612027Sjungma@eit.uni-kl.declass EnumeratedFault : public SparcFault<T>
18712027Sjungma@eit.uni-kl.de{
18812027Sjungma@eit.uni-kl.de  protected:
18912027Sjungma@eit.uni-kl.de    uint32_t _n;
19012027Sjungma@eit.uni-kl.de  public:
19112027Sjungma@eit.uni-kl.de    EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
19212027Sjungma@eit.uni-kl.de    TrapType trapType() { return SparcFault<T>::trapType() + _n; }
19312027Sjungma@eit.uni-kl.de};
19412027Sjungma@eit.uni-kl.de
19512027Sjungma@eit.uni-kl.declass InterruptLevelN : public EnumeratedFault<InterruptLevelN>
19612027Sjungma@eit.uni-kl.de{
19712027Sjungma@eit.uni-kl.de  public:
19812027Sjungma@eit.uni-kl.de    InterruptLevelN(uint32_t n) : EnumeratedFault<InterruptLevelN>(n) {;}
19912027Sjungma@eit.uni-kl.de    FaultPriority priority() { return 3200 - _n*100; }
20012027Sjungma@eit.uni-kl.de};
20112027Sjungma@eit.uni-kl.de
20212027Sjungma@eit.uni-kl.declass HstickMatch : public SparcFault<HstickMatch> {};
20312027Sjungma@eit.uni-kl.de
20412027Sjungma@eit.uni-kl.declass TrapLevelZero : public SparcFault<TrapLevelZero> {};
20512027Sjungma@eit.uni-kl.de
20612027Sjungma@eit.uni-kl.declass InterruptVector : public SparcFault<InterruptVector> {};
20712027Sjungma@eit.uni-kl.de
20812027Sjungma@eit.uni-kl.declass PAWatchpoint : public SparcFault<PAWatchpoint> {};
20912027Sjungma@eit.uni-kl.de
21012027Sjungma@eit.uni-kl.declass VAWatchpoint : public SparcFault<VAWatchpoint> {};
21112027Sjungma@eit.uni-kl.de
21212027Sjungma@eit.uni-kl.declass FastInstructionAccessMMUMiss :
21312027Sjungma@eit.uni-kl.de    public SparcFault<FastInstructionAccessMMUMiss>
21412027Sjungma@eit.uni-kl.de{
21512027Sjungma@eit.uni-kl.de#if !FULL_SYSTEM
21612027Sjungma@eit.uni-kl.de  protected:
21712027Sjungma@eit.uni-kl.de    Addr vaddr;
21812027Sjungma@eit.uni-kl.de  public:
21912027Sjungma@eit.uni-kl.de    FastInstructionAccessMMUMiss(Addr addr) : vaddr(addr)
22012027Sjungma@eit.uni-kl.de    {}
22112027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
22212027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
22312027Sjungma@eit.uni-kl.de#endif
22412027Sjungma@eit.uni-kl.de};
22512027Sjungma@eit.uni-kl.de
22612027Sjungma@eit.uni-kl.declass FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss>
22712027Sjungma@eit.uni-kl.de{
22812027Sjungma@eit.uni-kl.de#if !FULL_SYSTEM
22912027Sjungma@eit.uni-kl.de  protected:
23012027Sjungma@eit.uni-kl.de    Addr vaddr;
23112027Sjungma@eit.uni-kl.de  public:
23212027Sjungma@eit.uni-kl.de    FastDataAccessMMUMiss(Addr addr) : vaddr(addr)
23312027Sjungma@eit.uni-kl.de    {}
23412027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
23512027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
23612027Sjungma@eit.uni-kl.de#endif
23712027Sjungma@eit.uni-kl.de};
23812027Sjungma@eit.uni-kl.de
23912027Sjungma@eit.uni-kl.declass FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
24012027Sjungma@eit.uni-kl.de
24112027Sjungma@eit.uni-kl.declass InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
24212027Sjungma@eit.uni-kl.de
24312027Sjungma@eit.uni-kl.declass CpuMondo : public SparcFault<CpuMondo> {};
24412027Sjungma@eit.uni-kl.de
24512027Sjungma@eit.uni-kl.declass DevMondo : public SparcFault<DevMondo> {};
24612027Sjungma@eit.uni-kl.de
24712027Sjungma@eit.uni-kl.declass ResumableError : public SparcFault<ResumableError> {};
24812027Sjungma@eit.uni-kl.de
24912027Sjungma@eit.uni-kl.declass SpillNNormal : public EnumeratedFault<SpillNNormal>
25012027Sjungma@eit.uni-kl.de{
25112027Sjungma@eit.uni-kl.de  public:
25212027Sjungma@eit.uni-kl.de    SpillNNormal(uint32_t n) : EnumeratedFault<SpillNNormal>(n) {;}
25312027Sjungma@eit.uni-kl.de    // These need to be handled specially to enable spill traps in SE
25412027Sjungma@eit.uni-kl.de#if !FULL_SYSTEM
25512027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
25612027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
25712027Sjungma@eit.uni-kl.de#endif
25812027Sjungma@eit.uni-kl.de};
25912027Sjungma@eit.uni-kl.de
26012027Sjungma@eit.uni-kl.declass SpillNOther : public EnumeratedFault<SpillNOther>
26112027Sjungma@eit.uni-kl.de{
26212027Sjungma@eit.uni-kl.de  public:
26312027Sjungma@eit.uni-kl.de    SpillNOther(uint32_t n) : EnumeratedFault<SpillNOther>(n)
26412027Sjungma@eit.uni-kl.de    {}
26512027Sjungma@eit.uni-kl.de};
26612027Sjungma@eit.uni-kl.de
26712027Sjungma@eit.uni-kl.declass FillNNormal : public EnumeratedFault<FillNNormal>
26812027Sjungma@eit.uni-kl.de{
26912027Sjungma@eit.uni-kl.de  public:
27012027Sjungma@eit.uni-kl.de    FillNNormal(uint32_t n) : EnumeratedFault<FillNNormal>(n)
27112027Sjungma@eit.uni-kl.de    {}
27212027Sjungma@eit.uni-kl.de    // These need to be handled specially to enable fill traps in SE
27312027Sjungma@eit.uni-kl.de#if !FULL_SYSTEM
27412027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
27512027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
27612027Sjungma@eit.uni-kl.de#endif
27712027Sjungma@eit.uni-kl.de};
27812027Sjungma@eit.uni-kl.de
27912027Sjungma@eit.uni-kl.declass FillNOther : public EnumeratedFault<FillNOther>
28012027Sjungma@eit.uni-kl.de{
28112027Sjungma@eit.uni-kl.de  public:
28212027Sjungma@eit.uni-kl.de    FillNOther(uint32_t n) : EnumeratedFault<FillNOther>(n)
28312027Sjungma@eit.uni-kl.de    {}
28412027Sjungma@eit.uni-kl.de};
28512027Sjungma@eit.uni-kl.de
28612027Sjungma@eit.uni-kl.declass TrapInstruction : public EnumeratedFault<TrapInstruction>
28712027Sjungma@eit.uni-kl.de{
28812027Sjungma@eit.uni-kl.de  public:
28912027Sjungma@eit.uni-kl.de    TrapInstruction(uint32_t n) : EnumeratedFault<TrapInstruction>(n)
29012027Sjungma@eit.uni-kl.de    {}
29112027Sjungma@eit.uni-kl.de    // In SE, trap instructions are requesting services from the OS.
29212027Sjungma@eit.uni-kl.de#if !FULL_SYSTEM
29312027Sjungma@eit.uni-kl.de    void invoke(ThreadContext * tc,
29412027Sjungma@eit.uni-kl.de            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
29512027Sjungma@eit.uni-kl.de#endif
29612027Sjungma@eit.uni-kl.de};
29712027Sjungma@eit.uni-kl.de
29812027Sjungma@eit.uni-kl.destatic inline Fault
29912027Sjungma@eit.uni-kl.degenMachineCheckFault()
30012027Sjungma@eit.uni-kl.de{
30112027Sjungma@eit.uni-kl.de    return new InternalProcessorError;
30212027Sjungma@eit.uni-kl.de}
30312027Sjungma@eit.uni-kl.de
30412027Sjungma@eit.uni-kl.de
30512027Sjungma@eit.uni-kl.de} // SparcISA namespace
30612027Sjungma@eit.uni-kl.de
30712027Sjungma@eit.uni-kl.de#endif // __SPARC_FAULTS_HH__
30812027Sjungma@eit.uni-kl.de