sim: Small style fixes in sim/syscall_return.hh.
[gem5.git] / src / sim / faults.hh
index 4cdb24aee42efb10e7146519344594d2fd0c61c5..47855e7c28a8967dccb44cacbb0d5437c221532d 100644 (file)
 #ifndef __FAULTS_HH__
 #define __FAULTS_HH__
 
-#include "base/refcnt.hh"
 #include "base/types.hh"
 #include "cpu/static_inst.hh"
-#include "sim/fault_fwd.hh"
 #include "sim/stats.hh"
 
 class ThreadContext;
@@ -43,19 +41,14 @@ class ThreadContext;
 typedef const char * FaultName;
 typedef Stats::Scalar FaultStat;
 
-// 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.
-
-class FaultBase : public RefCounted
+class FaultBase
 {
   public:
     virtual FaultName name() const = 0;
-    virtual void invoke(ThreadContext * tc,
-            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
+    virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+                        StaticInst::nullStaticInstPtr);
+
+    virtual ~FaultBase() {};
 };
 
 class UnimpFault : public FaultBase
@@ -67,18 +60,34 @@ class UnimpFault : public FaultBase
         : panicStr(_str)
     { }
 
-    FaultName name() const {return "Unimplemented simulator feature";}
-    void invoke(ThreadContext * tc,
-            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
+    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";}
+    virtual FaultName name() const { return "Re-execution fault"; }
     ReExec() {}
-    void invoke(ThreadContext *tc,
-            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
+    void invoke(ThreadContext *tc, const StaticInstPtr &inst =
+                StaticInst::nullStaticInstPtr);
+};
+
+/*
+ * This class is needed to allow system call retries to occur for blocking
+ * system calls in SE mode. A retry fault will be generated by the system call
+ * emulation code if blocking conditions arise; the fault is passed up the
+ * function call chain into the CPU model where it is handled by retrying the
+ * syscall instruction on a later tick.
+ */
+class SyscallRetryFault : public FaultBase
+{
+  public:
+    virtual FaultName name() const { return "System call retry fault"; }
+    SyscallRetryFault() {}
+    void invoke(ThreadContext *tc, const StaticInstPtr &inst =
+                StaticInst::nullStaticInstPtr);
 };
 
 class GenericPageTableFault : public FaultBase
@@ -86,10 +95,11 @@ class GenericPageTableFault : public FaultBase
   private:
     Addr vaddr;
   public:
-    FaultName name() const {return "Generic page table fault";}
+    FaultName name() const { return "Generic page table fault"; }
     GenericPageTableFault(Addr va) : vaddr(va) {}
-    void invoke(ThreadContext * tc,
-            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
+    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+                StaticInst::nullStaticInstPtr);
+    Addr getFaultVAddr() const { return vaddr; }
 };
 
 class GenericAlignmentFault : public FaultBase
@@ -97,10 +107,11 @@ class GenericAlignmentFault : public FaultBase
   private:
     Addr vaddr;
   public:
-    FaultName name() const {return "Generic alignment fault";}
+    FaultName name() const { return "Generic alignment fault"; }
     GenericAlignmentFault(Addr va) : vaddr(va) {}
-    void invoke(ThreadContext * tc,
-            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
+    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+                StaticInst::nullStaticInstPtr);
+    Addr getFaultVAddr() const { return vaddr; }
 };
 
 #endif // __FAULTS_HH__