2 * Copyright (c) 2006 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "mem/tport.hh"
34 SimpleTimingPort::checkFunctional(PacketPtr pkt
)
36 DeferredPacketIterator i
= transmitList
.begin();
37 DeferredPacketIterator end
= transmitList
.end();
39 for (; i
!= end
; ++i
) {
40 PacketPtr target
= i
->pkt
;
41 // If the target contains data, and it overlaps the
42 // probed request, need to update data
43 if (target
->intersect(pkt
)) {
44 if (!fixPacket(pkt
, target
)) {
45 // fixPacket returns true for continue, false for done
53 SimpleTimingPort::recvFunctional(PacketPtr pkt
)
57 // Just do an atomic access and throw away the returned latency
58 if (pkt
->result
!= Packet::Success
)
63 SimpleTimingPort::recvTiming(PacketPtr pkt
)
65 // If the device is only a slave, it should only be sending
66 // responses, which should never get nacked. There used to be
67 // code to hanldle nacks here, but I'm pretty sure it didn't work
68 // correctly with the drain code, so that would need to be fixed
69 // if we ever added it back.
70 assert(pkt
->isRequest());
71 assert(pkt
->result
== Packet::Unknown
);
72 bool needsResponse
= pkt
->needsResponse();
73 Tick latency
= recvAtomic(pkt
);
74 // turn packet around to go back to requester if response expected
76 // recvAtomic() should already have turned packet into atomic response
77 assert(pkt
->isResponse());
78 pkt
->convertAtomicToTimingResponse();
79 schedSendTiming(pkt
, curTick
+ latency
);
89 SimpleTimingPort::schedSendTiming(PacketPtr pkt
, Tick when
)
91 assert(when
> curTick
);
93 // Nothing is on the list: add it and schedule an event
94 if (transmitList
.empty()) {
95 assert(!sendEvent
->scheduled());
96 sendEvent
->schedule(when
);
97 transmitList
.push_back(DeferredPacket(when
, pkt
));
101 // something is on the list and this belongs at the end
102 if (when
>= transmitList
.back().tick
) {
103 transmitList
.push_back(DeferredPacket(when
, pkt
));
106 // Something is on the list and this belongs somewhere else
107 DeferredPacketIterator i
= transmitList
.begin();
108 DeferredPacketIterator end
= transmitList
.end();
110 for (; i
!= end
; ++i
) {
111 if (when
< i
->tick
) {
112 if (i
== transmitList
.begin()) {
113 //Inserting at begining, reschedule
114 sendEvent
->reschedule(when
);
116 transmitList
.insert(i
, DeferredPacket(when
, pkt
));
120 assert(false); // should never get here
125 SimpleTimingPort::sendDeferredPacket()
127 assert(deferredPacketReady());
128 bool success
= sendTiming(transmitList
.front().pkt
);
131 //send successful, remove packet
132 transmitList
.pop_front();
133 if (!transmitList
.empty()) {
134 Tick time
= transmitList
.front().tick
;
135 sendEvent
->schedule(time
<= curTick
? curTick
+1 : time
);
138 if (transmitList
.empty() && drainEvent
) {
139 drainEvent
->process();
144 waitingOnRetry
= !success
;
146 if (waitingOnRetry
) {
147 DPRINTF(Bus
, "Send failed, waiting on retry\n");
153 SimpleTimingPort::recvRetry()
155 DPRINTF(Bus
, "Received retry\n");
156 assert(waitingOnRetry
);
157 sendDeferredPacket();
162 SimpleTimingPort::processSendEvent()
164 assert(!waitingOnRetry
);
165 sendDeferredPacket();
170 SimpleTimingPort::drain(Event
*de
)
172 if (transmitList
.size() == 0)