Fixes to get MIPS_SE to compile.
[gem5.git] / src / cpu / o3 / thread_state.hh
index 7322161e649eaedee590367bbd2e1b3c6096cf2f..d8720b3ab90a9f69d694daa374c862dfc7b85757 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: Kevin Lim
  */
 
 #ifndef __CPU_O3_THREAD_STATE_HH__
 #define __CPU_O3_THREAD_STATE_HH__
 
-#include "arch/faults.hh"
-#include "arch/isa_traits.hh"
+#include "base/callback.hh"
+#include "base/output.hh"
 #include "cpu/thread_context.hh"
 #include "cpu/thread_state.hh"
+#include "sim/sim_exit.hh"
 
 class Event;
 class Process;
@@ -56,19 +59,11 @@ class Process;
 template <class Impl>
 struct O3ThreadState : public ThreadState {
     typedef ThreadContext::Status Status;
-    typedef typename Impl::FullCPU FullCPU;
-
-    /** Current status of the thread. */
-    Status _status;
-
-    /** Current instruction the thread is committing.  Only set and
-     * used for DTB faults currently.
-     */
-    TheISA::MachInst inst;
+    typedef typename Impl::O3CPU O3CPU;
 
   private:
     /** Pointer to the CPU. */
-    FullCPU *cpu;
+    O3CPU *cpu;
   public:
     /** Whether or not the thread is currently in syscall mode, and
      * thus able to be externally updated without squashing.
@@ -81,14 +76,27 @@ struct O3ThreadState : public ThreadState {
     bool trapPending;
 
 #if FULL_SYSTEM
-    O3ThreadState(FullCPU *_cpu, int _thread_num, FunctionalMemory *_mem)
-        : ThreadState(-1, _thread_num, _mem),
-          inSyscall(0), trapPending(0)
-    { }
+    O3ThreadState(O3CPU *_cpu, int _thread_num)
+        : ThreadState(_cpu, -1, _thread_num),
+          cpu(_cpu), inSyscall(0), trapPending(0)
+    {
+        if (cpu->params->profile) {
+            profile = new FunctionProfile(cpu->params->system->kernelSymtab);
+            Callback *cb =
+                new MakeCallback<O3ThreadState,
+                &O3ThreadState::dumpFuncProfile>(this);
+            registerExitCallback(cb);
+        }
+
+        // let's fill with a dummy node for now so we don't get a segfault
+        // on the first cycle when there's no node available.
+        static ProfileNode dummyNode;
+        profileNode = &dummyNode;
+        profilePC = 3;
+    }
 #else
-    O3ThreadState(FullCPU *_cpu, int _thread_num, Process *_process, int _asid,
-                  MemObject *mem)
-        : ThreadState(-1, _thread_num, mem, _process, _asid),
+    O3ThreadState(O3CPU *_cpu, int _thread_num, Process *_process, int _asid)
+        : ThreadState(_cpu, -1, _thread_num, _process, _asid),
           cpu(_cpu), inSyscall(0), trapPending(0)
     { }
 #endif
@@ -99,29 +107,18 @@ struct O3ThreadState : public ThreadState {
     /** Returns a pointer to the TC of this thread. */
     ThreadContext *getTC() { return tc; }
 
-    /** Returns the status of this thread. */
-    Status status() const { return _status; }
-
-    /** Sets the status of this thread. */
-    void setStatus(Status new_status) { _status = new_status; }
-
-    /** Sets the current instruction being committed. */
-    void setInst(TheISA::MachInst _inst) { inst = _inst; }
-
-    /** Reads the number of instructions functionally executed and
-     * committed.
-     */
-    Counter readFuncExeInst() { return funcExeInst; }
-
-    /** Sets the total number of instructions functionally executed
-     * and committed.
-     */
-    void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
-
 #if !FULL_SYSTEM
     /** Handles the syscall. */
     void syscall(int64_t callnum) { process->syscall(callnum, tc); }
 #endif
+
+#if FULL_SYSTEM
+    void dumpFuncProfile()
+    {
+        std::ostream *os = simout.create(csprintf("profile.%s.dat", cpu->name()));
+        profile->dump(tc, *os);
+    }
+#endif
 };
 
 #endif // __CPU_O3_THREAD_STATE_HH__