Port: Make getAddrRanges const

This patch makes getAddrRanges const throughout the code base. There
is no reason why it should not be, and making it const prevents adding
any unintentional side-effects.
This commit is contained in:
Andreas Hansson
2012-07-09 12:35:34 -04:00
parent 830391cad9
commit 46d9adb68c
35 changed files with 57 additions and 54 deletions

View File

@@ -443,7 +443,7 @@ Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt)
}
AddrRangeList
Bridge::BridgeSlavePort::getAddrRanges()
Bridge::BridgeSlavePort::getAddrRanges() const
{
return ranges;
}

View File

@@ -276,7 +276,7 @@ class Bridge : public MemObject
/** When receiving a address range request the peer port,
pass it to the bridge. */
virtual AddrRangeList getAddrRanges();
virtual AddrRangeList getAddrRanges() const;
};

View File

@@ -269,7 +269,7 @@ BaseBus::findPort(Addr addr)
return dest_id;
// Check normal port ranges
PortIter i = portMap.find(RangeSize(addr,1));
PortMapConstIter i = portMap.find(RangeSize(addr,1));
if (i != portMap.end()) {
dest_id = i->second;
updatePortCache(dest_id, i->first.start, i->first.end);
@@ -278,8 +278,8 @@ BaseBus::findPort(Addr addr)
// Check if this matches the default range
if (useDefaultRange) {
AddrRangeIter a_end = defaultRange.end();
for (AddrRangeIter i = defaultRange.begin(); i != a_end; i++) {
AddrRangeConstIter a_end = defaultRange.end();
for (AddrRangeConstIter i = defaultRange.begin(); i != a_end; i++) {
if (*i == addr) {
DPRINTF(BusAddrRanges, " found addr %#llx on default\n",
addr);
@@ -332,7 +332,7 @@ BaseBus::recvRangeChange(PortID master_port_id)
MasterPort *port = masterPorts[master_port_id];
// Clean out any previously existent ids
for (PortIter portIter = portMap.begin();
for (PortMapIter portIter = portMap.begin();
portIter != portMap.end(); ) {
if (portIter->second == master_port_id)
portMap.erase(portIter++);
@@ -367,22 +367,22 @@ BaseBus::recvRangeChange(PortID master_port_id)
}
AddrRangeList
BaseBus::getAddrRanges()
BaseBus::getAddrRanges() const
{
AddrRangeList ranges;
DPRINTF(BusAddrRanges, "received address range request, returning:\n");
for (AddrRangeIter dflt_iter = defaultRange.begin();
for (AddrRangeConstIter dflt_iter = defaultRange.begin();
dflt_iter != defaultRange.end(); dflt_iter++) {
ranges.push_back(*dflt_iter);
DPRINTF(BusAddrRanges, " -- Dflt: %#llx : %#llx\n",dflt_iter->start,
dflt_iter->end);
}
for (PortIter portIter = portMap.begin();
for (PortMapConstIter portIter = portMap.begin();
portIter != portMap.end(); portIter++) {
bool subset = false;
for (AddrRangeIter dflt_iter = defaultRange.begin();
for (AddrRangeConstIter dflt_iter = defaultRange.begin();
dflt_iter != defaultRange.end(); dflt_iter++) {
if ((portIter->first.start < dflt_iter->start &&
portIter->first.end >= dflt_iter->start) ||

View File

@@ -85,7 +85,8 @@ class BaseBus : public MemObject
Event * drainEvent;
typedef range_map<Addr, PortID>::iterator PortIter;
typedef range_map<Addr, PortID>::iterator PortMapIter;
typedef range_map<Addr, PortID>::const_iterator PortMapConstIter;
range_map<Addr, PortID> portMap;
AddrRangeList defaultRange;
@@ -187,7 +188,7 @@ class BaseBus : public MemObject
*
* @return a list of non-overlapping address ranges
*/
AddrRangeList getAddrRanges();
AddrRangeList getAddrRanges() const;
/** Calculate the timing parameters for the packet. Updates the
* firstWordTime and finishTime fields of the packet object.

View File

@@ -101,7 +101,7 @@ class Cache : public BaseCache
virtual unsigned deviceBlockSize() const
{ return cache->getBlockSize(); }
virtual AddrRangeList getAddrRanges();
virtual AddrRangeList getAddrRanges() const;
public:

View File

@@ -1588,7 +1588,7 @@ Cache<TagStore>::unserialize(Checkpoint *cp, const std::string &section)
template<class TagStore>
AddrRangeList
Cache<TagStore>::CpuSidePort::getAddrRanges()
Cache<TagStore>::CpuSidePort::getAddrRanges() const
{
return cache->getAddrRanges();
}

View File

@@ -124,7 +124,7 @@ class CoherentBus : public BaseBus
/**
* Return the union of all adress ranges seen by this bus.
*/
virtual AddrRangeList getAddrRanges()
virtual AddrRangeList getAddrRanges() const
{ return bus.getAddrRanges(); }
/**

View File

@@ -345,7 +345,7 @@ CommMonitor::deviceBlockSizeSlave()
}
AddrRangeList
CommMonitor::getAddrRanges()
CommMonitor::getAddrRanges() const
{
// get the address ranges of the connected slave port
return masterPort.getAddrRanges();

View File

@@ -230,7 +230,7 @@ class CommMonitor : public MemObject
return mon.deviceBlockSizeSlave();
}
AddrRangeList getAddrRanges()
AddrRangeList getAddrRanges() const
{
return mon.getAddrRanges();
}
@@ -269,7 +269,7 @@ class CommMonitor : public MemObject
unsigned deviceBlockSizeSlave();
AddrRangeList getAddrRanges();
AddrRangeList getAddrRanges() const;
bool isSnooping() const;

View File

@@ -120,7 +120,7 @@ class NoncoherentBus : public BaseBus
/**
* Return the union of all adress ranges seen by this bus.
*/
virtual AddrRangeList getAddrRanges()
virtual AddrRangeList getAddrRanges() const
{ return bus.getAddrRanges(); }
/**

View File

@@ -64,6 +64,7 @@
typedef std::list<Range<Addr> > AddrRangeList;
typedef std::list<Range<Addr> >::iterator AddrRangeIter;
typedef std::list<Range<Addr> >::const_iterator AddrRangeConstIter;
class MemObject;
@@ -379,7 +380,7 @@ class SlavePort : public Port
*
* @return a list of ranges responded to
*/
virtual AddrRangeList getAddrRanges() = 0;
virtual AddrRangeList getAddrRanges() const = 0;
protected:

View File

@@ -669,7 +669,7 @@ RubyPort::PioPort::sendNextCycle(PacketPtr pkt)
}
AddrRangeList
RubyPort::M5Port::getAddrRanges()
RubyPort::M5Port::getAddrRanges() const
{
// at the moment the assumption is that the master does not care
AddrRangeList ranges;

View File

@@ -86,7 +86,7 @@ class RubyPort : public MemObject
virtual bool recvTimingReq(PacketPtr pkt);
virtual Tick recvAtomic(PacketPtr pkt);
virtual void recvFunctional(PacketPtr pkt);
virtual AddrRangeList getAddrRanges();
virtual AddrRangeList getAddrRanges() const;
private:
bool isPhysMemAddress(Addr addr);

View File

@@ -132,7 +132,7 @@ SimpleMemory::MemoryPort::MemoryPort(const std::string& _name,
{ }
AddrRangeList
SimpleMemory::MemoryPort::getAddrRanges()
SimpleMemory::MemoryPort::getAddrRanges() const
{
AddrRangeList ranges;
ranges.push_back(memory.getAddrRange());

View File

@@ -77,7 +77,7 @@ class SimpleMemory : public AbstractMemory
virtual void recvFunctional(PacketPtr pkt);
virtual AddrRangeList getAddrRanges();
virtual AddrRangeList getAddrRanges() const;
};