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();
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
55 SimpleTimingPort::recvFunctional(PacketPtr pkt
)
59 // Just do an atomic access and throw away the returned latency
60 if (pkt
->result
!= Packet::Success
)
65 SimpleTimingPort::recvTiming(PacketPtr pkt
)
67 // If the device is only a slave, it should only be sending
68 // responses, which should never get nacked. There used to be
69 // code to hanldle nacks here, but I'm pretty sure it didn't work
70 // correctly with the drain code, so that would need to be fixed
71 // if we ever added it back.
72 assert(pkt
->result
!= Packet::Nacked
);
73 Tick latency
= recvAtomic(pkt
);
74 // turn packet around to go back to requester if response expected
75 if (pkt
->needsResponse()) {
76 pkt
->makeTimingResponse();
77 sendTiming(pkt
, latency
);
79 else if (pkt
->cmd
!= MemCmd::UpgradeReq
) {
87 SimpleTimingPort::recvRetry()
89 assert(!transmitList
.empty());
90 if (Port::sendTiming(transmitList
.front().pkt
)) {
91 transmitList
.pop_front();
92 DPRINTF(Bus
, "No Longer waiting on retry\n");
93 if (!transmitList
.empty()) {
94 Tick time
= transmitList
.front().tick
;
95 sendEvent
->schedule(time
<= curTick
? curTick
+1 : time
);
99 if (transmitList
.empty() && drainEvent
) {
100 drainEvent
->process();
106 SimpleTimingPort::sendTiming(PacketPtr pkt
, Tick time
)
108 // Nothing is on the list: add it and schedule an event
109 if (transmitList
.empty()) {
110 assert(!sendEvent
->scheduled());
111 sendEvent
->schedule(curTick
+time
);
112 transmitList
.push_back(DeferredPacket(time
+curTick
, pkt
));
116 // something is on the list and this belongs at the end
117 if (time
+curTick
>= transmitList
.back().tick
) {
118 transmitList
.push_back(DeferredPacket(time
+curTick
, pkt
));
121 // Something is on the list and this belongs somewhere else
122 DeferredPacketIterator i
= transmitList
.begin();
123 DeferredPacketIterator end
= transmitList
.end();
126 while (i
!= end
&& !done
) {
127 if (time
+curTick
< i
->tick
) {
128 if (i
== transmitList
.begin()) {
129 //Inserting at begining, reschedule
130 sendEvent
->reschedule(time
+curTick
);
132 transmitList
.insert(i
, DeferredPacket(time
+curTick
, pkt
));
141 SimpleTimingPort::processSendEvent()
143 assert(transmitList
.size());
144 assert(transmitList
.front().tick
<= curTick
);
145 if (Port::sendTiming(transmitList
.front().pkt
)) {
146 //send successful, remove packet
147 transmitList
.pop_front();
148 if (!transmitList
.empty()) {
149 Tick time
= transmitList
.front().tick
;
150 sendEvent
->schedule(time
<= curTick
? curTick
+1 : time
);
152 if (transmitList
.empty() && drainEvent
) {
153 drainEvent
->process();
158 // send unsuccessful (due to flow control). Will get retry
159 // callback later; save for then if not already
160 DPRINTF(Bus
, "Waiting on retry\n");
165 SimpleTimingPort::drain(Event
*de
)
167 if (transmitList
.size() == 0)