ruby: abstract controller: mark some variables as const
[gem5.git] / src / mem / tport.cc
index c071ef18c9ca3c94cd12a7aabbcebddaa15a4306..aa783ada020f36d122ce253343568fcdfd8099c9 100644 (file)
 
 SimpleTimingPort::SimpleTimingPort(const std::string& _name,
                                    MemObject* _owner) :
-    QueuedSlavePort(_name, _owner, queue), queue(*_owner, *this)
+    QueuedSlavePort(_name, _owner, queueImpl), queueImpl(*_owner, *this)
 {
 }
 
 void
 SimpleTimingPort::recvFunctional(PacketPtr pkt)
 {
-    if (!queue.checkFunctional(pkt)) {
+    if (!respQueue.checkFunctional(pkt)) {
         // do an atomic access and throw away the returned latency
         recvAtomic(pkt);
     }
@@ -62,12 +62,16 @@ SimpleTimingPort::recvFunctional(PacketPtr pkt)
 bool
 SimpleTimingPort::recvTimingReq(PacketPtr pkt)
 {
-    if (pkt->memInhibitAsserted()) {
-        // snooper will supply based on copy of packet
-        // still target's responsibility to delete packet
-        delete pkt;
-        return true;
-    }
+    /// @todo temporary hack to deal with memory corruption issue until
+    /// 4-phase transactions are complete. Remove me later
+    for (int x = 0; x < pendingDelete.size(); x++)
+        delete pendingDelete[x];
+    pendingDelete.clear();
+
+    // the SimpleTimingPort should not be used anywhere where there is
+    // a need to deal with inhibited packets
+    if (pkt->memInhibitAsserted())
+        panic("SimpleTimingPort should never see an inhibited request\n");
 
     bool needsResponse = pkt->needsResponse();
     Tick latency = recvAtomic(pkt);
@@ -76,9 +80,12 @@ SimpleTimingPort::recvTimingReq(PacketPtr pkt)
         // recvAtomic() should already have turned packet into
         // atomic response
         assert(pkt->isResponse());
-        queue.schedSendTiming(pkt, curTick() + latency);
+        schedTimingResp(pkt, curTick() + latency);
     } else {
-        delete pkt;
+        /// @todo nominally we should just delete the packet here.
+        /// Until 4-phase stuff we can't because the sending
+        /// cache is still relying on it
+        pendingDelete.push_back(pkt);
     }
 
     return true;