xbar.cc revision 9564
12207SN/A/*
22207SN/A * Copyright (c) 2011-2013 ARM Limited
32207SN/A * All rights reserved
42207SN/A *
52207SN/A * The license below extends only to copyright in the software and shall
62207SN/A * not be construed as granting a license to any other intellectual
72207SN/A * property including but not limited to intellectual property relating
82207SN/A * to a hardware implementation of the functionality of the software
92207SN/A * licensed hereunder.  You may use the software subject to the license
102207SN/A * terms below provided that you ensure that this notice is replicated
112207SN/A * unmodified and in its entirety in all distributions of the software,
122207SN/A * modified or unmodified, in source code or in binary form.
132207SN/A *
142207SN/A * Copyright (c) 2006 The Regents of The University of Michigan
152207SN/A * All rights reserved.
162207SN/A *
172207SN/A * Redistribution and use in source and binary forms, with or without
182207SN/A * modification, are permitted provided that the following conditions are
192207SN/A * met: redistributions of source code must retain the above copyright
202207SN/A * notice, this list of conditions and the following disclaimer;
212207SN/A * redistributions in binary form must reproduce the above copyright
222207SN/A * notice, this list of conditions and the following disclaimer in the
232207SN/A * documentation and/or other materials provided with the distribution;
242207SN/A * neither the name of the copyright holders nor the names of its
252207SN/A * contributors may be used to endorse or promote products derived from
262207SN/A * this software without specific prior written permission.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292665Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302207SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312207SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322972Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332207SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342454SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
355759Shsul@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362454SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372680Sktlim@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
385759Shsul@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
395759Shsul@eecs.umich.edu *
402474SN/A * Authors: Ali Saidi
412207SN/A *          Andreas Hansson
422474SN/A *          William Wang
432474SN/A */
442474SN/A
455569Snate@binkert.org/**
465569Snate@binkert.org * @file
475154Sgblack@eecs.umich.edu * Definition of a bus object.
482474SN/A */
492474SN/A
502474SN/A#include "base/misc.hh"
512474SN/A#include "base/trace.hh"
522474SN/A#include "debug/Bus.hh"
532474SN/A#include "debug/BusAddrRanges.hh"
542474SN/A#include "debug/Drain.hh"
552474SN/A#include "mem/bus.hh"
562474SN/A
572474SN/ABaseBus::BaseBus(const BaseBusParams *p)
582474SN/A    : MemObject(p),
592474SN/A      headerCycles(p->header_cycles), width(p->width),
602474SN/A      gotAddrRanges(p->port_default_connection_count +
612474SN/A                          p->port_master_connection_count, false),
622474SN/A      gotAllAddrRanges(false), defaultPortID(InvalidPortID),
632474SN/A      useDefaultRange(p->use_default_range),
642474SN/A      blockSize(p->block_size)
652474SN/A{}
665759Shsul@eecs.umich.edu
675759Shsul@eecs.umich.eduBaseBus::~BaseBus()
685759Shsul@eecs.umich.edu{
695759Shsul@eecs.umich.edu    for (MasterPortIter m = masterPorts.begin(); m != masterPorts.end();
705771Shsul@eecs.umich.edu         ++m) {
715759Shsul@eecs.umich.edu        delete *m;
725759Shsul@eecs.umich.edu    }
735759Shsul@eecs.umich.edu
745759Shsul@eecs.umich.edu    for (SlavePortIter s = slavePorts.begin(); s != slavePorts.end();
755759Shsul@eecs.umich.edu         ++s) {
765759Shsul@eecs.umich.edu        delete *s;
775759Shsul@eecs.umich.edu    }
785759Shsul@eecs.umich.edu}
795759Shsul@eecs.umich.edu
805759Shsul@eecs.umich.eduvoid
815759Shsul@eecs.umich.eduBaseBus::init()
825759Shsul@eecs.umich.edu{
835759Shsul@eecs.umich.edu    // determine the maximum peer block size, look at both the
845759Shsul@eecs.umich.edu    // connected master and slave modules
855759Shsul@eecs.umich.edu    uint32_t peer_block_size = 0;
865759Shsul@eecs.umich.edu
875759Shsul@eecs.umich.edu    for (MasterPortConstIter m = masterPorts.begin(); m != masterPorts.end();
885759Shsul@eecs.umich.edu         ++m) {
895759Shsul@eecs.umich.edu        peer_block_size = std::max((*m)->peerBlockSize(), peer_block_size);
905759Shsul@eecs.umich.edu    }
915759Shsul@eecs.umich.edu
925759Shsul@eecs.umich.edu    for (SlavePortConstIter s = slavePorts.begin(); s != slavePorts.end();
935759Shsul@eecs.umich.edu         ++s) {
945759Shsul@eecs.umich.edu        peer_block_size = std::max((*s)->peerBlockSize(), peer_block_size);
955759Shsul@eecs.umich.edu    }
965759Shsul@eecs.umich.edu
975759Shsul@eecs.umich.edu    // if the peers do not have a block size, use the default value
985759Shsul@eecs.umich.edu    // set through the bus parameters
995759Shsul@eecs.umich.edu    if (peer_block_size != 0)
1005759Shsul@eecs.umich.edu        blockSize = peer_block_size;
1015759Shsul@eecs.umich.edu
1025759Shsul@eecs.umich.edu    // check if the block size is a value known to work
1035759Shsul@eecs.umich.edu    if (!(blockSize == 16 || blockSize == 32 || blockSize == 64 ||
1045759Shsul@eecs.umich.edu          blockSize == 128))
1055759Shsul@eecs.umich.edu        warn_once("Block size is neither 16, 32, 64 or 128 bytes.\n");
1065759Shsul@eecs.umich.edu}
1075759Shsul@eecs.umich.edu
1085759Shsul@eecs.umich.eduBaseMasterPort &
1095759Shsul@eecs.umich.eduBaseBus::getMasterPort(const std::string &if_name, PortID idx)
1105759Shsul@eecs.umich.edu{
1115759Shsul@eecs.umich.edu    if (if_name == "master" && idx < masterPorts.size()) {
1125759Shsul@eecs.umich.edu        // the master port index translates directly to the vector position
1135759Shsul@eecs.umich.edu        return *masterPorts[idx];
1145759Shsul@eecs.umich.edu    } else  if (if_name == "default") {
1155759Shsul@eecs.umich.edu        return *masterPorts[defaultPortID];
1165759Shsul@eecs.umich.edu    } else {
1175759Shsul@eecs.umich.edu        return MemObject::getMasterPort(if_name, idx);
1185759Shsul@eecs.umich.edu    }
1195759Shsul@eecs.umich.edu}
1205759Shsul@eecs.umich.edu
1215759Shsul@eecs.umich.eduBaseSlavePort &
1225759Shsul@eecs.umich.eduBaseBus::getSlavePort(const std::string &if_name, PortID idx)
1235759Shsul@eecs.umich.edu{
1245759Shsul@eecs.umich.edu    if (if_name == "slave" && idx < slavePorts.size()) {
1255759Shsul@eecs.umich.edu        // the slave port index translates directly to the vector position
1265759Shsul@eecs.umich.edu        return *slavePorts[idx];
1275759Shsul@eecs.umich.edu    } else {
1285759Shsul@eecs.umich.edu        return MemObject::getSlavePort(if_name, idx);
1295759Shsul@eecs.umich.edu    }
1305759Shsul@eecs.umich.edu}
1315759Shsul@eecs.umich.edu
1325759Shsul@eecs.umich.eduvoid
1335759Shsul@eecs.umich.eduBaseBus::calcPacketTiming(PacketPtr pkt)
1345759Shsul@eecs.umich.edu{
1355759Shsul@eecs.umich.edu    // the bus will be called at a time that is not necessarily
1365759Shsul@eecs.umich.edu    // coinciding with its own clock, so start by determining how long
1375759Shsul@eecs.umich.edu    // until the next clock edge (could be zero)
1385759Shsul@eecs.umich.edu    Tick offset = nextCycle() - curTick();
1395759Shsul@eecs.umich.edu
1405759Shsul@eecs.umich.edu    // determine how many cycles are needed to send the data
1415759Shsul@eecs.umich.edu    unsigned dataCycles = pkt->hasData() ? divCeil(pkt->getSize(), width) : 0;
1425759Shsul@eecs.umich.edu
1435759Shsul@eecs.umich.edu    // before setting the bus delay fields of the packet, ensure that
1445759Shsul@eecs.umich.edu    // the delay from any previous bus has been accounted for
1455759Shsul@eecs.umich.edu    if (pkt->busFirstWordDelay != 0 || pkt->busLastWordDelay != 0)
1465759Shsul@eecs.umich.edu        panic("Packet %s already has bus delay (%d, %d) that should be "
1475759Shsul@eecs.umich.edu              "accounted for.\n", pkt->cmdString(), pkt->busFirstWordDelay,
1485759Shsul@eecs.umich.edu              pkt->busLastWordDelay);
1495759Shsul@eecs.umich.edu
1505759Shsul@eecs.umich.edu    // The first word will be delivered on the cycle after the header.
1515759Shsul@eecs.umich.edu    pkt->busFirstWordDelay = (headerCycles + 1) * clockPeriod() + offset;
1525759Shsul@eecs.umich.edu
1535759Shsul@eecs.umich.edu    // Note that currently busLastWordDelay can be smaller than
1545759Shsul@eecs.umich.edu    // busFirstWordDelay if the packet has no data
1555759Shsul@eecs.umich.edu    pkt->busLastWordDelay = (headerCycles + dataCycles) * clockPeriod() +
1565759Shsul@eecs.umich.edu        offset;
1575759Shsul@eecs.umich.edu}
1585759Shsul@eecs.umich.edu
1595759Shsul@eecs.umich.edutemplate <typename PortClass>
1605759Shsul@eecs.umich.eduBaseBus::Layer<PortClass>::Layer(BaseBus& _bus, const std::string& _name) :
1615759Shsul@eecs.umich.edu    Drainable(),
1625759Shsul@eecs.umich.edu    bus(_bus), _name(_name), state(IDLE), drainManager(NULL),
1635759Shsul@eecs.umich.edu    releaseEvent(this)
1645759Shsul@eecs.umich.edu{
1655759Shsul@eecs.umich.edu}
1665759Shsul@eecs.umich.edu
1675759Shsul@eecs.umich.edutemplate <typename PortClass>
1685759Shsul@eecs.umich.eduvoid BaseBus::Layer<PortClass>::occupyLayer(Tick until)
1695759Shsul@eecs.umich.edu{
1705759Shsul@eecs.umich.edu    // ensure the state is busy or in retry and never idle at this
1715759Shsul@eecs.umich.edu    // point, as the bus should transition from idle as soon as it has
1725759Shsul@eecs.umich.edu    // decided to forward the packet to prevent any follow-on calls to
1735759Shsul@eecs.umich.edu    // sendTiming seeing an unoccupied bus
1745759Shsul@eecs.umich.edu    assert(state != IDLE);
1755759Shsul@eecs.umich.edu
1765759Shsul@eecs.umich.edu    // note that we do not change the bus state here, if we are going
1775759Shsul@eecs.umich.edu    // from idle to busy it is handled by tryTiming, and if we
1785759Shsul@eecs.umich.edu    // are in retry we should remain in retry such that
1792474SN/A    // succeededTiming still sees the accurate state
1802474SN/A
1815183Ssaidi@eecs.umich.edu    // until should never be 0 as express snoops never occupy the bus
1825183Ssaidi@eecs.umich.edu    assert(until != 0);
1835183Ssaidi@eecs.umich.edu    bus.schedule(releaseEvent, until);
1845759Shsul@eecs.umich.edu
1855759Shsul@eecs.umich.edu    DPRINTF(BaseBus, "The bus is now busy from tick %d to %d\n",
1862474SN/A            curTick(), until);
1872474SN/A}
1885713Shsul@eecs.umich.edu
1895713Shsul@eecs.umich.edutemplate <typename PortClass>
1905713Shsul@eecs.umich.edubool
1915713Shsul@eecs.umich.eduBaseBus::Layer<PortClass>::tryTiming(PortClass* port)
1924997Sgblack@eecs.umich.edu{
1935713Shsul@eecs.umich.edu    // first we see if the bus is busy, next we check if we are in a
1944997Sgblack@eecs.umich.edu    // retry with a port other than the current one
1955713Shsul@eecs.umich.edu    if (state == BUSY || (state == RETRY && port != retryList.front())) {
1962474SN/A        // put the port at the end of the retry list
1972474SN/A        retryList.push_back(port);
198        return false;
199    }
200
201    // update the state which is shared for request, response and
202    // snoop responses, if we were idle we are now busy, if we are in
203    // a retry, then do not change
204    if (state == IDLE)
205        state = BUSY;
206
207    return true;
208}
209
210template <typename PortClass>
211void
212BaseBus::Layer<PortClass>::succeededTiming(Tick busy_time)
213{
214    // if a retrying port succeeded, also take it off the retry list
215    if (state == RETRY) {
216        DPRINTF(BaseBus, "Remove retry from list %s\n",
217                retryList.front()->name());
218        retryList.pop_front();
219        state = BUSY;
220    }
221
222    // we should either have gone from idle to busy in the
223    // tryTiming test, or just gone from a retry to busy
224    assert(state == BUSY);
225
226    // occupy the bus accordingly
227    occupyLayer(busy_time);
228}
229
230template <typename PortClass>
231void
232BaseBus::Layer<PortClass>::failedTiming(PortClass* port, Tick busy_time)
233{
234    // if we are not in a retry, i.e. busy (but never idle), or we are
235    // in a retry but not for the current port, then add the port at
236    // the end of the retry list
237    if (state != RETRY || port != retryList.front()) {
238        retryList.push_back(port);
239    }
240
241    // even if we retried the current one and did not succeed,
242    // we are no longer retrying but instead busy
243    state = BUSY;
244
245    // occupy the bus accordingly
246    occupyLayer(busy_time);
247}
248
249template <typename PortClass>
250void
251BaseBus::Layer<PortClass>::releaseLayer()
252{
253    // releasing the bus means we should now be idle
254    assert(state == BUSY);
255    assert(!releaseEvent.scheduled());
256
257    // update the state
258    state = IDLE;
259
260    // bus is now idle, so if someone is waiting we can retry
261    if (!retryList.empty()) {
262        // note that we block (return false on recvTiming) both
263        // because the bus is busy and because the destination is
264        // busy, and in the latter case the bus may be released before
265        // we see a retry from the destination
266        retryWaiting();
267    } else if (drainManager) {
268        DPRINTF(Drain, "Bus done draining, signaling drain manager\n");
269        //If we weren't able to drain before, do it now.
270        drainManager->signalDrainDone();
271        // Clear the drain event once we're done with it.
272        drainManager = NULL;
273    }
274}
275
276template <typename PortClass>
277void
278BaseBus::Layer<PortClass>::retryWaiting()
279{
280    // this should never be called with an empty retry list
281    assert(!retryList.empty());
282
283    // we always go to retrying from idle
284    assert(state == IDLE);
285
286    // update the state which is shared for request, response and
287    // snoop responses
288    state = RETRY;
289
290    // note that we might have blocked on the receiving port being
291    // busy (rather than the bus itself) and now call retry before the
292    // destination called retry on the bus
293    retryList.front()->sendRetry();
294
295    // If the bus is still in the retry state, sendTiming wasn't
296    // called in zero time (e.g. the cache does this)
297    if (state == RETRY) {
298        retryList.pop_front();
299
300        //Burn a cycle for the missed grant.
301
302        // update the state which is shared for request, response and
303        // snoop responses
304        state = BUSY;
305
306        // occupy the bus layer until the next cycle ends
307        occupyLayer(bus.clockEdge(Cycles(1)));
308    }
309}
310
311template <typename PortClass>
312void
313BaseBus::Layer<PortClass>::recvRetry()
314{
315    // we got a retry from a peer that we tried to send something to
316    // and failed, but we sent it on the account of someone else, and
317    // that source port should be on our retry list, however if the
318    // bus layer is released before this happens and the retry (from
319    // the bus point of view) is successful then this no longer holds
320    // and we could in fact have an empty retry list
321    if (retryList.empty())
322        return;
323
324    // if the bus layer is idle
325    if (state == IDLE) {
326        // note that we do not care who told us to retry at the moment, we
327        // merely let the first one on the retry list go
328        retryWaiting();
329    }
330}
331
332PortID
333BaseBus::findPort(Addr addr)
334{
335    // we should never see any address lookups before we've got the
336    // ranges of all connected slave modules
337    assert(gotAllAddrRanges);
338
339    // Check the cache
340    PortID dest_id = checkPortCache(addr);
341    if (dest_id != InvalidPortID)
342        return dest_id;
343
344    // Check the address map interval tree
345    PortMapConstIter i = portMap.find(addr);
346    if (i != portMap.end()) {
347        dest_id = i->second;
348        updatePortCache(dest_id, i->first);
349        return dest_id;
350    }
351
352    // Check if this matches the default range
353    if (useDefaultRange) {
354        if (defaultRange.contains(addr)) {
355            DPRINTF(BusAddrRanges, "  found addr %#llx on default\n",
356                    addr);
357            return defaultPortID;
358        }
359    } else if (defaultPortID != InvalidPortID) {
360        DPRINTF(BusAddrRanges, "Unable to find destination for addr %#llx, "
361                "will use default port\n", addr);
362        return defaultPortID;
363    }
364
365    // we should use the range for the default port and it did not
366    // match, or the default port is not set
367    fatal("Unable to find destination for addr %#llx on bus %s\n", addr,
368          name());
369}
370
371/** Function called by the port when the bus is receiving a range change.*/
372void
373BaseBus::recvRangeChange(PortID master_port_id)
374{
375    DPRINTF(BusAddrRanges, "Received range change from slave port %s\n",
376            masterPorts[master_port_id]->getSlavePort().name());
377
378    // remember that we got a range from this master port and thus the
379    // connected slave module
380    gotAddrRanges[master_port_id] = true;
381
382    // update the global flag
383    if (!gotAllAddrRanges) {
384        // take a logical AND of all the ports and see if we got
385        // ranges from everyone
386        gotAllAddrRanges = true;
387        std::vector<bool>::const_iterator r = gotAddrRanges.begin();
388        while (gotAllAddrRanges &&  r != gotAddrRanges.end()) {
389            gotAllAddrRanges &= *r++;
390        }
391        if (gotAllAddrRanges)
392            DPRINTF(BusAddrRanges, "Got address ranges from all slaves\n");
393    }
394
395    // note that we could get the range from the default port at any
396    // point in time, and we cannot assume that the default range is
397    // set before the other ones are, so we do additional checks once
398    // all ranges are provided
399    if (master_port_id == defaultPortID) {
400        // only update if we are indeed checking ranges for the
401        // default port since the port might not have a valid range
402        // otherwise
403        if (useDefaultRange) {
404            AddrRangeList ranges = masterPorts[master_port_id]->getAddrRanges();
405
406            if (ranges.size() != 1)
407                fatal("Bus %s may only have a single default range",
408                      name());
409
410            defaultRange = ranges.front();
411        }
412    } else {
413        // the ports are allowed to update their address ranges
414        // dynamically, so remove any existing entries
415        if (gotAddrRanges[master_port_id]) {
416            for (PortMapIter p = portMap.begin(); p != portMap.end(); ) {
417                if (p->second == master_port_id)
418                    // erasing invalidates the iterator, so advance it
419                    // before the deletion takes place
420                    portMap.erase(p++);
421                else
422                    p++;
423            }
424        }
425
426        AddrRangeList ranges = masterPorts[master_port_id]->getAddrRanges();
427
428        for (AddrRangeConstIter r = ranges.begin(); r != ranges.end(); ++r) {
429            DPRINTF(BusAddrRanges, "Adding range %s for id %d\n",
430                    r->to_string(), master_port_id);
431            if (portMap.insert(*r, master_port_id) == portMap.end()) {
432                PortID conflict_id = portMap.find(*r)->second;
433                fatal("%s has two ports with same range:\n\t%s\n\t%s\n",
434                      name(),
435                      masterPorts[master_port_id]->getSlavePort().name(),
436                      masterPorts[conflict_id]->getSlavePort().name());
437            }
438        }
439    }
440
441    // if we have received ranges from all our neighbouring slave
442    // modules, go ahead and tell our connected master modules in
443    // turn, this effectively assumes a tree structure of the system
444    if (gotAllAddrRanges) {
445        DPRINTF(BusAddrRanges, "Aggregating bus ranges\n");
446        busRanges.clear();
447
448        // start out with the default range
449        if (useDefaultRange) {
450            if (!gotAddrRanges[defaultPortID])
451                fatal("Bus %s uses default range, but none provided",
452                      name());
453
454            busRanges.push_back(defaultRange);
455            DPRINTF(BusAddrRanges, "-- Adding default %s\n",
456                    defaultRange.to_string());
457        }
458
459        // merge all interleaved ranges and add any range that is not
460        // a subset of the default range
461        std::vector<AddrRange> intlv_ranges;
462        for (AddrRangeMap<PortID>::const_iterator r = portMap.begin();
463             r != portMap.end(); ++r) {
464            // if the range is interleaved then save it for now
465            if (r->first.interleaved()) {
466                // if we already got interleaved ranges that are not
467                // part of the same range, then first do a merge
468                // before we add the new one
469                if (!intlv_ranges.empty() &&
470                    !intlv_ranges.back().mergesWith(r->first)) {
471                    DPRINTF(BusAddrRanges, "-- Merging range from %d ranges\n",
472                            intlv_ranges.size());
473                    AddrRange merged_range(intlv_ranges);
474                    // next decide if we keep the merged range or not
475                    if (!(useDefaultRange &&
476                          merged_range.isSubset(defaultRange))) {
477                        busRanges.push_back(merged_range);
478                        DPRINTF(BusAddrRanges, "-- Adding merged range %s\n",
479                                merged_range.to_string());
480                    }
481                    intlv_ranges.clear();
482                }
483                intlv_ranges.push_back(r->first);
484            } else {
485                // keep the current range if not a subset of the default
486                if (!(useDefaultRange &&
487                      r->first.isSubset(defaultRange))) {
488                    busRanges.push_back(r->first);
489                    DPRINTF(BusAddrRanges, "-- Adding range %s\n",
490                            r->first.to_string());
491                }
492            }
493        }
494
495        // if there is still interleaved ranges waiting to be merged,
496        // go ahead and do it
497        if (!intlv_ranges.empty()) {
498            DPRINTF(BusAddrRanges, "-- Merging range from %d ranges\n",
499                    intlv_ranges.size());
500            AddrRange merged_range(intlv_ranges);
501            if (!(useDefaultRange && merged_range.isSubset(defaultRange))) {
502                busRanges.push_back(merged_range);
503                DPRINTF(BusAddrRanges, "-- Adding merged range %s\n",
504                        merged_range.to_string());
505            }
506        }
507
508        // also check that no range partially overlaps with the
509        // default range, this has to be done after all ranges are set
510        // as there are no guarantees for when the default range is
511        // update with respect to the other ones
512        if (useDefaultRange) {
513            for (AddrRangeConstIter r = busRanges.begin();
514                 r != busRanges.end(); ++r) {
515                // see if the new range is partially
516                // overlapping the default range
517                if (r->intersects(defaultRange) &&
518                    !r->isSubset(defaultRange))
519                    fatal("Range %s intersects the "                    \
520                          "default range of %s but is not a "           \
521                          "subset\n", r->to_string(), name());
522            }
523        }
524
525        // tell all our neighbouring master ports that our address
526        // ranges have changed
527        for (SlavePortConstIter s = slavePorts.begin(); s != slavePorts.end();
528             ++s)
529            (*s)->sendRangeChange();
530    }
531
532    clearPortCache();
533}
534
535AddrRangeList
536BaseBus::getAddrRanges() const
537{
538    // we should never be asked without first having sent a range
539    // change, and the latter is only done once we have all the ranges
540    // of the connected devices
541    assert(gotAllAddrRanges);
542
543    // at the moment, this never happens, as there are no cycles in
544    // the range queries and no devices on the master side of a bus
545    // (CPU, cache, bridge etc) actually care about the ranges of the
546    // ports they are connected to
547
548    DPRINTF(BusAddrRanges, "Received address range request\n");
549
550    return busRanges;
551}
552
553unsigned
554BaseBus::deviceBlockSize() const
555{
556    return blockSize;
557}
558
559template <typename PortClass>
560unsigned int
561BaseBus::Layer<PortClass>::drain(DrainManager *dm)
562{
563    //We should check that we're not "doing" anything, and that noone is
564    //waiting. We might be idle but have someone waiting if the device we
565    //contacted for a retry didn't actually retry.
566    if (!retryList.empty() || state != IDLE) {
567        DPRINTF(Drain, "Bus not drained\n");
568        drainManager = dm;
569        return 1;
570    }
571    return 0;
572}
573
574/**
575 * Bus layer template instantiations. Could be removed with _impl.hh
576 * file, but since there are only two given options (MasterPort and
577 * SlavePort) it seems a bit excessive at this point.
578 */
579template class BaseBus::Layer<SlavePort>;
580template class BaseBus::Layer<MasterPort>;
581