summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2010-09-13 19:26:03 -0700
committerGabe Black <gblack@eecs.umich.edu>2010-09-13 19:26:03 -0700
commit6833ca7eedd351596bb1518620af7465f5172fcd (patch)
tree4a67b3d591132dab3e8273fc9dfba606a1720e4a /src/sim
parent2edfcbbaee87c1a28351fc0dcd81d52d0d9102a4 (diff)
downloadgem5-6833ca7eedd351596bb1518620af7465f5172fcd.tar.xz
Faults: Pass the StaticInst involved, if any, to a Fault's invoke method.
Also move the "Fault" reference counted pointer type into a separate file, sim/fault.hh. It would be better to name this less similarly to sim/faults.hh to reduce confusion, but fault.hh matches the name of the type. We could change Fault to FaultPtr to match other pointer types, and then changing the name of the file would make more sense.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/fault.hh38
-rw-r--r--src/sim/faults.cc10
-rw-r--r--src/sim/faults.hh17
-rw-r--r--src/sim/process_impl.hh1
-rw-r--r--src/sim/syscall_emul.hh1
-rw-r--r--src/sim/tlb.cc1
-rw-r--r--src/sim/tlb.hh2
7 files changed, 58 insertions, 12 deletions
diff --git a/src/sim/fault.hh b/src/sim/fault.hh
new file mode 100644
index 000000000..ac0b691d0
--- /dev/null
+++ b/src/sim/fault.hh
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Advanced Micro Devices
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Authors: Gabe Black
+ */
+
+#ifndef __SIM_FAULT_HH__
+#define __SIM_FAULT_HH__
+
+class FaultBase;
+template <class T> class RefCountingPtr;
+typedef RefCountingPtr<FaultBase> Fault;
+
+#endif // __SIM_FAULT_HH__
diff --git a/src/sim/faults.cc b/src/sim/faults.cc
index 10f0b9a66..78b9fb0a4 100644
--- a/src/sim/faults.cc
+++ b/src/sim/faults.cc
@@ -38,12 +38,12 @@
#include "mem/page_table.hh"
#if !FULL_SYSTEM
-void FaultBase::invoke(ThreadContext * tc)
+void FaultBase::invoke(ThreadContext * tc, StaticInstPtr inst)
{
panic("fault (%s) detected @ PC %p", name(), tc->readPC());
}
#else
-void FaultBase::invoke(ThreadContext * tc)
+void FaultBase::invoke(ThreadContext * tc, StaticInstPtr inst)
{
DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), tc->readPC());
@@ -51,13 +51,13 @@ void FaultBase::invoke(ThreadContext * tc)
}
#endif
-void UnimpFault::invoke(ThreadContext * tc)
+void UnimpFault::invoke(ThreadContext * tc, StaticInstPtr inst)
{
panic("Unimpfault: %s\n", panicStr.c_str());
}
#if !FULL_SYSTEM
-void GenericPageTableFault::invoke(ThreadContext *tc)
+void GenericPageTableFault::invoke(ThreadContext *tc, StaticInstPtr inst)
{
Process *p = tc->getProcessPtr();
@@ -66,7 +66,7 @@ void GenericPageTableFault::invoke(ThreadContext *tc)
}
-void GenericAlignmentFault::invoke(ThreadContext *tc)
+void GenericAlignmentFault::invoke(ThreadContext *tc, StaticInstPtr inst)
{
panic("Alignment fault when accessing virtual address %#x\n", vaddr);
}
diff --git a/src/sim/faults.hh b/src/sim/faults.hh
index f2fa30b60..e48928b2c 100644
--- a/src/sim/faults.hh
+++ b/src/sim/faults.hh
@@ -33,12 +33,13 @@
#define __FAULTS_HH__
#include "base/refcnt.hh"
+#include "base/types.hh"
+#include "sim/fault.hh"
#include "sim/stats.hh"
#include "config/full_system.hh"
+#include "cpu/static_inst.hh"
class ThreadContext;
-class FaultBase;
-typedef RefCountingPtr<FaultBase> Fault;
typedef const char * FaultName;
typedef Stats::Scalar FaultStat;
@@ -54,7 +55,8 @@ class FaultBase : public RefCounted
{
public:
virtual FaultName name() const = 0;
- virtual void invoke(ThreadContext * tc);
+ virtual void invoke(ThreadContext * tc,
+ StaticInstPtr inst = StaticInst::nullStaticInstPtr);
virtual bool isMachineCheckFault() const {return false;}
virtual bool isAlignmentFault() const {return false;}
};
@@ -71,7 +73,8 @@ class UnimpFault : public FaultBase
{ }
FaultName name() const {return "Unimplemented simulator feature";}
- void invoke(ThreadContext * tc);
+ void invoke(ThreadContext * tc,
+ StaticInstPtr inst = StaticInst::nullStaticInstPtr);
};
#if !FULL_SYSTEM
@@ -82,7 +85,8 @@ class GenericPageTableFault : public FaultBase
public:
FaultName name() const {return "Generic page table fault";}
GenericPageTableFault(Addr va) : vaddr(va) {}
- void invoke(ThreadContext * tc);
+ void invoke(ThreadContext * tc,
+ StaticInstPtr inst = StaticInst::nullStaticInstPtr);
};
class GenericAlignmentFault : public FaultBase
@@ -92,7 +96,8 @@ class GenericAlignmentFault : public FaultBase
public:
FaultName name() const {return "Generic alignment fault";}
GenericAlignmentFault(Addr va) : vaddr(va) {}
- void invoke(ThreadContext * tc);
+ void invoke(ThreadContext * tc,
+ StaticInstPtr inst = StaticInst::nullStaticInstPtr);
};
#endif
diff --git a/src/sim/process_impl.hh b/src/sim/process_impl.hh
index 9d12113d0..1db533428 100644
--- a/src/sim/process_impl.hh
+++ b/src/sim/process_impl.hh
@@ -45,6 +45,7 @@
#include <vector>
#include "mem/translating_port.hh"
+#include "sim/byteswap.hh"
//This needs to be templated for cases where 32 bit pointers are needed.
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 703bbd1e0..eaec57ef5 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -62,6 +62,7 @@
#include "cpu/thread_context.hh"
#include "mem/translating_port.hh"
#include "mem/page_table.hh"
+#include "sim/byteswap.hh"
#include "sim/system.hh"
#include "sim/process.hh"
diff --git a/src/sim/tlb.cc b/src/sim/tlb.cc
index e9a719ffa..e2f4f9135 100644
--- a/src/sim/tlb.cc
+++ b/src/sim/tlb.cc
@@ -31,6 +31,7 @@
#include "cpu/thread_context.hh"
#include "mem/page_table.hh"
#include "sim/process.hh"
+#include "sim/faults.hh"
#include "sim/tlb.hh"
Fault
diff --git a/src/sim/tlb.hh b/src/sim/tlb.hh
index db62b691d..ddd3127e5 100644
--- a/src/sim/tlb.hh
+++ b/src/sim/tlb.hh
@@ -33,7 +33,7 @@
#include "base/misc.hh"
#include "mem/request.hh"
-#include "sim/faults.hh"
+#include "sim/fault.hh"
#include "sim/sim_object.hh"
class ThreadContext;