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 (pkt
->checkFunctional(target
)) {
52 SimpleTimingPort::recvFunctional(PacketPtr pkt
)
54 if (!checkFunctional(pkt
)) {
55 // Just do an atomic access and throw away the returned latency
61 SimpleTimingPort::recvTiming(PacketPtr pkt
)
63 // If the device is only a slave, it should only be sending
64 // responses, which should never get nacked. There used to be
65 // code to hanldle nacks here, but I'm pretty sure it didn't work
66 // correctly with the drain code, so that would need to be fixed
67 // if we ever added it back.
69 if (pkt
->memInhibitAsserted()) {
70 // snooper will supply based on copy of packet
71 // still target's responsibility to delete packet
76 bool needsResponse
= pkt
->needsResponse();
77 Tick latency
= recvAtomic(pkt
);
78 // turn packet around to go back to requester if response expected
80 // recvAtomic() should already have turned packet into
82 assert(pkt
->isResponse());
83 schedSendTiming(pkt
, curTick
+ latency
);
93 SimpleTimingPort::schedSendTiming(PacketPtr pkt
, Tick when
)
95 assert(when
> curTick
);
96 assert(when
< curTick
+ Clock::Int::ms
);
98 // Nothing is on the list: add it and schedule an event
99 if (transmitList
.empty() || when
< transmitList
.front().tick
) {
100 transmitList
.push_front(DeferredPacket(when
, pkt
));
101 schedSendEvent(when
);
105 // list is non-empty & this belongs at the end
106 if (when
>= transmitList
.back().tick
) {
107 transmitList
.push_back(DeferredPacket(when
, pkt
));
111 // this belongs in the middle somewhere
112 DeferredPacketIterator i
= transmitList
.begin();
113 i
++; // already checked for insertion at front
114 DeferredPacketIterator end
= transmitList
.end();
116 for (; i
!= end
; ++i
) {
117 if (when
< i
->tick
) {
118 transmitList
.insert(i
, DeferredPacket(when
, pkt
));
122 assert(false); // should never get here
127 SimpleTimingPort::sendDeferredPacket()
129 assert(deferredPacketReady());
130 // take packet off list here; if recvTiming() on the other side
131 // calls sendTiming() back on us (like SimpleTimingCpu does), then
132 // we get confused by having a non-active packet on transmitList
133 DeferredPacket dp
= transmitList
.front();
134 transmitList
.pop_front();
135 bool success
= sendTiming(dp
.pkt
);
138 if (!transmitList
.empty() && !sendEvent
->scheduled()) {
139 Tick time
= transmitList
.front().tick
;
140 schedule(sendEvent
, time
<= curTick
? curTick
+1 : time
);
143 if (transmitList
.empty() && drainEvent
) {
144 drainEvent
->process();
148 // Unsuccessful, need to put back on transmitList. Callee
149 // should not have messed with it (since it didn't accept that
150 // packet), so we can just push it back on the front.
151 assert(!sendEvent
->scheduled());
152 transmitList
.push_front(dp
);
155 waitingOnRetry
= !success
;
157 if (waitingOnRetry
) {
158 DPRINTF(Bus
, "Send failed, waiting on retry\n");
164 SimpleTimingPort::recvRetry()
166 DPRINTF(Bus
, "Received retry\n");
167 assert(waitingOnRetry
);
168 sendDeferredPacket();
173 SimpleTimingPort::processSendEvent()
175 assert(!waitingOnRetry
);
176 sendDeferredPacket();
181 SimpleTimingPort::drain(Event
*de
)
183 if (transmitList
.size() == 0)