* 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.
+ *
+ * Authors: Nathan Binkert
+ * Gabe Black
*/
#ifndef __FAULTS_HH__
#define __FAULTS_HH__
-#include "base/refcnt.hh"
+#include "base/types.hh"
+#include "cpu/static_inst.hh"
#include "sim/stats.hh"
-#include "config/full_system.hh"
-class ExecContext;
-class FaultBase;
-typedef RefCountingPtr<FaultBase> Fault;
+class ThreadContext;
typedef const char * FaultName;
-typedef Stats::Scalar<> FaultStat;
+typedef Stats::Scalar FaultStat;
// Each class has it's name statically define in _name,
// and has a virtual function to access it's name.
// all faults returned using the Fault type) will use the
// generic FaultBase name.
-class FaultBase : public RefCounted
+class FaultBase
{
public:
- virtual FaultName name() = 0;
-#if FULL_SYSTEM
- virtual void invoke(ExecContext * xc);
-#else
- virtual void invoke(ExecContext * xc);
-#endif
-// template<typename T>
-// bool isA() {return dynamic_cast<T *>(this);}
- virtual bool isMachineCheckFault() {return false;}
- virtual bool isAlignmentFault() {return false;}
+ virtual FaultName name() const = 0;
+ virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+ StaticInst::nullStaticInstPtr);
};
-FaultBase * const NoFault = 0;
-
class UnimpFault : public FaultBase
{
private:
: panicStr(_str)
{ }
- FaultName name() {return "Unimplemented simulator feature";}
- void invoke(ExecContext * xc);
+ FaultName name() const {return "Unimplemented simulator feature";}
+ void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+ StaticInst::nullStaticInstPtr);
+};
+
+class ReExec : public FaultBase
+{
+ public:
+ virtual FaultName name() const { return "Re-execution fault";}
+ ReExec() {}
+ void invoke(ThreadContext *tc, const StaticInstPtr &inst =
+ StaticInst::nullStaticInstPtr);
+};
+
+class GenericPageTableFault : public FaultBase
+{
+ private:
+ Addr vaddr;
+ public:
+ FaultName name() const {return "Generic page table fault";}
+ GenericPageTableFault(Addr va) : vaddr(va) {}
+ void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+ StaticInst::nullStaticInstPtr);
+};
+
+class GenericAlignmentFault : public FaultBase
+{
+ private:
+ Addr vaddr;
+ public:
+ FaultName name() const {return "Generic alignment fault";}
+ GenericAlignmentFault(Addr va) : vaddr(va) {}
+ void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+ StaticInst::nullStaticInstPtr);
};
#endif // __FAULTS_HH__