2 * Copyright (c) 2011-2012 ARM Limited
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.
14 * Copyright (c) 2006 The Regents of The University of Michigan
15 * All rights reserved.
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
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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.
47 * Definition of a bus object.
50 #include "base/misc.hh"
51 #include "base/trace.hh"
52 #include "debug/Bus.hh"
53 #include "debug/BusAddrRanges.hh"
56 Bus::Bus(const BusParams
*p
)
57 : MemObject(p
), clock(p
->clock
),
58 headerCycles(p
->header_cycles
), width(p
->width
), tickNextIdle(0),
59 drainEvent(NULL
), busIdleEvent(this), inRetry(false),
60 defaultPortId(Port::INVALID_PORT_ID
),
61 useDefaultRange(p
->use_default_range
),
62 defaultBlockSize(p
->block_size
),
63 cachedBlockSize(0), cachedBlockSizeValid(false)
65 //width, clock period, and header cycles must be positive
67 fatal("Bus width must be positive\n");
69 fatal("Bus clock period must be positive\n");
70 if (headerCycles
<= 0)
71 fatal("Number of header cycles must be positive\n");
73 // create the ports based on the size of the master and slave
74 // vector ports, and the presence of the default port, the ports
75 // are enumerated starting from zero
76 for (int i
= 0; i
< p
->port_master_connection_count
; ++i
) {
77 std::string portName
= csprintf("%s-p%d", name(), i
);
78 MasterPort
* bp
= new BusMasterPort(portName
, this, i
);
79 masterPorts
.push_back(bp
);
82 // see if we have a default slave device connected and if so add
83 // our corresponding master port
84 if (p
->port_default_connection_count
) {
85 defaultPortId
= masterPorts
.size();
86 std::string portName
= csprintf("%s-default", name());
87 MasterPort
* bp
= new BusMasterPort(portName
, this, defaultPortId
);
88 masterPorts
.push_back(bp
);
91 // create the slave ports, once again starting at zero
92 for (int i
= 0; i
< p
->port_slave_connection_count
; ++i
) {
93 std::string portName
= csprintf("%s-p%d", name(), i
);
94 SlavePort
* bp
= new BusSlavePort(portName
, this, i
);
95 slavePorts
.push_back(bp
);
102 Bus::getMasterPort(const std::string
&if_name
, int idx
)
104 if (if_name
== "master" && idx
< masterPorts
.size()) {
105 // the master port index translates directly to the vector position
106 return *masterPorts
[idx
];
107 } else if (if_name
== "default") {
108 return *masterPorts
[defaultPortId
];
110 return MemObject::getMasterPort(if_name
, idx
);
115 Bus::getSlavePort(const std::string
&if_name
, int idx
)
117 if (if_name
== "slave" && idx
< slavePorts
.size()) {
118 // the slave port index translates directly to the vector position
119 return *slavePorts
[idx
];
121 return MemObject::getSlavePort(if_name
, idx
);
128 // iterate over our slave ports and determine which of our
129 // neighbouring master ports are snooping and add them as snoopers
130 for (SlavePortConstIter p
= slavePorts
.begin(); p
!= slavePorts
.end();
132 if ((*p
)->getMasterPort().isSnooping()) {
133 DPRINTF(BusAddrRanges
, "Adding snooping neighbour %s\n",
134 (*p
)->getMasterPort().name());
135 snoopPorts
.push_back(*p
);
141 Bus::calcPacketTiming(PacketPtr pkt
)
143 // determine the current time rounded to the closest following
145 Tick now
= curTick();
146 if (now
% clock
!= 0) {
147 now
= ((now
/ clock
) + 1) * clock
;
150 Tick headerTime
= now
+ headerCycles
* clock
;
152 // The packet will be sent. Figure out how long it occupies the bus, and
153 // how much of that time is for the first "word", aka bus width.
155 if (pkt
->hasData()) {
156 // If a packet has data, it needs ceil(size/width) cycles to send it
157 int dataSize
= pkt
->getSize();
158 numCycles
+= dataSize
/width
;
159 if (dataSize
% width
)
163 // The first word will be delivered after the current tick, the delivery
164 // of the address if any, and one bus cycle to deliver the data
165 pkt
->firstWordTime
= headerTime
+ clock
;
167 pkt
->finishTime
= headerTime
+ numCycles
* clock
;
172 void Bus::occupyBus(Tick until
)
175 // shortcut for express snoop packets
179 tickNextIdle
= until
;
180 reschedule(busIdleEvent
, tickNextIdle
, true);
182 DPRINTF(Bus
, "The bus is now occupied from tick %d to %d\n",
183 curTick(), tickNextIdle
);
187 Bus::isOccupied(PacketPtr pkt
, Port
* port
)
189 // first we see if the next idle tick is in the future, next the
190 // bus is considered occupied if there are ports on the retry list
191 // and we are not in a retry with the current port
192 if (tickNextIdle
> curTick() ||
193 (!retryList
.empty() && !(inRetry
&& port
== retryList
.front()))) {
194 addToRetryList(port
);
201 Bus::recvTiming(PacketPtr pkt
)
204 Packet::NodeID src_id
= pkt
->getSrc();
206 // determine the source port based on the id and direction
207 Port
*src_port
= NULL
;
208 if (pkt
->isRequest())
209 src_port
= slavePorts
[src_id
];
211 src_port
= masterPorts
[src_id
];
213 // test if the bus should be considered occupied for the current
214 // packet, and exclude express snoops from the check
215 if (!pkt
->isExpressSnoop() && isOccupied(pkt
, src_port
)) {
216 DPRINTF(Bus
, "recvTiming: src %s %s 0x%x BUSY\n",
217 src_port
->name(), pkt
->cmdString(), pkt
->getAddr());
221 DPRINTF(Bus
, "recvTiming: src %s %s 0x%x\n",
222 src_port
->name(), pkt
->cmdString(), pkt
->getAddr());
224 Tick headerFinishTime
= pkt
->isExpressSnoop() ? 0 : calcPacketTiming(pkt
);
225 Tick packetFinishTime
= pkt
->isExpressSnoop() ? 0 : pkt
->finishTime
;
227 // decide what to do based on the direction
228 if (pkt
->isRequest()) {
229 // the packet is a memory-mapped request and should be
230 // broadcasted to our snoopers but the source
231 forwardTiming(pkt
, src_id
);
233 // remember if we add an outstanding req so we can undo it if
234 // necessary, if the packet needs a response, we should add it
235 // as outstanding and express snoops never fail so there is
236 // not need to worry about them
237 bool add_outstanding
= !pkt
->isExpressSnoop() && pkt
->needsResponse();
239 // keep track that we have an outstanding request packet
240 // matching this request, this is used by the coherency
241 // mechanism in determining what to do with snoop responses
242 // (in recvTimingSnoop)
243 if (add_outstanding
) {
244 // we should never have an exsiting request outstanding
245 assert(outstandingReq
.find(pkt
->req
) == outstandingReq
.end());
246 outstandingReq
.insert(pkt
->req
);
249 // since it is a normal request, determine the destination
250 // based on the address and attempt to send the packet
251 bool success
= masterPorts
[findPort(pkt
->getAddr())]->sendTiming(pkt
);
254 // inhibited packets should never be forced to retry
255 assert(!pkt
->memInhibitAsserted());
257 // if it was added as outstanding and the send failed, then
260 outstandingReq
.erase(pkt
->req
);
262 DPRINTF(Bus
, "recvTiming: src %s %s 0x%x RETRY\n",
263 src_port
->name(), pkt
->cmdString(), pkt
->getAddr());
265 addToRetryList(src_port
);
266 occupyBus(headerFinishTime
);
271 // the packet is a normal response to a request that we should
272 // have seen passing through the bus
273 assert(outstandingReq
.find(pkt
->req
) != outstandingReq
.end());
275 // remove it as outstanding
276 outstandingReq
.erase(pkt
->req
);
278 // send the packet to the destination through one of our slave
279 // ports, as determined by the destination field
280 bool success M5_VAR_USED
= slavePorts
[pkt
->getDest()]->sendTiming(pkt
);
282 // currently it is illegal to block responses... can lead to
287 succeededTiming(packetFinishTime
);
293 Bus::recvTimingSnoop(PacketPtr pkt
)
296 Packet::NodeID src_id
= pkt
->getSrc();
298 if (pkt
->isRequest()) {
299 DPRINTF(Bus
, "recvTimingSnoop: src %d %s 0x%x\n",
300 src_id
, pkt
->cmdString(), pkt
->getAddr());
302 // the packet is an express snoop request and should be
303 // broadcasted to our snoopers
304 assert(pkt
->isExpressSnoop());
306 // forward to all snoopers
307 forwardTiming(pkt
, Port::INVALID_PORT_ID
);
309 // a snoop request came from a connected slave device (one of
310 // our master ports), and if it is not coming from the slave
311 // device responsible for the address range something is
312 // wrong, hence there is nothing further to do as the packet
313 // would be going back to where it came from
314 assert(src_id
== findPort(pkt
->getAddr()));
316 // this is an express snoop and is never forced to retry
321 // determine the source port based on the id
322 SlavePort
* src_port
= slavePorts
[src_id
];
324 if (isOccupied(pkt
, src_port
)) {
325 DPRINTF(Bus
, "recvTimingSnoop: src %s %s 0x%x BUSY\n",
326 src_port
->name(), pkt
->cmdString(), pkt
->getAddr());
330 DPRINTF(Bus
, "recvTimingSnoop: src %s %s 0x%x\n",
331 src_port
->name(), pkt
->cmdString(), pkt
->getAddr());
333 // get the destination from the packet
334 Packet::NodeID dest
= pkt
->getDest();
336 // responses are never express snoops
337 assert(!pkt
->isExpressSnoop());
339 calcPacketTiming(pkt
);
340 Tick packetFinishTime
= pkt
->finishTime
;
342 // determine if the response is from a snoop request we
343 // created as the result of a normal request (in which case it
344 // should be in the outstandingReq), or if we merely forwarded
345 // someone else's snoop request
346 if (outstandingReq
.find(pkt
->req
) == outstandingReq
.end()) {
347 // this is a snoop response to a snoop request we
348 // forwarded, e.g. coming from the L1 and going to the L2
349 // this should be forwarded as a snoop response
350 bool success M5_VAR_USED
= masterPorts
[dest
]->sendTimingSnoop(pkt
);
353 // we got a snoop response on one of our slave ports,
354 // i.e. from a coherent master connected to the bus, and
355 // since we created the snoop request as part of
356 // recvTiming, this should now be a normal response again
357 outstandingReq
.erase(pkt
->req
);
359 // this is a snoop response from a coherent master, with a
360 // destination field set on its way through the bus as
361 // request, hence it should never go back to where the
362 // snoop response came from, but instead to where the
363 // original request came from
364 assert(src_id
!= dest
);
366 // as a normal response, it should go back to a master
367 // through one of our slave ports
368 bool success M5_VAR_USED
= slavePorts
[dest
]->sendTiming(pkt
);
370 // currently it is illegal to block responses... can lead
375 succeededTiming(packetFinishTime
);
382 Bus::succeededTiming(Tick busy_time
)
384 // occupy the bus accordingly
385 occupyBus(busy_time
);
387 // if a retrying port succeeded, also take it off the retry list
389 DPRINTF(Bus
, "Remove retry from list %s\n",
390 retryList
.front()->name());
391 retryList
.pop_front();
397 Bus::forwardTiming(PacketPtr pkt
, int exclude_slave_port_id
)
399 for (SlavePortIter s
= snoopPorts
.begin(); s
!= snoopPorts
.end(); ++s
) {
401 // we could have gotten this request from a snooping master
402 // (corresponding to our own slave port that is also in
403 // snoopPorts) and should not send it back to where it came
405 if (exclude_slave_port_id
== Port::INVALID_PORT_ID
||
406 p
->getId() != exclude_slave_port_id
) {
407 // cache is not allowed to refuse snoop
408 bool success M5_VAR_USED
= p
->sendTimingSnoop(pkt
);
417 // releasing the bus means we should now be idle
418 assert(curTick() >= tickNextIdle
);
420 // bus is now idle, so if someone is waiting we can retry
421 if (!retryList
.empty()) {
422 // note that we block (return false on recvTiming) both
423 // because the bus is busy and because the destination is
424 // busy, and in the latter case the bus may be released before
425 // we see a retry from the destination
429 //If we weren't able to drain before, we might be able to now.
430 if (drainEvent
&& retryList
.empty() && curTick() >= tickNextIdle
) {
431 drainEvent
->process();
432 // Clear the drain event once we're done with it.
440 // this should never be called with an empty retry list
441 assert(!retryList
.empty());
443 // send a retry to the port at the head of the retry list
446 // note that we might have blocked on the receiving port being
447 // busy (rather than the bus itself) and now call retry before the
448 // destination called retry on the bus
449 retryList
.front()->sendRetry();
451 // If inRetry is still true, sendTiming wasn't called in zero time
452 // (e.g. the cache does this)
454 retryList
.pop_front();
457 //Bring tickNextIdle up to the present
458 while (tickNextIdle
< curTick())
459 tickNextIdle
+= clock
;
461 //Burn a cycle for the missed grant.
462 tickNextIdle
+= clock
;
464 reschedule(busIdleEvent
, tickNextIdle
, true);
469 Bus::recvRetry(Port::PortId id
)
471 // we got a retry from a peer that we tried to send something to
472 // and failed, but we sent it on the account of someone else, and
473 // that source port should be on our retry list, however if the
474 // bus is released before this happens and the retry (from the bus
475 // point of view) is successful then this no longer holds and we
476 // could in fact have an empty retry list
477 if (retryList
.empty())
480 // if the bus isn't busy
481 if (curTick() >= tickNextIdle
) {
482 // note that we do not care who told us to retry at the moment, we
483 // merely let the first one on the retry list go
489 Bus::findPort(Addr addr
)
491 /* An interval tree would be a better way to do this. --ali. */
494 dest_id
= checkPortCache(addr
);
495 if (dest_id
!= Port::INVALID_PORT_ID
)
498 // Check normal port ranges
499 PortIter i
= portMap
.find(RangeSize(addr
,1));
500 if (i
!= portMap
.end()) {
502 updatePortCache(dest_id
, i
->first
.start
, i
->first
.end
);
506 // Check if this matches the default range
507 if (useDefaultRange
) {
508 AddrRangeIter a_end
= defaultRange
.end();
509 for (AddrRangeIter i
= defaultRange
.begin(); i
!= a_end
; i
++) {
511 DPRINTF(Bus
, " found addr %#llx on default\n", addr
);
512 return defaultPortId
;
515 } else if (defaultPortId
!= Port::INVALID_PORT_ID
) {
516 DPRINTF(Bus
, "Unable to find destination for addr %#llx, "
517 "will use default port\n", addr
);
518 return defaultPortId
;
521 // we should use the range for the default port and it did not
522 // match, or the default port is not set
523 fatal("Unable to find destination for addr %#llx on bus %s\n", addr
,
528 Bus::recvAtomic(PacketPtr pkt
)
530 DPRINTF(Bus
, "recvAtomic: packet src %s addr 0x%x cmd %s\n",
531 slavePorts
[pkt
->getSrc()]->name(), pkt
->getAddr(),
534 // we should always see a request routed based on the address
535 assert(pkt
->isRequest());
537 // forward to all snoopers but the source
538 std::pair
<MemCmd
, Tick
> snoop_result
= forwardAtomic(pkt
, pkt
->getSrc());
539 MemCmd snoop_response_cmd
= snoop_result
.first
;
540 Tick snoop_response_latency
= snoop_result
.second
;
542 // even if we had a snoop response, we must continue and also
543 // perform the actual request at the destination
544 int dest_id
= findPort(pkt
->getAddr());
546 // forward the request to the appropriate destination
547 Tick response_latency
= masterPorts
[dest_id
]->sendAtomic(pkt
);
549 // if we got a response from a snooper, restore it here
550 if (snoop_response_cmd
!= MemCmd::InvalidCmd
) {
551 // no one else should have responded
552 assert(!pkt
->isResponse());
553 pkt
->cmd
= snoop_response_cmd
;
554 response_latency
= snoop_response_latency
;
557 pkt
->finishTime
= curTick() + response_latency
;
558 return response_latency
;
562 Bus::recvAtomicSnoop(PacketPtr pkt
)
564 DPRINTF(Bus
, "recvAtomicSnoop: packet src %s addr 0x%x cmd %s\n",
565 masterPorts
[pkt
->getSrc()]->name(), pkt
->getAddr(),
568 // we should always see a request routed based on the address
569 assert(pkt
->isRequest());
571 // forward to all snoopers
572 std::pair
<MemCmd
, Tick
> snoop_result
=
573 forwardAtomic(pkt
, Port::INVALID_PORT_ID
);
574 MemCmd snoop_response_cmd
= snoop_result
.first
;
575 Tick snoop_response_latency
= snoop_result
.second
;
577 if (snoop_response_cmd
!= MemCmd::InvalidCmd
)
578 pkt
->cmd
= snoop_response_cmd
;
580 pkt
->finishTime
= curTick() + snoop_response_latency
;
581 return snoop_response_latency
;
584 std::pair
<MemCmd
, Tick
>
585 Bus::forwardAtomic(PacketPtr pkt
, int exclude_slave_port_id
)
587 // the packet may be changed on snoops, record the original source
588 // and command to enable us to restore it between snoops so that
589 // additional snoops can take place properly
590 Packet::NodeID orig_src_id
= pkt
->getSrc();
591 MemCmd orig_cmd
= pkt
->cmd
;
592 MemCmd snoop_response_cmd
= MemCmd::InvalidCmd
;
593 Tick snoop_response_latency
= 0;
595 for (SlavePortIter s
= snoopPorts
.begin(); s
!= snoopPorts
.end(); ++s
) {
597 // we could have gotten this request from a snooping master
598 // (corresponding to our own slave port that is also in
599 // snoopPorts) and should not send it back to where it came
601 if (exclude_slave_port_id
== Port::INVALID_PORT_ID
||
602 p
->getId() != exclude_slave_port_id
) {
603 Tick latency
= p
->sendAtomicSnoop(pkt
);
604 // in contrast to a functional access, we have to keep on
605 // going as all snoopers must be updated even if we get a
607 if (pkt
->isResponse()) {
608 // response from snoop agent
609 assert(pkt
->cmd
!= orig_cmd
);
610 assert(pkt
->memInhibitAsserted());
611 // should only happen once
612 assert(snoop_response_cmd
== MemCmd::InvalidCmd
);
613 // save response state
614 snoop_response_cmd
= pkt
->cmd
;
615 snoop_response_latency
= latency
;
616 // restore original packet state for remaining snoopers
618 pkt
->setSrc(orig_src_id
);
624 // the packet is restored as part of the loop and any potential
625 // snoop response is part of the returned pair
626 return std::make_pair(snoop_response_cmd
, snoop_response_latency
);
630 Bus::recvFunctional(PacketPtr pkt
)
632 if (!pkt
->isPrint()) {
633 // don't do DPRINTFs on PrintReq as it clutters up the output
635 "recvFunctional: packet src %s addr 0x%x cmd %s\n",
636 slavePorts
[pkt
->getSrc()]->name(), pkt
->getAddr(),
640 // we should always see a request routed based on the address
641 assert(pkt
->isRequest());
643 // forward to all snoopers but the source
644 forwardFunctional(pkt
, pkt
->getSrc());
646 // there is no need to continue if the snooping has found what we
647 // were looking for and the packet is already a response
648 if (!pkt
->isResponse()) {
649 int dest_id
= findPort(pkt
->getAddr());
651 masterPorts
[dest_id
]->sendFunctional(pkt
);
656 Bus::recvFunctionalSnoop(PacketPtr pkt
)
658 if (!pkt
->isPrint()) {
659 // don't do DPRINTFs on PrintReq as it clutters up the output
661 "recvFunctionalSnoop: packet src %s addr 0x%x cmd %s\n",
662 masterPorts
[pkt
->getSrc()]->name(), pkt
->getAddr(),
666 // we should always see a request routed based on the address
667 assert(pkt
->isRequest());
669 // forward to all snoopers
670 forwardFunctional(pkt
, Port::INVALID_PORT_ID
);
674 Bus::forwardFunctional(PacketPtr pkt
, int exclude_slave_port_id
)
676 for (SlavePortIter s
= snoopPorts
.begin(); s
!= snoopPorts
.end(); ++s
) {
678 // we could have gotten this request from a snooping master
679 // (corresponding to our own slave port that is also in
680 // snoopPorts) and should not send it back to where it came
682 if (exclude_slave_port_id
== Port::INVALID_PORT_ID
||
683 p
->getId() != exclude_slave_port_id
)
684 p
->sendFunctionalSnoop(pkt
);
686 // if we get a response we are done
687 if (pkt
->isResponse()) {
693 /** Function called by the port when the bus is receiving a range change.*/
695 Bus::recvRangeChange(Port::PortId id
)
697 AddrRangeList ranges
;
700 if (inRecvRangeChange
.count(id
))
702 inRecvRangeChange
.insert(id
);
704 DPRINTF(BusAddrRanges
, "received RangeChange from device id %d\n", id
);
707 if (id
== defaultPortId
) {
708 defaultRange
.clear();
709 // Only try to update these ranges if the user set a default responder.
710 if (useDefaultRange
) {
711 AddrRangeList ranges
=
712 masterPorts
[id
]->getSlavePort().getAddrRanges();
713 for(iter
= ranges
.begin(); iter
!= ranges
.end(); iter
++) {
714 defaultRange
.push_back(*iter
);
715 DPRINTF(BusAddrRanges
, "Adding range %#llx - %#llx for default range\n",
716 iter
->start
, iter
->end
);
721 assert(id
< masterPorts
.size() && id
>= 0);
722 MasterPort
*port
= masterPorts
[id
];
724 // Clean out any previously existent ids
725 for (PortIter portIter
= portMap
.begin();
726 portIter
!= portMap
.end(); ) {
727 if (portIter
->second
== id
)
728 portMap
.erase(portIter
++);
733 ranges
= port
->getSlavePort().getAddrRanges();
735 for (iter
= ranges
.begin(); iter
!= ranges
.end(); iter
++) {
736 DPRINTF(BusAddrRanges
, "Adding range %#llx - %#llx for id %d\n",
737 iter
->start
, iter
->end
, id
);
738 if (portMap
.insert(*iter
, id
) == portMap
.end()) {
739 int conflict_id
= portMap
.find(*iter
)->second
;
740 fatal("%s has two ports with same range:\n\t%s\n\t%s\n",
741 name(), masterPorts
[id
]->getSlavePort().name(),
742 masterPorts
[conflict_id
]->getSlavePort().name());
746 DPRINTF(BusAddrRanges
, "port list has %d entries\n", portMap
.size());
748 // tell all our neighbouring master ports that our address range
750 for (SlavePortConstIter p
= slavePorts
.begin(); p
!= slavePorts
.end();
752 (*p
)->sendRangeChange();
754 inRecvRangeChange
.erase(id
);
758 Bus::getAddrRanges(Port::PortId id
)
760 AddrRangeList ranges
;
762 DPRINTF(BusAddrRanges
, "received address range request, returning:\n");
764 for (AddrRangeIter dflt_iter
= defaultRange
.begin();
765 dflt_iter
!= defaultRange
.end(); dflt_iter
++) {
766 ranges
.push_back(*dflt_iter
);
767 DPRINTF(BusAddrRanges
, " -- Dflt: %#llx : %#llx\n",dflt_iter
->start
,
770 for (PortIter portIter
= portMap
.begin();
771 portIter
!= portMap
.end(); portIter
++) {
773 for (AddrRangeIter dflt_iter
= defaultRange
.begin();
774 dflt_iter
!= defaultRange
.end(); dflt_iter
++) {
775 if ((portIter
->first
.start
< dflt_iter
->start
&&
776 portIter
->first
.end
>= dflt_iter
->start
) ||
777 (portIter
->first
.start
< dflt_iter
->end
&&
778 portIter
->first
.end
>= dflt_iter
->end
))
779 fatal("Devices can not set ranges that itersect the default set\
780 but are not a subset of the default set.\n");
781 if (portIter
->first
.start
>= dflt_iter
->start
&&
782 portIter
->first
.end
<= dflt_iter
->end
) {
784 DPRINTF(BusAddrRanges
, " -- %#llx : %#llx is a SUBSET\n",
785 portIter
->first
.start
, portIter
->first
.end
);
788 if (portIter
->second
!= id
&& !subset
) {
789 ranges
.push_back(portIter
->first
);
790 DPRINTF(BusAddrRanges
, " -- %#llx : %#llx\n",
791 portIter
->first
.start
, portIter
->first
.end
);
799 Bus::isSnooping(Port::PortId id
) const
801 // in essence, answer the question if there are snooping ports
802 return !snoopPorts
.empty();
806 Bus::findBlockSize(Port::PortId id
)
808 if (cachedBlockSizeValid
)
809 return cachedBlockSize
;
813 PortIter p_end
= portMap
.end();
814 for (PortIter p_iter
= portMap
.begin(); p_iter
!= p_end
; p_iter
++) {
815 unsigned tmp_bs
= masterPorts
[p_iter
->second
]->peerBlockSize();
820 for (SlavePortConstIter s
= snoopPorts
.begin(); s
!= snoopPorts
.end();
822 unsigned tmp_bs
= (*s
)->peerBlockSize();
827 max_bs
= defaultBlockSize
;
830 warn_once("Blocksize found to not be 64... hmm... probably not.\n");
831 cachedBlockSize
= max_bs
;
832 cachedBlockSizeValid
= true;
838 Bus::drain(Event
* de
)
840 //We should check that we're not "doing" anything, and that noone is
841 //waiting. We might be idle but have someone waiting if the device we
842 //contacted for a retry didn't actually retry.
843 if (!retryList
.empty() || (curTick() < tickNextIdle
&&
844 busIdleEvent
.scheduled())) {
854 if (tickNextIdle
< curTick())
855 tickNextIdle
= (curTick() / clock
) * clock
+ clock
;
861 return new Bus(this);