diff options
Diffstat (limited to 'sim/faults.hh')
-rw-r--r-- | sim/faults.hh | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/sim/faults.hh b/sim/faults.hh index dbec399af..9e8d224cd 100644 --- a/sim/faults.hh +++ b/sim/faults.hh @@ -29,34 +29,40 @@ #ifndef __FAULTS_HH__ #define __FAULTS_HH__ +#include "base/refcnt.hh" +#include "sim/stats.hh" +#include "config/full_system.hh" + +class ExecContext; class FaultBase; -typedef FaultBase * Fault; +typedef RefCountingPtr<FaultBase> Fault; -class FaultBase -{ -public: - FaultBase(char * newName, int newId = 0) : name(newName), id(newId) {;} - const char * name; - int id; -}; +typedef const char * FaultName; +typedef Stats::Scalar<> FaultStat; -extern class NoFaultType : public FaultBase -{ -public: - NoFaultType(char * newName) : FaultBase(newName) {;} -} * const NoFault; +// Each class has it's name statically define in _name, +// and has a virtual function to access it's name. +// The function is necessary because otherwise, all objects +// which are being accessed cast as a FaultBase * (namely +// all faults returned using the Fault type) will use the +// generic FaultBase name. -extern class MachineCheckFaultType : public FaultBase +class FaultBase : public RefCounted { -public: - MachineCheckFaultType(char * newName) : FaultBase(newName) {;} -} * const MachineCheckFault; - -extern class AlignmentFaultType : public FaultBase -{ -public: - AlignmentFaultType(char * newName) : FaultBase(newName) {;} -} * const AlignmentFault; + public: + virtual FaultName name() = 0; + virtual FaultStat & stat() = 0; +#if FULL_SYSTEM + virtual void invoke(ExecContext * xc) = 0; +#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;} +}; +FaultBase * const NoFault = 0; #endif // __FAULTS_HH__ |