Deleted Added
sdiff udiff text old ( 8708:7ccbdea0fa12 ) new ( 8856:241ee47b0dc6 )
full compact
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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

--- 11 unchanged lines hidden (view full) ---

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.
27 *
28 * Authors: Ali Saidi
29 */
30
31#include "debug/Bus.hh"
32#include "mem/mem_object.hh"
33#include "mem/tport.hh"
34
35using namespace std;
36
37SimpleTimingPort::SimpleTimingPort(string pname, MemObject *_owner)
38 : Port(pname, _owner), sendEvent(NULL), drainEvent(NULL),
39 waitingOnRetry(false)
40{
41 sendEvent = new EventWrapper<SimpleTimingPort,
42 &SimpleTimingPort::processSendEvent>(this);
43}
44
45SimpleTimingPort::~SimpleTimingPort()
46{
47 delete sendEvent;
48}
49
50bool
51SimpleTimingPort::checkFunctional(PacketPtr pkt)
52{
53 DeferredPacketIterator i = transmitList.begin();
54 DeferredPacketIterator end = transmitList.end();
55
56 for (; i != end; ++i) {
57 PacketPtr target = i->pkt;
58 // If the target contains data, and it overlaps the
59 // probed request, need to update data
60 if (pkt->checkFunctional(target)) {
61 return true;
62 }
63 }
64
65 return false;
66}
67
68void
69SimpleTimingPort::recvFunctional(PacketPtr pkt)
70{
71 if (!checkFunctional(pkt)) {
72 // Just do an atomic access and throw away the returned latency
73 recvAtomic(pkt);

--- 29 unchanged lines hidden (view full) ---

103 }
104
105 return true;
106}
107
108void
109SimpleTimingPort::schedSendEvent(Tick when)
110{
111 if (waitingOnRetry) {
112 assert(!sendEvent->scheduled());
113 return;
114 }
115
116 if (!sendEvent->scheduled()) {
117 owner->schedule(sendEvent, when);
118 } else if (sendEvent->when() > when) {
119 owner->reschedule(sendEvent, when);
120 }
121}
122
123void
124SimpleTimingPort::schedSendTiming(PacketPtr pkt, Tick when)
125{
126 assert(when > curTick());
127 assert(when < curTick() + SimClock::Int::ms);

--- 20 unchanged lines hidden (view full) ---

148 if (when < i->tick) {
149 transmitList.insert(i, DeferredPacket(when, pkt));
150 return;
151 }
152 }
153 assert(false); // should never get here
154}
155
156
157void
158SimpleTimingPort::sendDeferredPacket()
159{
160 assert(deferredPacketReady());
161 // take packet off list here; if recvTiming() on the other side
162 // calls sendTiming() back on us (like SimpleTimingCpu does), then
163 // we get confused by having a non-active packet on transmitList
164 DeferredPacket dp = transmitList.front();
165 transmitList.pop_front();
166 bool success = sendTiming(dp.pkt);
167
168 if (success) {
169 if (!transmitList.empty() && !sendEvent->scheduled()) {
170 Tick time = transmitList.front().tick;
171 owner->schedule(sendEvent, time <= curTick() ? curTick()+1 : time);
172 }
173
174 if (transmitList.empty() && drainEvent && !sendEvent->scheduled()) {
175 drainEvent->process();
176 drainEvent = NULL;
177 }
178 } else {
179 // Unsuccessful, need to put back on transmitList. Callee
180 // should not have messed with it (since it didn't accept that
181 // packet), so we can just push it back on the front.
182 assert(!sendEvent->scheduled());
183 transmitList.push_front(dp);
184 }
185
186 waitingOnRetry = !success;
187
188 if (waitingOnRetry) {
189 DPRINTF(Bus, "Send failed, waiting on retry\n");
190 }
191}
192
193
194void
195SimpleTimingPort::recvRetry()
196{
197 DPRINTF(Bus, "Received retry\n");
198 assert(waitingOnRetry);
199 sendDeferredPacket();
200}
201
202
203void
204SimpleTimingPort::processSendEvent()
205{
206 assert(!waitingOnRetry);
207 sendDeferredPacket();
208}
209
210
211unsigned int
212SimpleTimingPort::drain(Event *de)
213{
214 if (transmitList.size() == 0 && !sendEvent->scheduled())
215 return 0;
216 drainEvent = de;
217 return 1;
218}