bridge.cc (8711:c7e14f52c682) bridge.cc (8713:2f1a3e335255)
1
2/*
1/*
2 * Copyright (c) 2011 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
3 * Copyright (c) 2006 The Regents of The University of Michigan
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright

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

23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Ali Saidi
30 * Steve Reinhardt
14 * Copyright (c) 2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright

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

34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Ali Saidi
41 * Steve Reinhardt
42 * Andreas Hansson
31 */
32
33/**
34 * @file
43 */
44
45/**
46 * @file
35 * Definition of a simple bus bridge without buffering.
47 * Implementation of a memory-mapped bus bridge that connects a master
48 * and a slave through a request and response queue.
36 */
37
49 */
50
38#include <algorithm>
39
40#include "base/range_ops.hh"
41#include "base/trace.hh"
42#include "debug/BusBridge.hh"
43#include "mem/bridge.hh"
44#include "params/Bridge.hh"
45
51#include "base/trace.hh"
52#include "debug/BusBridge.hh"
53#include "mem/bridge.hh"
54#include "params/Bridge.hh"
55
46Bridge::BridgePort::BridgePort(const std::string &_name,
47 Bridge *_bridge, BridgePort *_otherPort,
48 int _delay, int _nack_delay, int _req_limit,
49 int _resp_limit,
50 std::vector<Range<Addr> > filter_ranges)
51 : Port(_name, _bridge), bridge(_bridge), otherPort(_otherPort),
52 delay(_delay), nackDelay(_nack_delay), filterRanges(filter_ranges),
53 outstandingResponses(0), queuedRequests(0), inRetry(false),
54 reqQueueLimit(_req_limit), respQueueLimit(_resp_limit), sendEvent(this)
56Bridge::BridgeSlavePort::BridgeSlavePort(const std::string &_name,
57 Bridge* _bridge,
58 BridgeMasterPort* _masterPort,
59 int _delay, int _nack_delay,
60 int _resp_limit,
61 std::vector<Range<Addr> > _ranges)
62 : Port(_name, _bridge), bridge(_bridge), masterPort(_masterPort),
63 delay(_delay), nackDelay(_nack_delay),
64 ranges(_ranges.begin(), _ranges.end()),
65 outstandingResponses(0), inRetry(false),
66 respQueueLimit(_resp_limit), sendEvent(this)
55{
56}
57
67{
68}
69
70Bridge::BridgeMasterPort::BridgeMasterPort(const std::string &_name,
71 Bridge* _bridge,
72 BridgeSlavePort* _slavePort,
73 int _delay, int _req_limit)
74 : Port(_name, _bridge), bridge(_bridge), slavePort(_slavePort),
75 delay(_delay), inRetry(false), reqQueueLimit(_req_limit), sendEvent(this)
76{
77}
78
58Bridge::Bridge(Params *p)
59 : MemObject(p),
79Bridge::Bridge(Params *p)
80 : MemObject(p),
60 portA(p->name + "-portA", this, &portB, p->delay, p->nack_delay,
61 p->req_size_a, p->resp_size_a, p->filter_ranges_a),
62 portB(p->name + "-portB", this, &portA, p->delay, p->nack_delay,
63 p->req_size_b, p->resp_size_b, p->filter_ranges_b),
81 slavePort(p->name + "-slave", this, &masterPort, p->delay,
82 p->nack_delay, p->resp_size, p->ranges),
83 masterPort(p->name + "-master", this, &slavePort, p->delay, p->req_size),
64 ackWrites(p->write_ack), _params(p)
65{
66 if (ackWrites)
67 panic("No support for acknowledging writes\n");
68}
69
84 ackWrites(p->write_ack), _params(p)
85{
86 if (ackWrites)
87 panic("No support for acknowledging writes\n");
88}
89
70Port *
90Port*
71Bridge::getPort(const std::string &if_name, int idx)
72{
91Bridge::getPort(const std::string &if_name, int idx)
92{
73 BridgePort *port;
93 Port* port;
74
94
75 if (if_name == "side_a")
76 port = &portA;
77 else if (if_name == "side_b")
78 port = &portB;
95 if (if_name == "slave")
96 port = &slavePort;
97 else if (if_name == "master")
98 port = &masterPort;
79 else
80 return NULL;
81
82 if (port->getPeer() != NULL)
83 panic("bridge side %s already connected to %s.",
84 if_name, port->getPeer()->name());
85 return port;
86}
87
88
89void
90Bridge::init()
91{
99 else
100 return NULL;
101
102 if (port->getPeer() != NULL)
103 panic("bridge side %s already connected to %s.",
104 if_name, port->getPeer()->name());
105 return port;
106}
107
108
109void
110Bridge::init()
111{
92 // Make sure that both sides are connected to.
93 if (!portA.isConnected() || !portB.isConnected())
112 // make sure both sides are connected and have the same block size
113 if (!slavePort.isConnected() || !masterPort.isConnected())
94 fatal("Both ports of bus bridge are not connected to a bus.\n");
95
114 fatal("Both ports of bus bridge are not connected to a bus.\n");
115
96 if (portA.peerBlockSize() != portB.peerBlockSize())
97 fatal("port A size %d, port B size %d \n " \
116 if (slavePort.peerBlockSize() != masterPort.peerBlockSize())
117 fatal("Slave port size %d, master port size %d \n " \
98 "Busses don't have the same block size... Not supported.\n",
118 "Busses don't have the same block size... Not supported.\n",
99 portA.peerBlockSize(), portB.peerBlockSize());
119 slavePort.peerBlockSize(), masterPort.peerBlockSize());
120
121 // notify the master side of our address ranges
122 slavePort.sendRangeChange();
100}
101
102bool
123}
124
125bool
103Bridge::BridgePort::respQueueFull()
126Bridge::BridgeSlavePort::respQueueFull()
104{
127{
105 assert(outstandingResponses >= 0 && outstandingResponses <= respQueueLimit);
106 return outstandingResponses >= respQueueLimit;
128 return outstandingResponses == respQueueLimit;
107}
108
109bool
129}
130
131bool
110Bridge::BridgePort::reqQueueFull()
132Bridge::BridgeMasterPort::reqQueueFull()
111{
133{
112 assert(queuedRequests >= 0 && queuedRequests <= reqQueueLimit);
113 return queuedRequests >= reqQueueLimit;
134 return requestQueue.size() == reqQueueLimit;
114}
115
135}
136
116/** Function called by the port when the bus is receiving a Timing
117 * transaction.*/
118bool
137bool
119Bridge::BridgePort::recvTiming(PacketPtr pkt)
138Bridge::BridgeMasterPort::recvTiming(PacketPtr pkt)
120{
139{
140 // should only see responses on the master side
141 assert(pkt->isResponse());
142
143 // all checks are done when the request is accepted on the slave
144 // side, so we are guaranteed to have space for the response
145
121 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n",
146 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n",
122 pkt->getSrc(), pkt->getDest(), pkt->getAddr());
147 pkt->getSrc(), pkt->getDest(), pkt->getAddr());
123
148
124 DPRINTF(BusBridge, "Local queue size: %d outreq: %d outresp: %d\n",
125 sendQueue.size(), queuedRequests, outstandingResponses);
126 DPRINTF(BusBridge, "Remote queue size: %d outreq: %d outresp: %d\n",
127 otherPort->sendQueue.size(), otherPort->queuedRequests,
128 otherPort->outstandingResponses);
149 DPRINTF(BusBridge, "Request queue size: %d\n", requestQueue.size());
129
150
130 if (pkt->isRequest() && otherPort->reqQueueFull()) {
131 DPRINTF(BusBridge, "Remote queue full, nacking\n");
151 slavePort->queueForSendTiming(pkt);
152
153 return true;
154}
155
156bool
157Bridge::BridgeSlavePort::recvTiming(PacketPtr pkt)
158{
159 // should only see requests on the slave side
160 assert(pkt->isRequest());
161
162 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n",
163 pkt->getSrc(), pkt->getDest(), pkt->getAddr());
164
165 DPRINTF(BusBridge, "Response queue size: %d outresp: %d\n",
166 responseQueue.size(), outstandingResponses);
167
168 if (masterPort->reqQueueFull()) {
169 DPRINTF(BusBridge, "Request queue full, nacking\n");
132 nackRequest(pkt);
133 return true;
134 }
135
136 if (pkt->needsResponse()) {
137 if (respQueueFull()) {
170 nackRequest(pkt);
171 return true;
172 }
173
174 if (pkt->needsResponse()) {
175 if (respQueueFull()) {
138 DPRINTF(BusBridge, "Local queue full, no space for response, nacking\n");
139 DPRINTF(BusBridge, "queue size: %d outreq: %d outstanding resp: %d\n",
140 sendQueue.size(), queuedRequests, outstandingResponses);
176 DPRINTF(BusBridge,
177 "Response queue full, no space for response, nacking\n");
178 DPRINTF(BusBridge,
179 "queue size: %d outstanding resp: %d\n",
180 responseQueue.size(), outstandingResponses);
141 nackRequest(pkt);
142 return true;
143 } else {
144 DPRINTF(BusBridge, "Request Needs response, reserving space\n");
181 nackRequest(pkt);
182 return true;
183 } else {
184 DPRINTF(BusBridge, "Request Needs response, reserving space\n");
185 assert(outstandingResponses != respQueueLimit);
145 ++outstandingResponses;
146 }
147 }
148
186 ++outstandingResponses;
187 }
188 }
189
149 otherPort->queueForSendTiming(pkt);
190 masterPort->queueForSendTiming(pkt);
150
151 return true;
152}
153
154void
191
192 return true;
193}
194
195void
155Bridge::BridgePort::nackRequest(PacketPtr pkt)
196Bridge::BridgeSlavePort::nackRequest(PacketPtr pkt)
156{
157 // Nack the packet
158 pkt->makeTimingResponse();
159 pkt->setNacked();
160
197{
198 // Nack the packet
199 pkt->makeTimingResponse();
200 pkt->setNacked();
201
161 //put it on the list to send
202 // The Nack packets are stored in the response queue just like any
203 // other response, but they do not occupy any space as this is
204 // tracked by the outstandingResponses, this guarantees space for
205 // the Nack packets, but implicitly means we have an (unrealistic)
206 // unbounded Nack queue.
207
208 // put it on the list to send
162 Tick readyTime = curTick() + nackDelay;
163 PacketBuffer *buf = new PacketBuffer(pkt, readyTime, true);
164
165 // nothing on the list, add it and we're done
209 Tick readyTime = curTick() + nackDelay;
210 PacketBuffer *buf = new PacketBuffer(pkt, readyTime, true);
211
212 // nothing on the list, add it and we're done
166 if (sendQueue.empty()) {
213 if (responseQueue.empty()) {
167 assert(!sendEvent.scheduled());
168 bridge->schedule(sendEvent, readyTime);
214 assert(!sendEvent.scheduled());
215 bridge->schedule(sendEvent, readyTime);
169 sendQueue.push_back(buf);
216 responseQueue.push_back(buf);
170 return;
171 }
172
173 assert(sendEvent.scheduled() || inRetry);
174
175 // does it go at the end?
217 return;
218 }
219
220 assert(sendEvent.scheduled() || inRetry);
221
222 // does it go at the end?
176 if (readyTime >= sendQueue.back()->ready) {
177 sendQueue.push_back(buf);
223 if (readyTime >= responseQueue.back()->ready) {
224 responseQueue.push_back(buf);
178 return;
179 }
180
181 // ok, somewhere in the middle, fun
225 return;
226 }
227
228 // ok, somewhere in the middle, fun
182 std::list<PacketBuffer*>::iterator i = sendQueue.begin();
183 std::list<PacketBuffer*>::iterator end = sendQueue.end();
184 std::list<PacketBuffer*>::iterator begin = sendQueue.begin();
229 std::list<PacketBuffer*>::iterator i = responseQueue.begin();
230 std::list<PacketBuffer*>::iterator end = responseQueue.end();
231 std::list<PacketBuffer*>::iterator begin = responseQueue.begin();
185 bool done = false;
186
187 while (i != end && !done) {
188 if (readyTime < (*i)->ready) {
189 if (i == begin)
190 bridge->reschedule(sendEvent, readyTime);
232 bool done = false;
233
234 while (i != end && !done) {
235 if (readyTime < (*i)->ready) {
236 if (i == begin)
237 bridge->reschedule(sendEvent, readyTime);
191 sendQueue.insert(i,buf);
238 responseQueue.insert(i,buf);
192 done = true;
193 }
194 i++;
195 }
196 assert(done);
197}
198
239 done = true;
240 }
241 i++;
242 }
243 assert(done);
244}
245
199
200void
246void
201Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
247Bridge::BridgeMasterPort::queueForSendTiming(PacketPtr pkt)
202{
248{
203 if (pkt->isResponse()) {
204 // This is a response for a request we forwarded earlier. The
205 // corresponding PacketBuffer should be stored in the packet's
206 // senderState field.
249 Tick readyTime = curTick() + delay;
250 PacketBuffer *buf = new PacketBuffer(pkt, readyTime);
207
251
208 PacketBuffer *buf = dynamic_cast<PacketBuffer*>(pkt->senderState);
209 assert(buf != NULL);
210 // set up new packet dest & senderState based on values saved
211 // from original request
212 buf->fixResponse(pkt);
213
214 DPRINTF(BusBridge, "response, new dest %d\n", pkt->getDest());
215 delete buf;
252 // If we're about to put this packet at the head of the queue, we
253 // need to schedule an event to do the transmit. Otherwise there
254 // should already be an event scheduled for sending the head
255 // packet.
256 if (requestQueue.empty()) {
257 bridge->schedule(sendEvent, readyTime);
216 }
217
258 }
259
260 assert(requestQueue.size() != reqQueueLimit);
218
261
219 if (pkt->isRequest()) {
220 ++queuedRequests;
221 }
262 requestQueue.push_back(buf);
263}
222
223
264
265
266void
267Bridge::BridgeSlavePort::queueForSendTiming(PacketPtr pkt)
268{
269 // This is a response for a request we forwarded earlier. The
270 // corresponding PacketBuffer should be stored in the packet's
271 // senderState field.
272 PacketBuffer *buf = dynamic_cast<PacketBuffer*>(pkt->senderState);
273 assert(buf != NULL);
274 // set up new packet dest & senderState based on values saved
275 // from original request
276 buf->fixResponse(pkt);
224
277
278 DPRINTF(BusBridge, "response, new dest %d\n", pkt->getDest());
279 delete buf;
280
225 Tick readyTime = curTick() + delay;
281 Tick readyTime = curTick() + delay;
226 PacketBuffer *buf = new PacketBuffer(pkt, readyTime);
282 buf = new PacketBuffer(pkt, readyTime);
227
228 // If we're about to put this packet at the head of the queue, we
229 // need to schedule an event to do the transmit. Otherwise there
230 // should already be an event scheduled for sending the head
231 // packet.
283
284 // If we're about to put this packet at the head of the queue, we
285 // need to schedule an event to do the transmit. Otherwise there
286 // should already be an event scheduled for sending the head
287 // packet.
232 if (sendQueue.empty()) {
288 if (responseQueue.empty()) {
233 bridge->schedule(sendEvent, readyTime);
234 }
289 bridge->schedule(sendEvent, readyTime);
290 }
235 sendQueue.push_back(buf);
291 responseQueue.push_back(buf);
236}
237
238void
292}
293
294void
239Bridge::BridgePort::trySend()
295Bridge::BridgeMasterPort::trySend()
240{
296{
241 assert(!sendQueue.empty());
297 assert(!requestQueue.empty());
242
298
243 PacketBuffer *buf = sendQueue.front();
299 PacketBuffer *buf = requestQueue.front();
244
245 assert(buf->ready <= curTick());
246
247 PacketPtr pkt = buf->pkt;
248
249 DPRINTF(BusBridge, "trySend: origSrc %d dest %d addr 0x%x\n",
250 buf->origSrc, pkt->getDest(), pkt->getAddr());
251
300
301 assert(buf->ready <= curTick());
302
303 PacketPtr pkt = buf->pkt;
304
305 DPRINTF(BusBridge, "trySend: origSrc %d dest %d addr 0x%x\n",
306 buf->origSrc, pkt->getDest(), pkt->getAddr());
307
252 bool wasReq = pkt->isRequest();
253 bool was_nacked_here = buf->nackedHere;
254
255 // If the send was successful, make sure sender state was set to NULL
256 // otherwise we could get a NACK back of a packet that didn't expect a
257 // response and we would try to use freed memory.
258
259 Packet::SenderState *old_sender_state = pkt->senderState;
308 // If the send was successful, make sure sender state was set to NULL
309 // otherwise we could get a NACK back of a packet that didn't expect a
310 // response and we would try to use freed memory.
311
312 Packet::SenderState *old_sender_state = pkt->senderState;
260 if (pkt->isRequest() && !buf->expectResponse)
313 if (!buf->expectResponse)
261 pkt->senderState = NULL;
262
263 if (sendTiming(pkt)) {
264 // send successful
314 pkt->senderState = NULL;
315
316 if (sendTiming(pkt)) {
317 // send successful
265 sendQueue.pop_front();
266 buf->pkt = NULL; // we no longer own packet, so it's not safe to look at it
318 requestQueue.pop_front();
319 // we no longer own packet, so it's not safe to look at it
320 buf->pkt = NULL;
267
321
268 if (buf->expectResponse) {
269 // Must wait for response
270 DPRINTF(BusBridge, " successful: awaiting response (%d)\n",
271 outstandingResponses);
272 } else {
322 if (!buf->expectResponse) {
273 // no response expected... deallocate packet buffer now.
274 DPRINTF(BusBridge, " successful: no response expected\n");
275 delete buf;
276 }
277
323 // no response expected... deallocate packet buffer now.
324 DPRINTF(BusBridge, " successful: no response expected\n");
325 delete buf;
326 }
327
278 if (wasReq)
279 --queuedRequests;
280 else if (!was_nacked_here)
328 // If there are more packets to send, schedule event to try again.
329 if (!requestQueue.empty()) {
330 buf = requestQueue.front();
331 DPRINTF(BusBridge, "Scheduling next send\n");
332 bridge->schedule(sendEvent, std::max(buf->ready, curTick() + 1));
333 }
334 } else {
335 DPRINTF(BusBridge, " unsuccessful\n");
336 pkt->senderState = old_sender_state;
337 inRetry = true;
338 }
339
340 DPRINTF(BusBridge, "trySend: request queue size: %d\n",
341 requestQueue.size());
342}
343
344void
345Bridge::BridgeSlavePort::trySend()
346{
347 assert(!responseQueue.empty());
348
349 PacketBuffer *buf = responseQueue.front();
350
351 assert(buf->ready <= curTick());
352
353 PacketPtr pkt = buf->pkt;
354
355 DPRINTF(BusBridge, "trySend: origSrc %d dest %d addr 0x%x\n",
356 buf->origSrc, pkt->getDest(), pkt->getAddr());
357
358 bool was_nacked_here = buf->nackedHere;
359
360 // no need to worry about the sender state since we are not
361 // modifying it
362
363 if (sendTiming(pkt)) {
364 DPRINTF(BusBridge, " successful\n");
365 // send successful
366 responseQueue.pop_front();
367 // this is a response... deallocate packet buffer now.
368 delete buf;
369
370 if (!was_nacked_here) {
371 assert(outstandingResponses != 0);
281 --outstandingResponses;
372 --outstandingResponses;
373 }
282
283 // If there are more packets to send, schedule event to try again.
374
375 // If there are more packets to send, schedule event to try again.
284 if (!sendQueue.empty()) {
285 buf = sendQueue.front();
376 if (!responseQueue.empty()) {
377 buf = responseQueue.front();
286 DPRINTF(BusBridge, "Scheduling next send\n");
287 bridge->schedule(sendEvent, std::max(buf->ready, curTick() + 1));
288 }
289 } else {
290 DPRINTF(BusBridge, " unsuccessful\n");
378 DPRINTF(BusBridge, "Scheduling next send\n");
379 bridge->schedule(sendEvent, std::max(buf->ready, curTick() + 1));
380 }
381 } else {
382 DPRINTF(BusBridge, " unsuccessful\n");
291 pkt->senderState = old_sender_state;
292 inRetry = true;
293 }
294
383 inRetry = true;
384 }
385
295 DPRINTF(BusBridge, "trySend: queue size: %d outreq: %d outstanding resp: %d\n",
296 sendQueue.size(), queuedRequests, outstandingResponses);
386 DPRINTF(BusBridge, "trySend: queue size: %d outstanding resp: %d\n",
387 responseQueue.size(), outstandingResponses);
297}
298
388}
389
390void
391Bridge::BridgeMasterPort::recvRetry()
392{
393 inRetry = false;
394 Tick nextReady = requestQueue.front()->ready;
395 if (nextReady <= curTick())
396 trySend();
397 else
398 bridge->schedule(sendEvent, nextReady);
399}
299
300void
400
401void
301Bridge::BridgePort::recvRetry()
402Bridge::BridgeSlavePort::recvRetry()
302{
303 inRetry = false;
403{
404 inRetry = false;
304 Tick nextReady = sendQueue.front()->ready;
405 Tick nextReady = responseQueue.front()->ready;
305 if (nextReady <= curTick())
306 trySend();
307 else
308 bridge->schedule(sendEvent, nextReady);
309}
310
406 if (nextReady <= curTick())
407 trySend();
408 else
409 bridge->schedule(sendEvent, nextReady);
410}
411
311/** Function called by the port when the bus is receiving a Atomic
312 * transaction.*/
313Tick
412Tick
314Bridge::BridgePort::recvAtomic(PacketPtr pkt)
413Bridge::BridgeMasterPort::recvAtomic(PacketPtr pkt)
315{
414{
316 return delay + otherPort->sendAtomic(pkt);
415 // master port should never receive any atomic access (panic only
416 // works once the other side, i.e. the busses, respects this)
417 //
418 //panic("Master port on %s got a recvAtomic\n", bridge->name());
419 return 0;
317}
318
420}
421
319/** Function called by the port when the bus is receiving a Functional
320 * transaction.*/
422Tick
423Bridge::BridgeSlavePort::recvAtomic(PacketPtr pkt)
424{
425 return delay + masterPort->sendAtomic(pkt);
426}
427
321void
428void
322Bridge::BridgePort::recvFunctional(PacketPtr pkt)
429Bridge::BridgeMasterPort::recvFunctional(PacketPtr pkt)
323{
430{
431 // master port should never receive any functional access (panic
432 // only works once the other side, i.e. the busses, respect this)
433
434 // panic("Master port on %s got a recvFunctional\n", bridge->name());
435}
436
437void
438Bridge::BridgeSlavePort::recvFunctional(PacketPtr pkt)
439{
324 std::list<PacketBuffer*>::iterator i;
325
326 pkt->pushLabel(name());
327
440 std::list<PacketBuffer*>::iterator i;
441
442 pkt->pushLabel(name());
443
328 for (i = sendQueue.begin(); i != sendQueue.end(); ++i) {
444 // check the response queue
445 for (i = responseQueue.begin(); i != responseQueue.end(); ++i) {
329 if (pkt->checkFunctional((*i)->pkt)) {
330 pkt->makeResponse();
331 return;
332 }
333 }
334
446 if (pkt->checkFunctional((*i)->pkt)) {
447 pkt->makeResponse();
448 return;
449 }
450 }
451
452 // also check the master port's request queue
453 if (masterPort->checkFunctional(pkt)) {
454 return;
455 }
456
335 pkt->popLabel();
336
337 // fall through if pkt still not satisfied
457 pkt->popLabel();
458
459 // fall through if pkt still not satisfied
338 otherPort->sendFunctional(pkt);
460 masterPort->sendFunctional(pkt);
339}
340
461}
462
463bool
464Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt)
465{
466 bool found = false;
467 std::list<PacketBuffer*>::iterator i = requestQueue.begin();
468
469 while(i != requestQueue.end() && !found) {
470 if (pkt->checkFunctional((*i)->pkt)) {
471 pkt->makeResponse();
472 found = true;
473 }
474 ++i;
475 }
476
477 return found;
478}
479
341/** Function called by the port when the bridge is receiving a range change.*/
342void
480/** Function called by the port when the bridge is receiving a range change.*/
481void
343Bridge::BridgePort::recvRangeChange()
482Bridge::BridgeMasterPort::recvRangeChange()
344{
483{
345 otherPort->sendRangeChange();
484 // no need to forward as the bridge has a fixed set of ranges
346}
347
485}
486
487void
488Bridge::BridgeSlavePort::recvRangeChange()
489{
490 // is a slave port so do nothing
491}
492
348AddrRangeList
493AddrRangeList
349Bridge::BridgePort::getAddrRanges()
494Bridge::BridgeSlavePort::getAddrRanges()
350{
495{
351 AddrRangeList ranges = otherPort->getPeer()->getAddrRanges();
352 FilterRangeList(filterRanges, ranges);
353 return ranges;
354}
355
356Bridge *
357BridgeParams::create()
358{
359 return new Bridge(this);
360}
496 return ranges;
497}
498
499Bridge *
500BridgeParams::create()
501{
502 return new Bridge(this);
503}