cpu: Fix rename mis-handling serializing instructions when resource constrained
[gem5.git] / src / cpu / thread_state.hh
index 99f0c2a873a05367a5469b119fc0613da1340ec4..d8dccc4aee9f3b2eb734be3cecd149cb9ab5da8c 100644 (file)
 #define __CPU_THREAD_STATE_HH__
 
 #include "arch/types.hh"
+#include "config/the_isa.hh"
+#include "cpu/base.hh"
 #include "cpu/profile.hh"
 #include "cpu/thread_context.hh"
-#include "cpu/base.hh"
-
-#if !FULL_SYSTEM
 #include "mem/mem_object.hh"
 #include "sim/process.hh"
-#endif
 
-#if FULL_SYSTEM
 class EndQuiesceEvent;
 class FunctionProfile;
 class ProfileNode;
 namespace TheISA {
     namespace Kernel {
         class Statistics;
-    };
-};
-#endif
+    }
+}
 
 class Checkpoint;
-class Port;
-class TranslatingPort;
 
 /**
  *  Struct for holding general thread state that is needed across CPU
@@ -65,14 +59,9 @@ class TranslatingPort;
 struct ThreadState {
     typedef ThreadContext::Status Status;
 
-#if FULL_SYSTEM
-    ThreadState(BaseCPU *cpu, int _tid);
-#else
-    ThreadState(BaseCPU *cpu, int _tid, Process *_process,
-                short _asid);
-#endif
+    ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
 
-    ~ThreadState();
+    virtual ~ThreadState();
 
     void serialize(std::ostream &os);
 
@@ -84,20 +73,21 @@ struct ThreadState {
 
     void setContextId(int id) { _contextId = id; }
 
-    void setThreadId(int id) { _threadId = id; }
+    void setThreadId(ThreadID id) { _threadId = id; }
 
-    int threadId() { return _threadId; }
+    ThreadID threadId() { return _threadId; }
 
     Tick readLastActivate() { return lastActivate; }
 
     Tick readLastSuspend() { return lastSuspend; }
 
-#if FULL_SYSTEM
-    void connectMemPorts(ThreadContext *tc);
-
-    void connectPhysPort();
-
-    void connectVirtPort(ThreadContext *tc);
+    /**
+     * Initialise the physical and virtual port proxies and tie them to
+     * the data port of the CPU.
+     *
+     * @param tc ThreadContext for the virtual-to-physical translation
+     */
+    void initMemProxies(ThreadContext *tc);
 
     void dumpFuncProfile();
 
@@ -109,27 +99,13 @@ struct ThreadState {
 
     TheISA::Kernel::Statistics *getKernelStats() { return kernelStats; }
 
-    FunctionalPort *getPhysPort() { return physPort; }
+    PortProxy &getPhysProxy();
 
-    void setPhysPort(FunctionalPort *port) { physPort = port; }
+    FSTranslatingPortProxy &getVirtProxy();
 
-    VirtualPort *getVirtPort() { return virtPort; }
-#else
     Process *getProcessPtr() { return process; }
 
-    TranslatingPort *getMemPort();
-
-    void setMemPort(TranslatingPort *_port) { port = _port; }
-
-    int getInstAsid() { return asid; }
-    int getDataAsid() { return asid; }
-#endif
-
-    /** Sets the current instruction being committed. */
-    void setInst(TheISA::MachInst _inst) { inst = _inst; }
-
-    /** Returns the current instruction being committed. */
-    TheISA::MachInst getInst() { return inst; }
+    SETranslatingPortProxy &getMemProxy();
 
     /** Reads the number of instructions functionally executed and
      * committed.
@@ -148,14 +124,15 @@ struct ThreadState {
     void setStatus(Status new_status) { _status = new_status; }
 
   public:
-    /** Connects port to the functional port of the memory object
-     * below the CPU. */
-    void connectToMemFunc(Port *port);
 
     /** Number of instructions committed. */
     Counter numInst;
     /** Stat for number instructions committed. */
     Stats::Scalar numInsts;
+    /** Number of ops (including micro ops) committed. */
+    Counter numOp;
+    /** Stat for number ops (including micro ops) committed. */
+    Stats::Scalar numOps;
     /** Stat for number of memory references. */
     Stats::Scalar numMemRefs;
 
@@ -177,7 +154,7 @@ struct ThreadState {
     int _contextId;
 
     // Index of hardware thread context on the CPU that this represents.
-    int _threadId;
+    ThreadID _threadId;
 
   public:
     /** Last time activate was called on this thread. */
@@ -186,7 +163,6 @@ struct ThreadState {
     /** Last time suspend was called on this thread. */
     Tick lastSuspend;
 
-#if FULL_SYSTEM
   public:
     FunctionProfile *profile;
     ProfileNode *profileNode;
@@ -194,54 +170,20 @@ struct ThreadState {
     EndQuiesceEvent *quiesceEvent;
 
     TheISA::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. */
-    VirtualPort *virtPort;
-#else
-    TranslatingPort *port;
 
+  protected:
     Process *process;
 
-    // Address space ID.  Note that this is used for TIMING cache
-    // 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;
-
-    /** The current microcode pc for the currently executing macro
-     * operation.
-     */
-    MicroPC microPC;
+    /** A port proxy outgoing only for functional accesses to physical
+     * addresses.*/
+    PortProxy *physProxy;
 
-    /** The next microcode pc for the currently executing macro
-     * operation.
-     */
-    MicroPC nextMicroPC;
+    /** A translating port proxy, outgoing only, for functional
+     * accesse to virtual addresses. */
+    FSTranslatingPortProxy *virtProxy;
+    SETranslatingPortProxy *proxy;
 
   public:
-    /**
-     * Temporary storage to pass the source address from copy_load to
-     * copy_store.
-     * @todo Remove this temporary when we have a better way to do it.
-     */
-    Addr copySrcAddr;
-    /**
-     * Temp storage for the physical source address of a copy.
-     * @todo Remove this temporary when we have a better way to do it.
-     */
-    Addr copySrcPhysAddr;
-
     /*
      * number of executed instructions, for matching with syscall trace
      * points in EIO files.