2006-02-22 04:02:05 +01:00
|
|
|
/*
|
2007-11-17 03:32:22 +01:00
|
|
|
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
2007-11-14 12:24:47 +01:00
|
|
|
* Copyright (c) 2007 MIPS Technologies, Inc.
|
|
|
|
* All rights reserved.
|
2006-02-22 04:02:05 +01:00
|
|
|
*
|
2007-11-14 12:24:47 +01:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
2006-02-22 04:02:05 +01:00
|
|
|
*
|
2007-11-14 12:24:47 +01:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
2007-11-14 12:24:47 +01:00
|
|
|
* Authors: Gabe Black
|
|
|
|
* Korey Sewell
|
2007-11-13 22:58:16 +01:00
|
|
|
* Jaidev Patwardhan
|
2006-02-22 04:02:05 +01:00
|
|
|
*/
|
|
|
|
|
2006-03-08 08:05:38 +01:00
|
|
|
#ifndef __MIPS_FAULTS_HH__
|
|
|
|
#define __MIPS_FAULTS_HH__
|
2006-02-22 04:02:05 +01:00
|
|
|
|
|
|
|
#include "sim/faults.hh"
|
2006-03-12 11:57:34 +01:00
|
|
|
|
|
|
|
namespace MipsISA
|
|
|
|
{
|
2009-07-21 10:08:53 +02:00
|
|
|
|
2006-03-12 11:57:34 +01:00
|
|
|
typedef const Addr FaultVect;
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class MipsFaultBase : public FaultBase
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
2006-03-12 11:57:34 +01:00
|
|
|
protected:
|
|
|
|
virtual bool skipFaultingInstruction() {return false;}
|
|
|
|
virtual bool setRestartAddress() {return true;}
|
2006-02-22 04:02:05 +01:00
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
struct FaultVals
|
|
|
|
{
|
|
|
|
const FaultName name;
|
|
|
|
const FaultVect vect;
|
|
|
|
};
|
|
|
|
|
2009-07-21 10:09:05 +02:00
|
|
|
Addr badVAddr;
|
|
|
|
Addr entryHiAsid;
|
|
|
|
Addr entryHiVPN2;
|
|
|
|
Addr entryHiVPN2X;
|
|
|
|
Addr contextBadVPN2;
|
2006-03-12 11:57:34 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr)
|
|
|
|
{}
|
2009-07-21 10:08:53 +02:00
|
|
|
void setExceptionState(ThreadContext *, uint8_t);
|
|
|
|
void setHandlerPC(Addr, ThreadContext *);
|
2006-03-12 11:57:34 +01:00
|
|
|
#endif
|
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
template <typename T>
|
|
|
|
class MipsFault : public MipsFaultBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
static FaultVals vals;
|
|
|
|
public:
|
|
|
|
FaultName name() const { return vals.name; }
|
|
|
|
FaultVect vect() const { return vals.vect; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MachineCheckFault : public MipsFault<MachineCheckFault>
|
2006-03-12 11:57:34 +01:00
|
|
|
{
|
|
|
|
public:
|
2007-11-13 22:58:16 +01:00
|
|
|
bool isMachineCheckFault() {return true;}
|
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:20 +02:00
|
|
|
static inline Fault genMachineCheckFault()
|
|
|
|
{
|
|
|
|
return new MachineCheckFault;
|
|
|
|
}
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt>
|
2007-11-13 22:58:16 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool isNonMaskableInterrupt() {return true;}
|
2006-02-22 04:02:05 +01:00
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class AddressErrorFault : public MipsFault<AddressErrorFault>
|
2007-11-13 22:58:16 +01:00
|
|
|
{
|
2011-09-19 15:17:20 +02:00
|
|
|
protected:
|
|
|
|
Addr vaddr;
|
|
|
|
bool store;
|
2007-11-13 22:58:16 +01:00
|
|
|
public:
|
2011-09-19 15:17:20 +02:00
|
|
|
AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store)
|
|
|
|
{}
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
|
|
|
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2009-07-21 10:08:53 +02:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class ResetFault : public MipsFault<ResetFault>
|
2007-11-13 22:58:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
|
|
|
|
};
|
2009-07-21 10:08:53 +02:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class SystemCallFault : public MipsFault<SystemCallFault>
|
2007-11-13 22:58:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-09-19 15:09:15 +02:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2011-09-19 15:09:15 +02:00
|
|
|
#endif
|
2007-11-13 22:58:16 +01:00
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class SoftResetFault : public MipsFault<SoftResetFault>
|
2007-11-13 22:58:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
};
|
2009-07-21 10:08:53 +02:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault>
|
2007-06-23 01:03:42 +02:00
|
|
|
{
|
2011-09-19 15:17:19 +02:00
|
|
|
protected:
|
2007-11-13 22:58:16 +01:00
|
|
|
int coProcID;
|
2007-06-23 01:03:42 +02:00
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
CoprocessorUnusableFault(int _procid) : coProcID(_procid)
|
|
|
|
{}
|
|
|
|
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-06-23 01:03:42 +02:00
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class ReservedInstructionFault : public MipsFault<ReservedInstructionFault>
|
2007-06-23 01:03:42 +02:00
|
|
|
{
|
|
|
|
public:
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-06-23 01:03:42 +02:00
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class ThreadFault : public MipsFault<ThreadFault>
|
2007-06-23 01:03:42 +02:00
|
|
|
{
|
|
|
|
public:
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-06-23 01:03:42 +02:00
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class IntegerOverflowFault : public MipsFault<IntegerOverflowFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
2006-03-12 11:57:34 +01:00
|
|
|
protected:
|
|
|
|
bool skipFaultingInstruction() {return true;}
|
2006-02-22 04:02:05 +01:00
|
|
|
public:
|
2006-03-12 11:57:34 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2006-03-12 11:57:34 +01:00
|
|
|
#endif
|
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class InterruptFault : public MipsFault<InterruptFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
2006-03-12 11:57:34 +01:00
|
|
|
protected:
|
|
|
|
bool setRestartAddress() {return false;}
|
2006-02-22 04:02:05 +01:00
|
|
|
public:
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class TrapFault : public MipsFault<TrapFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class BreakpointFault : public MipsFault<BreakpointFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class ItbRefillFault : public MipsFault<ItbRefillFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
ItbRefillFault(Addr asid, Addr vaddr, Addr vpn)
|
|
|
|
{
|
|
|
|
entryHiAsid = asid;
|
|
|
|
entryHiVPN2 = vpn >> 2;
|
|
|
|
entryHiVPN2X = vpn & 0x3;
|
|
|
|
badVAddr = vaddr;
|
|
|
|
contextBadVPN2 = vpn >> 2;
|
|
|
|
}
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2009-07-21 10:08:53 +02:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class DtbRefillFault : public MipsFault<DtbRefillFault>
|
2006-03-12 11:57:34 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
DtbRefillFault(Addr asid, Addr vaddr, Addr vpn)
|
|
|
|
{
|
|
|
|
entryHiAsid = asid;
|
|
|
|
entryHiVPN2 = vpn >> 2;
|
|
|
|
entryHiVPN2X = vpn & 0x3;
|
|
|
|
badVAddr = vaddr;
|
|
|
|
contextBadVPN2 = vpn >> 2;
|
|
|
|
}
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class ItbInvalidFault : public MipsFault<ItbInvalidFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn)
|
|
|
|
{
|
|
|
|
entryHiAsid = asid;
|
|
|
|
entryHiVPN2 = vpn >> 2;
|
|
|
|
entryHiVPN2X = vpn & 0x3;
|
|
|
|
badVAddr = vaddr;
|
|
|
|
contextBadVPN2 = vpn >> 2;
|
|
|
|
}
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2009-07-21 10:08:53 +02:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class TLBModifiedFault : public MipsFault<TLBModifiedFault>
|
2007-11-13 22:58:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn)
|
|
|
|
{
|
|
|
|
entryHiAsid = asid;
|
|
|
|
entryHiVPN2 = vpn >> 2;
|
|
|
|
entryHiVPN2X = vpn & 0x3;
|
|
|
|
badVAddr = vaddr;
|
|
|
|
contextBadVPN2 = vpn >> 2;
|
|
|
|
}
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class DtbInvalidFault : public MipsFault<DtbInvalidFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-09-19 15:17:19 +02:00
|
|
|
DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn)
|
|
|
|
{
|
|
|
|
entryHiAsid = asid;
|
|
|
|
entryHiVPN2 = vpn >> 2;
|
|
|
|
entryHiVPN2X = vpn & 0x3;
|
|
|
|
badVAddr = vaddr;
|
|
|
|
contextBadVPN2 = vpn >> 2;
|
|
|
|
}
|
2007-11-13 22:58:16 +01:00
|
|
|
#if FULL_SYSTEM
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInst::StaticInstPtr inst = nullStaticInstPtr);
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-09-19 15:17:19 +02:00
|
|
|
class DspStateDisabledFault : public MipsFault<DspStateDisabledFault>
|
2006-02-22 04:02:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2010-09-14 04:26:03 +02:00
|
|
|
void invoke(ThreadContext * tc,
|
|
|
|
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
2006-03-12 11:57:34 +01:00
|
|
|
};
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2011-01-03 23:35:43 +01:00
|
|
|
} // namespace MipsISA
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2007-11-13 22:58:16 +01:00
|
|
|
#endif // __MIPS_FAULTS_HH__
|