summaryrefslogtreecommitdiff
path: root/src/cpu/thread_state.hh
diff options
context:
space:
mode:
authorKevin Lim <ktlim@umich.edu>2006-06-07 15:29:53 -0400
committerKevin Lim <ktlim@umich.edu>2006-06-07 15:29:53 -0400
commit54d4220b004a385d04def37fa55c820366da0d4a (patch)
tree9a3b4d776c3d10954f2d2ec024694684e5e2435a /src/cpu/thread_state.hh
parent6915513b972524de5b73edbf7cddeaeb84504703 (diff)
downloadgem5-54d4220b004a385d04def37fa55c820366da0d4a.tar.xz
Reorganization/renaming of CPUExecContext. Now it is called SimpleThread in order to clear up the confusion due to the many ExecContexts. It also derives from a common ThreadState object, which holds various state common to threads across CPU models.
Following with the previous check-in, ExecContext now refers only to the interface provided to the ISA in order to access CPU state. ThreadContext refers to the interface provided to all objects outside the CPU in order to access thread state. SimpleThread provides all thread state and the interface to access it, and is suitable for simple execution models such as the SimpleCPU. src/SConscript: Include thread state file. src/arch/alpha/ev5.cc: src/cpu/checker/cpu.cc: src/cpu/checker/cpu.hh: src/cpu/checker/thread_context.hh: src/cpu/memtest/memtest.cc: src/cpu/memtest/memtest.hh: src/cpu/o3/cpu.cc: src/cpu/ozone/cpu_impl.hh: src/cpu/simple/atomic.cc: src/cpu/simple/base.cc: src/cpu/simple/base.hh: src/cpu/simple/timing.cc: Rename CPUExecContext to SimpleThread. src/cpu/base_dyn_inst.hh: Make thread member variables protected.. src/cpu/o3/alpha_cpu.hh: src/cpu/o3/cpu.hh: Make various members of ThreadState protected. src/cpu/o3/alpha_cpu_impl.hh: Push generation of TranslatingPort into the CPU itself. Make various members of ThreadState protected. src/cpu/o3/thread_state.hh: Pull a lot of common code into the base ThreadState class. src/cpu/ozone/thread_state.hh: Rename CPUExecContext to SimpleThread, move a lot of common code into base ThreadState class. src/cpu/thread_state.hh: Push a lot of common code into base ThreadState class. This goes along with renaming CPUExecContext to SimpleThread, and making it derive from ThreadState. src/cpu/simple_thread.cc: Rename CPUExecContext to SimpleThread, make it derive from ThreadState. This helps push a lot of common code/state into a single class that can be used by all CPUs. src/cpu/simple_thread.hh: Rename CPUExecContext to SimpleThread, make it derive from ThreadState. src/kern/system_events.cc: Rename cpu_exec_context to thread_context. src/sim/process.hh: Remove unused forward declaration. --HG-- rename : src/cpu/cpu_exec_context.cc => src/cpu/simple_thread.cc rename : src/cpu/cpu_exec_context.hh => src/cpu/simple_thread.hh extra : convert_revision : 2ed617aa80b64016cb9270f75352607cca032733
Diffstat (limited to 'src/cpu/thread_state.hh')
-rw-r--r--src/cpu/thread_state.hh128
1 files changed, 99 insertions, 29 deletions
diff --git a/src/cpu/thread_state.hh b/src/cpu/thread_state.hh
index 6d64c94f7..d72697cb7 100644
--- a/src/cpu/thread_state.hh
+++ b/src/cpu/thread_state.hh
@@ -29,10 +29,13 @@
#ifndef __CPU_THREAD_STATE_HH__
#define __CPU_THREAD_STATE_HH__
+#include "arch/isa_traits.hh"
#include "cpu/thread_context.hh"
#if !FULL_SYSTEM
+#include "mem/mem_object.hh"
#include "mem/translating_port.hh"
+#include "sim/process.hh"
#endif
#if FULL_SYSTEM
@@ -42,9 +45,6 @@ class ProfileNode;
namespace Kernel {
class Statistics;
};
-#else
-class FunctionalMemory;
-class Process;
#endif
/**
@@ -54,56 +54,121 @@ class Process;
* to hold more thread-specific stats within it.
*/
struct ThreadState {
+ typedef ThreadContext::Status Status;
+
#if FULL_SYSTEM
- ThreadState(int _cpuId, int _tid)
- : cpuId(_cpuId), tid(_tid), lastActivate(0), lastSuspend(0),
- profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL)
+ ThreadState(int _cpuId, int _tid);
#else
ThreadState(int _cpuId, int _tid, MemObject *mem,
- Process *_process, short _asid)
- : cpuId(_cpuId), tid(_tid), process(_process), asid(_asid)
+ Process *_process, short _asid);
#endif
- {
- funcExeInst = 0;
- storeCondFailures = 0;
-#if !FULL_SYSTEM
- /* Use this port to for syscall emulation writes to memory. */
- Port *mem_port;
- port = new TranslatingPort(csprintf("%d-funcport",
- tid),
- process->pTable, false);
- mem_port = mem->getPort("functional");
- mem_port->setPeer(port);
- port->setPeer(mem_port);
+
+ void setCpuId(int id) { cpuId = id; }
+
+ int readCpuId() { return cpuId; }
+
+ void setTid(int id) { tid = id; }
+
+ int readTid() { return tid; }
+
+ Tick readLastActivate() { return lastActivate; }
+
+ Tick readLastSuspend() { return lastSuspend; }
+
+#if FULL_SYSTEM
+ void dumpFuncProfile();
+
+ EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
+
+ void profileClear();
+
+ void profileSample();
+
+ Kernel::Statistics *getKernelStats() { return kernelStats; }
+
+ void setPhysPort(FunctionalPort *port) { physPort = port; }
+
+ void setVirtPort(VirtualPort *port) { virtPort = port; }
+#else
+ Process *getProcessPtr() { return process; }
+
+ TranslatingPort *getMemPort() { return port; }
+
+ void setMemPort(TranslatingPort *_port) { port = _port; }
+
+ int getInstAsid() { return asid; }
+ int getDataAsid() { return asid; }
#endif
- }
- ThreadContext::Status status;
+ /** Sets the current instruction being committed. */
+ void setInst(TheISA::MachInst _inst) { inst = _inst; }
- int cpuId;
+ /** Returns the current instruction being committed. */
+ TheISA::MachInst getInst() { return inst; }
- // Index of hardware thread context on the CPU that this represents.
- int tid;
+ /** 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; }
+
+ /** 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; }
+
+ /** Number of instructions committed. */
Counter numInst;
+ /** Stat for number instructions committed. */
Stats::Scalar<> numInsts;
+ /** Stat for number of memory references. */
Stats::Scalar<> numMemRefs;
- // number of simulated loads
+ /** Number of simulated loads, used for tracking events based on
+ * the number of loads committed.
+ */
Counter numLoad;
+
+ /** The number of simulated loads committed prior to this run. */
Counter startNumLoad;
-#if FULL_SYSTEM
+ protected:
+ ThreadContext::Status _status;
+
+ // ID of this context w.r.t. the System or Process object to which
+ // it belongs. For full-system mode, this is the system CPU ID.
+ int cpuId;
+
+ // Index of hardware thread context on the CPU that this represents.
+ int tid;
+
+ /** Last time activate was called on this thread. */
Tick lastActivate;
+
+ /** Last time suspend was called on this thread. */
Tick lastSuspend;
+#if FULL_SYSTEM
+ public:
FunctionProfile *profile;
ProfileNode *profileNode;
Addr profilePC;
-
EndQuiesceEvent *quiesceEvent;
Kernel::Statistics *kernelStats;
+ protected:
+ /** A functional port outgoing only for functional accesses to physical
+ * addresses.*/
+ FunctionalPort *physPort;
+
+ /** A functional port, outgoing only, for functional accesse to virtual
+ * addresses. That doen't require execution context information */
+ VirtualPort *virtPort;
#else
TranslatingPort *port;
@@ -113,9 +178,13 @@ struct ThreadState {
// simulation only; all functional memory accesses should use
// one of the FunctionalMemory pointers above.
short asid;
-
#endif
+ /** Current instruction the thread is committing. Only set and
+ * used for DTB faults currently.
+ */
+ TheISA::MachInst inst;
+
/**
* Temporary storage to pass the source address from copy_load to
* copy_store.
@@ -128,6 +197,7 @@ struct ThreadState {
*/
Addr copySrcPhysAddr;
+ public:
/*
* number of executed instructions, for matching with syscall trace
* points in EIO files.