sim-se: Add default to SyscallDesc constructor
[gem5.git] / src / sim / faults.cc
index cb095f852226c9a8ca5b58076a2a08cc78c1147f..b0fa6fedb11f4f90ea26dc51637666f303b759e3 100644 (file)
  * 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
  */
 
-#include "base/misc.hh"
 #include "sim/faults.hh"
-#include "cpu/exec_context.hh"
+
+#include "arch/isa_traits.hh"
+#include "base/misc.hh"
 #include "cpu/base.hh"
+#include "cpu/thread_context.hh"
+#include "debug/Fault.hh"
+#include "mem/page_table.hh"
+#include "sim/full_system.hh"
+#include "sim/process.hh"
+
+void FaultBase::invoke(ThreadContext * tc, const StaticInstPtr &inst)
+{
+    if (FullSystem) {
+        DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState());
+    } else {
+        panic("fault (%s) detected @ PC %s", name(), tc->pcState());
+    }
+}
+
+void UnimpFault::invoke(ThreadContext * tc, const StaticInstPtr &inst)
+{
+    panic("Unimpfault: %s\n", panicStr.c_str());
+}
+
+void ReExec::invoke(ThreadContext *tc, const StaticInstPtr &inst)
+{
+    tc->pcState(tc->pcState());
+}
 
-#if !FULL_SYSTEM
-void FaultBase::invoke(ExecContext * xc)
+void SyscallRetryFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
 {
-    fatal("fault (%s) detected @ PC 0x%08p", name(), xc->readPC());
+    tc->pcState(tc->pcState());
 }
-#else
-void FaultBase::invoke(ExecContext * xc)
+
+void GenericPageTableFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
 {
-    DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->readPC());
-    xc->getCpuPtr()->recordEvent(csprintf("Fault %s", name()));
+    bool handled = false;
+    if (!FullSystem) {
+        Process *p = tc->getProcessPtr();
+        handled = p->fixupStackFault(vaddr);
+    }
+    if (!handled)
+        panic("Page table fault when accessing virtual address %#x\n", vaddr);
 
-    assert(!xc->misspeculating());
 }
-#endif
 
-void UnimpFault::invoke(ExecContext * xc)
+void GenericAlignmentFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
 {
-    panic("Unimpfault: %s\n", panicStr.c_str());
+    panic("Alignment fault when accessing virtual address %#x\n", vaddr);
 }