A few minor non-debug compilation issues.
[gem5.git] / src / mem / bridge.cc
index f525ccb48daab54c3b61deadd1a63e19f8596418..d6adb05d13eb71fd2c31393b184b3d5f2f110bf1 100644 (file)
@@ -112,10 +112,6 @@ Bridge::BridgePort::reqQueueFull()
 bool
 Bridge::BridgePort::recvTiming(PacketPtr pkt)
 {
-    if (!(pkt->flags & SNOOP_COMMIT))
-        return true;
-
-
     DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n",
                 pkt->getSrc(), pkt->getDest(), pkt->getAddr());
 
@@ -125,14 +121,13 @@ Bridge::BridgePort::recvTiming(PacketPtr pkt)
                     otherPort->sendQueue.size(), otherPort->queuedRequests,
                     otherPort->outstandingResponses);
 
-    if (pkt->isRequest() && otherPort->reqQueueFull() && pkt->result !=
-            Packet::Nacked) {
+    if (pkt->isRequest() && otherPort->reqQueueFull() && !pkt->wasNacked()) {
         DPRINTF(BusBridge, "Remote queue full, nacking\n");
         nackRequest(pkt);
         return true;
     }
 
-    if (pkt->needsResponse() && pkt->result != Packet::Nacked)
+    if (pkt->needsResponse() && !pkt->wasNacked())
         if (respQueueFull()) {
             DPRINTF(BusBridge, "Local queue full, no space for response, nacking\n");
             DPRINTF(BusBridge, "queue size: %d outreq: %d outstanding resp: %d\n",
@@ -153,7 +148,7 @@ void
 Bridge::BridgePort::nackRequest(PacketPtr pkt)
 {
     // Nack the packet
-    pkt->result = Packet::Nacked;
+    pkt->setNacked();
     pkt->setDest(pkt->getSrc());
 
     //put it on the list to send
@@ -198,7 +193,7 @@ Bridge::BridgePort::nackRequest(PacketPtr pkt)
 void
 Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
 {
-    if (pkt->isResponse() || pkt->result == Packet::Nacked) {
+    if (pkt->isResponse() || pkt->wasNacked()) {
         // This is a response for a request we forwarded earlier.  The
         // corresponding PacketBuffer should be stored in the packet's
         // senderState field.
@@ -210,18 +205,15 @@ Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
 
         // Check if this packet was expecting a response and it's a nacked
         // packet, in which case we will never being seeing it
-        if (buf->expectResponse && pkt->result == Packet::Nacked)
+        if (buf->expectResponse && pkt->wasNacked())
             --outstandingResponses;
 
-
-        DPRINTF(BusBridge, "restoring  sender state: %#X, from packet buffer: %#X\n",
-                        pkt->senderState, buf);
-        DPRINTF(BusBridge, "  is response, new dest %d\n", pkt->getDest());
+        DPRINTF(BusBridge, "response, new dest %d\n", pkt->getDest());
         delete buf;
     }
 
 
-    if (pkt->isRequest() && pkt->result != Packet::Nacked) {
+    if (pkt->isRequest() && !pkt->wasNacked()) {
         ++queuedRequests;
     }
 
@@ -229,8 +221,6 @@ Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
 
     Tick readyTime = curTick + delay;
     PacketBuffer *buf = new PacketBuffer(pkt, readyTime);
-    DPRINTF(BusBridge, "old sender state: %#X, new sender state: %#X\n",
-            buf->origSenderState, buf);
 
     // If we're about to put this packet at the head of the queue, we
     // need to schedule an event to do the transmit.  Otherwise there
@@ -247,28 +237,28 @@ Bridge::BridgePort::trySend()
 {
     assert(!sendQueue.empty());
 
-    int pbs = peerBlockSize();
-
     PacketBuffer *buf = sendQueue.front();
 
     assert(buf->ready <= curTick);
 
     PacketPtr pkt = buf->pkt;
 
-    pkt->flags &= ~SNOOP_COMMIT; //CLear it if it was set
-
+    // Ugly! @todo When multilevel coherence works this will be removed
     if (pkt->cmd == MemCmd::WriteInvalidateReq && fixPartialWrite &&
-            pkt->result != Packet::Nacked && pkt->getOffset(pbs) &&
-            pkt->getSize() != pbs) {
-        buf->partialWriteFix(this);
-        pkt = buf->pkt;
+            !pkt->wasNacked()) {
+        PacketPtr funcPkt = new Packet(pkt->req, MemCmd::WriteReq,
+                            Packet::Broadcast);
+        funcPkt->dataStatic(pkt->getPtr<uint8_t>());
+        sendFunctional(funcPkt);
+        pkt->cmd = MemCmd::WriteReq;
+        delete funcPkt;
     }
 
     DPRINTF(BusBridge, "trySend: origSrc %d dest %d addr 0x%x\n",
             buf->origSrc, pkt->getDest(), pkt->getAddr());
 
     bool wasReq = pkt->isRequest();
-    bool wasNacked = pkt->result == Packet::Nacked;
+    bool wasNacked = pkt->wasNacked();
 
     if (sendTiming(pkt)) {
         // send successful
@@ -300,7 +290,6 @@ Bridge::BridgePort::trySend()
         }
     } else {
         DPRINTF(BusBridge, "  unsuccessful\n");
-        buf->undoPartialWriteFix();
         inRetry = true;
     }
     DPRINTF(BusBridge, "trySend: queue size: %d outreq: %d outstanding resp: %d\n",
@@ -324,32 +313,18 @@ Bridge::BridgePort::recvRetry()
 Tick
 Bridge::BridgePort::recvAtomic(PacketPtr pkt)
 {
-    int pbs = otherPort->peerBlockSize();
-    Tick atomic_delay;
     // fix partial atomic writes... similar to the timing code that does the
-    // same
-    if (pkt->cmd == MemCmd::WriteInvalidateReq && fixPartialWrite &&
-             pkt->getOffset(pbs) && pkt->getSize() != pbs) {
-        PacketDataPtr data;
-        data = new uint8_t[pbs];
-        PacketPtr funcPkt = new Packet(pkt->req, MemCmd::ReadReq,
-                         Packet::Broadcast, pbs);
+    // same... will be removed once our code gets this right
+    if (pkt->cmd == MemCmd::WriteInvalidateReq && fixPartialWrite) {
 
-        funcPkt->dataStatic(data);
+        PacketPtr funcPkt = new Packet(pkt->req, MemCmd::WriteReq,
+                         Packet::Broadcast);
+        funcPkt->dataStatic(pkt->getPtr<uint8_t>());
         otherPort->sendFunctional(funcPkt);
-        assert(funcPkt->result == Packet::Success);
         delete funcPkt;
-        memcpy(data + pkt->getOffset(pbs), pkt->getPtr<uint8_t>(),
-                         pkt->getSize());
-        PacketPtr newPkt = new Packet(pkt->req, MemCmd::WriteInvalidateReq,
-                Packet::Broadcast, pbs);
-        pkt->dataDynamicArray(data);
-        atomic_delay = otherPort->sendAtomic(newPkt);
-        delete newPkt;
-    } else {
-        atomic_delay = otherPort->sendAtomic(pkt);
+        pkt->cmd = MemCmd::WriteReq;
     }
-    return atomic_delay + delay;
+    return delay + otherPort->sendAtomic(pkt);
 }
 
 /** Function called by the port when the bus is receiving a Functional
@@ -358,17 +333,14 @@ void
 Bridge::BridgePort::recvFunctional(PacketPtr pkt)
 {
     std::list<PacketBuffer*>::iterator i;
-    bool pktContinue = true;
 
     for (i = sendQueue.begin();  i != sendQueue.end(); ++i) {
-        if (pkt->intersect((*i)->pkt)) {
-            pktContinue &= fixPacket(pkt, (*i)->pkt);
-        }
+        if (pkt->checkFunctional((*i)->pkt))
+            return;
     }
 
-    if (pktContinue) {
-        otherPort->sendFunctional(pkt);
-    }
+    // fall through if pkt still not satisfied
+    otherPort->sendFunctional(pkt);
 }
 
 /** Function called by the port when the bus is receiving a status change.*/
@@ -380,9 +352,11 @@ Bridge::BridgePort::recvStatusChange(Port::Status status)
 
 void
 Bridge::BridgePort::getDeviceAddressRanges(AddrRangeList &resp,
-                                           AddrRangeList &snoop)
+                                           bool &snoop)
 {
     otherPort->getPeerAddressRanges(resp, snoop);
+    // we don't allow snooping across bridges
+    snoop = false;
 }
 
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(Bridge)
@@ -431,3 +405,4 @@ CREATE_SIM_OBJECT(Bridge)
 
 REGISTER_SIM_OBJECT("Bridge", Bridge)
 
+