Update Virtual and Physical ports.
authorKevin Lim <ktlim@umich.edu>
Sun, 19 Nov 2006 22:43:03 +0000 (17:43 -0500)
committerKevin Lim <ktlim@umich.edu>
Sun, 19 Nov 2006 22:43:03 +0000 (17:43 -0500)
src/cpu/o3/alpha/cpu_impl.hh:
    Handle the PhysicalPort and VirtualPort in the ThreadState.
src/cpu/o3/cpu.cc:
    Initialize the thread context.
src/cpu/o3/thread_context.hh:
    Add new function to initialize thread context.
src/cpu/o3/thread_context_impl.hh:
    Use code now put into function.
src/cpu/simple_thread.cc:
    Move code to ThreadState and use the new helper function.
src/cpu/simple_thread.hh:
    Remove init() in this derived class; use init() from ThreadState base class.
src/cpu/thread_state.cc:
    Move setting up of Physical and Virtual ports here.  Change getMemFuncPort() to connectToMemFunc(), which connects a port to a functional port of the memory object below the CPU.
src/cpu/thread_state.hh:
    Update functions.

--HG--
extra : convert_revision : ff254715ef0b259dc80d08f13543b63e4024ca8d

src/cpu/o3/alpha/cpu_impl.hh
src/cpu/o3/cpu.cc
src/cpu/o3/thread_context.hh
src/cpu/o3/thread_context_impl.hh
src/cpu/simple_thread.cc
src/cpu/simple_thread.hh
src/cpu/thread_state.cc
src/cpu/thread_state.hh

index b2ef78360a2c0c7b28a46bd65cdcfeafe71357d0..98fd0699ac84684a31b1b507e55d614c9b800842 100644 (file)
@@ -116,24 +116,6 @@ AlphaO3CPU<Impl>::AlphaO3CPU(Params *params)
 #if FULL_SYSTEM
         // Setup quiesce event.
         this->thread[i]->quiesceEvent = new EndQuiesceEvent(tc);
-
-        Port *mem_port;
-        FunctionalPort *phys_port;
-        VirtualPort *virt_port;
-        phys_port = new FunctionalPort(csprintf("%s-%d-funcport",
-                                                name(), i));
-        mem_port = this->system->physmem->getPort("functional");
-        mem_port->setPeer(phys_port);
-        phys_port->setPeer(mem_port);
-
-        virt_port = new VirtualPort(csprintf("%s-%d-vport",
-                                             name(), i));
-        mem_port = this->system->physmem->getPort("functional");
-        mem_port->setPeer(virt_port);
-        virt_port->setPeer(mem_port);
-
-        this->thread[i]->setPhysPort(phys_port);
-        this->thread[i]->setVirtPort(virt_port);
 #endif
         // Give the thread the TC.
         this->thread[i]->tc = tc;
index 5808163723d9a0eea51f5866bf3088f5d592126e..3dc353a9fb9c1d7f193e6a27b17085003394dff5 100644 (file)
@@ -497,6 +497,8 @@ FullO3CPU<Impl>::init()
         }
 
 #if FULL_SYSTEM
+        src_tc->init();
+
         TheISA::initCPU(src_tc, src_tc->readCpuId());
 #endif
     }
index daee2fc7d453130aa2cf54cd09e8385c8c70ffe5..031f36480a231b887c7ee35455a12acebb1e8fd5 100755 (executable)
@@ -91,6 +91,8 @@ class O3ThreadContext : public ThreadContext
     virtual VirtualPort *getVirtPort(ThreadContext *src_tc = NULL);
 
     void delVirtPort(VirtualPort *vp);
+
+    virtual void init() { thread->init(); }
 #else
     virtual TranslatingPort *getMemPort() { return thread->getMemPort(); }
 
index 8d623f5b8fb2335d4876b2cefe8f9f8fea55e1a5..0180756e38d3c152729f25c7f9a7b9a013e034c4 100755 (executable)
@@ -41,12 +41,9 @@ O3ThreadContext<Impl>::getVirtPort(ThreadContext *src_tc)
         return thread->getVirtPort();
 
     VirtualPort *vp;
-    Port *mem_port;
 
     vp = new VirtualPort("tc-vport", src_tc);
-    mem_port = cpu->system->physmem->getPort("functional");
-    mem_port->setPeer(vp);
-    vp->setPeer(mem_port);
+    thread->connectToMemFunc(vp);
     return vp;
 }
 
index e07d6e7c1e42cb8b1ae1e20644a267d855b25995..13d0e2e291ace750531303b190244444257eb617 100644 (file)
@@ -104,25 +104,6 @@ SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num,
 
 #endif
 
-#if FULL_SYSTEM
-void
-SimpleThread::init()
-{
-    Port *mem_port;
-    physPort = new FunctionalPort(csprintf("%s-%d-funcport",
-                                           cpu->name(), tid));
-    mem_port = getMemFuncPort();
-    mem_port->setPeer(physPort);
-    physPort->setPeer(mem_port);
-
-    virtPort = new VirtualPort(csprintf("%s-%d-vport",
-                                        cpu->name(), tid));
-    mem_port = getMemFuncPort();
-    mem_port->setPeer(virtPort);
-    virtPort->setPeer(mem_port);
-}
-#endif
-
 SimpleThread::SimpleThread()
 #if FULL_SYSTEM
     : ThreadState(NULL, -1, -1)
@@ -316,10 +297,7 @@ SimpleThread::getVirtPort(ThreadContext *src_tc)
         return virtPort;
 
     VirtualPort *vp = new VirtualPort("tc-vport", src_tc);
-    Port *mem_port = getMemFuncPort();
-
-    mem_port->setPeer(vp);
-    vp->setPeer(mem_port);
+    connectToMemFunc(vp);
     return vp;
 }
 
index b9ce4e0ce7adad88de0d3c9605a61da7e22de5ee..e8757c8c20b67e56de3f5f7953c83b7459f884cf 100644 (file)
@@ -118,8 +118,6 @@ class SimpleThread : public ThreadState
     SimpleThread(BaseCPU *_cpu, int _thread_num, System *_system,
                  TheISA::ITB *_itb, TheISA::DTB *_dtb,
                  bool use_kernel_stats = true);
-
-    void init();
 #else
     SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, int _asid);
 #endif
index 8602f8a50b02fad111fc45350835001a0811f9a9..9cac4fd26b18d7766ebb3ddc2ed5de36fa41cd23 100644 (file)
@@ -39,6 +39,7 @@
 #if FULL_SYSTEM
 #include "arch/kernel_stats.hh"
 #include "cpu/quiesce_event.hh"
+#include "mem/vport.hh"
 #endif
 
 #if FULL_SYSTEM
@@ -111,6 +112,28 @@ ThreadState::unserialize(Checkpoint *cp, const std::string &section)
 }
 
 #if FULL_SYSTEM
+void
+ThreadState::init()
+{
+    initPhysPort();
+    initVirtPort();
+}
+
+void
+ThreadState::initPhysPort()
+{
+    physPort = new FunctionalPort(csprintf("%s-%d-funcport",
+                                           baseCpu->name(), tid));
+    connectToMemFunc(physPort);
+}
+
+void
+ThreadState::initVirtPort()
+{
+    virtPort = new VirtualPort(csprintf("%s-%d-vport",
+                                        baseCpu->name(), tid));
+    connectToMemFunc(virtPort);
+}
 
 void
 ThreadState::profileClear()
@@ -138,17 +161,14 @@ ThreadState::getMemPort()
                                         baseCpu->name(), tid),
                                process->pTable, false);
 
-    Port *func_port = getMemFuncPort();
-
-    func_port->setPeer(port);
-    port->setPeer(func_port);
+    connectToMemFunc(port);
 
     return port;
 }
 #endif
 
-Port *
-ThreadState::getMemFuncPort()
+void
+ThreadState::connectToMemFunc(Port *port)
 {
     Port *dcache_port, *func_mem_port;
 
@@ -161,5 +181,6 @@ ThreadState::getMemFuncPort()
     func_mem_port = mem_object->getPort("functional");
     assert(func_mem_port != NULL);
 
-    return func_mem_port;
+    func_mem_port->setPeer(port);
+    port->setPeer(func_mem_port);
 }
index 183ddcd2bcdaba25ec2166c335a662734f017b76..1844be8b7245aa1a555a6ca36226436c058c6460 100644 (file)
@@ -91,6 +91,12 @@ struct ThreadState {
     Tick readLastSuspend() { return lastSuspend; }
 
 #if FULL_SYSTEM
+    void init();
+
+    void initPhysPort();
+
+    void initVirtPort();
+
     void dumpFuncProfile();
 
     EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
@@ -142,9 +148,9 @@ struct ThreadState {
     void setStatus(Status new_status) { _status = new_status; }
 
   public:
-    /** Gets a functional port from the memory object that's connected
-     * to the CPU. */
-    Port *getMemFuncPort();
+    /** Connects port to the functional port of the memory object
+     * below the CPU. */
+    void connectToMemFunc(Port *port);
 
     /** Number of instructions committed. */
     Counter numInst;