From: Andreas Hansson Date: Mon, 9 Jul 2012 16:35:34 +0000 (-0400) Subject: Port: Make getAddrRanges const X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=46d9adb68c96b94ae25bbe92d34e375daf532ece;p=gem5.git 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. --- diff --git a/src/arch/x86/interrupts.cc b/src/arch/x86/interrupts.cc index a422a4758..b418a7489 100644 --- a/src/arch/x86/interrupts.cc +++ b/src/arch/x86/interrupts.cc @@ -303,6 +303,7 @@ X86ISA::Interrupts::setCPU(BaseCPU * newCPU) cpu = newCPU; initialApicId = cpu->cpuId(); regs[APIC_ID] = (initialApicId << 24); + pioAddr = x86LocalAPICAddress(initialApicId, 0); } @@ -367,20 +368,19 @@ X86ISA::Interrupts::recvResponse(PacketPtr pkt) AddrRangeList -X86ISA::Interrupts::getAddrRanges() +X86ISA::Interrupts::getAddrRanges() const { AddrRangeList ranges; Range range = RangeEx(x86LocalAPICAddress(initialApicId, 0), x86LocalAPICAddress(initialApicId, 0) + PageBytes); ranges.push_back(range); - pioAddr = range.start; return ranges; } AddrRangeList -X86ISA::Interrupts::getIntAddrRange() +X86ISA::Interrupts::getIntAddrRange() const { AddrRangeList ranges; ranges.push_back(RangeEx(x86InterruptAddress(initialApicId, 0), diff --git a/src/arch/x86/interrupts.hh b/src/arch/x86/interrupts.hh index 328e7159d..1b7f5a52c 100644 --- a/src/arch/x86/interrupts.hh +++ b/src/arch/x86/interrupts.hh @@ -236,8 +236,8 @@ class Interrupts : public BasicPioDevice, IntDev return entry.periodic; } - AddrRangeList getAddrRanges(); - AddrRangeList getIntAddrRange(); + AddrRangeList getAddrRanges() const; + AddrRangeList getIntAddrRange() const; MasterPort &getMasterPort(const std::string &if_name, int idx = -1) { diff --git a/src/dev/arm/gic.cc b/src/dev/arm/gic.cc index 143cae9f1..725199bc4 100644 --- a/src/dev/arm/gic.cc +++ b/src/dev/arm/gic.cc @@ -708,7 +708,7 @@ Gic::postInt(uint32_t cpu, Tick when) } AddrRangeList -Gic::getAddrRanges() +Gic::getAddrRanges() const { AddrRangeList ranges; ranges.push_back(RangeSize(distAddr, DIST_SIZE)); diff --git a/src/dev/arm/gic.hh b/src/dev/arm/gic.hh index 67d48cd86..9d93bbedf 100644 --- a/src/dev/arm/gic.hh +++ b/src/dev/arm/gic.hh @@ -261,7 +261,7 @@ class Gic : public PioDevice /** Return the address ranges used by the Gic * This is the distributor address + all cpu addresses */ - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; /** A PIO read to the device, immediately split up into * readDistributor() or readCpu() diff --git a/src/dev/arm/pl111.cc b/src/dev/arm/pl111.cc index c1edc29ea..998644a8c 100644 --- a/src/dev/arm/pl111.cc +++ b/src/dev/arm/pl111.cc @@ -746,7 +746,7 @@ Pl111::generateInterrupt() } AddrRangeList -Pl111::getAddrRanges() +Pl111::getAddrRanges() const { AddrRangeList ranges; ranges.push_back(RangeSize(pioAddr, pioSize)); diff --git a/src/dev/arm/pl111.hh b/src/dev/arm/pl111.hh index 36dfc46c1..c4fb84efa 100644 --- a/src/dev/arm/pl111.hh +++ b/src/dev/arm/pl111.hh @@ -329,7 +329,7 @@ class Pl111: public AmbaDmaDevice * * @return a list of non-overlapping address ranges */ - AddrRangeList getAddrRanges(); + AddrRangeList getAddrRanges() const; }; #endif diff --git a/src/dev/io_device.cc b/src/dev/io_device.cc index 100c04828..b03afc5c6 100644 --- a/src/dev/io_device.cc +++ b/src/dev/io_device.cc @@ -58,7 +58,7 @@ PioPort::recvAtomic(PacketPtr pkt) } AddrRangeList -PioPort::getAddrRanges() +PioPort::getAddrRanges() const { return device->getAddrRanges(); } @@ -106,7 +106,7 @@ BasicPioDevice::BasicPioDevice(const Params *p) {} AddrRangeList -BasicPioDevice::getAddrRanges() +BasicPioDevice::getAddrRanges() const { assert(pioSize != 0); AddrRangeList ranges; diff --git a/src/dev/io_device.hh b/src/dev/io_device.hh index 3f2802332..260053169 100644 --- a/src/dev/io_device.hh +++ b/src/dev/io_device.hh @@ -67,7 +67,7 @@ class PioPort : public SimpleTimingPort virtual Tick recvAtomic(PacketPtr pkt); - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; public: @@ -96,7 +96,7 @@ class PioDevice : public MemObject * * @return a list of non-overlapping address ranges */ - virtual AddrRangeList getAddrRanges() = 0; + virtual AddrRangeList getAddrRanges() const = 0; /** Pure virtual function that the device must implement. Called * when a read command is recieved by the port. @@ -160,7 +160,7 @@ class BasicPioDevice : public PioDevice * * @return a list of non-overlapping address ranges */ - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; }; diff --git a/src/dev/pciconfigall.cc b/src/dev/pciconfigall.cc index 320f45543..4fe3b4641 100644 --- a/src/dev/pciconfigall.cc +++ b/src/dev/pciconfigall.cc @@ -85,7 +85,7 @@ PciConfigAll::write(PacketPtr pkt) AddrRangeList -PciConfigAll::getAddrRanges() +PciConfigAll::getAddrRanges() const { AddrRangeList ranges; ranges.push_back(RangeSize(pioAddr, params()->size)); diff --git a/src/dev/pciconfigall.hh b/src/dev/pciconfigall.hh index e594838fa..eb480ad16 100644 --- a/src/dev/pciconfigall.hh +++ b/src/dev/pciconfigall.hh @@ -80,7 +80,7 @@ class PciConfigAll : public PioDevice virtual Tick write(PacketPtr pkt); - AddrRangeList getAddrRanges(); + AddrRangeList getAddrRanges() const; private: Addr pioAddr; diff --git a/src/dev/pcidev.cc b/src/dev/pcidev.cc index 3c15bb002..fb4aaa799 100644 --- a/src/dev/pcidev.cc +++ b/src/dev/pcidev.cc @@ -71,7 +71,7 @@ PciDev::PciConfigPort::recvAtomic(PacketPtr pkt) } AddrRangeList -PciDev::PciConfigPort::getAddrRanges() +PciDev::PciConfigPort::getAddrRanges() const { AddrRangeList ranges; if (configAddr != ULL(-1)) @@ -208,7 +208,7 @@ PciDev::readConfig(PacketPtr pkt) } AddrRangeList -PciDev::getAddrRanges() +PciDev::getAddrRanges() const { AddrRangeList ranges; int x = 0; diff --git a/src/dev/pcidev.hh b/src/dev/pcidev.hh index 0cda0b8ea..51d2cc93e 100644 --- a/src/dev/pcidev.hh +++ b/src/dev/pcidev.hh @@ -65,7 +65,7 @@ class PciDev : public DmaDevice virtual Tick recvAtomic(PacketPtr pkt); - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; Platform *platform; @@ -191,7 +191,7 @@ class PciDev : public DmaDevice * * @return a list of non-overlapping address ranges */ - AddrRangeList getAddrRanges(); + AddrRangeList getAddrRanges() const; /** * Constructor for PCI Dev. This function copies data from the diff --git a/src/dev/sparc/iob.cc b/src/dev/sparc/iob.cc index 757c50a24..c71edd9f0 100644 --- a/src/dev/sparc/iob.cc +++ b/src/dev/sparc/iob.cc @@ -324,7 +324,7 @@ Iob::receiveJBusInterrupt(int cpu_id, int source, uint64_t d0, uint64_t d1) } AddrRangeList -Iob::getAddrRanges() +Iob::getAddrRanges() const { AddrRangeList ranges; ranges.push_back(RangeSize(iobManAddr, iobManSize)); diff --git a/src/dev/sparc/iob.hh b/src/dev/sparc/iob.hh index d6a47ce19..b92d3cb2a 100644 --- a/src/dev/sparc/iob.hh +++ b/src/dev/sparc/iob.hh @@ -141,7 +141,7 @@ class Iob : public PioDevice bool receiveJBusInterrupt(int cpu_id, int source, uint64_t d0, uint64_t d1); - AddrRangeList getAddrRanges(); + AddrRangeList getAddrRanges() const; virtual void serialize(std::ostream &os); virtual void unserialize(Checkpoint *cp, const std::string §ion); diff --git a/src/dev/uart8250.cc b/src/dev/uart8250.cc index 671d5505f..a014398b2 100644 --- a/src/dev/uart8250.cc +++ b/src/dev/uart8250.cc @@ -287,7 +287,7 @@ Uart8250::dataAvailable() } AddrRangeList -Uart8250::getAddrRanges() +Uart8250::getAddrRanges() const { AddrRangeList ranges; ranges.push_back(RangeSize(pioAddr, pioSize)); diff --git a/src/dev/uart8250.hh b/src/dev/uart8250.hh index f31def2ea..e2fb043c1 100644 --- a/src/dev/uart8250.hh +++ b/src/dev/uart8250.hh @@ -100,7 +100,7 @@ class Uart8250 : public Uart virtual Tick read(PacketPtr pkt); virtual Tick write(PacketPtr pkt); - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; /** * Inform the uart that there is data available. diff --git a/src/dev/x86/i8042.cc b/src/dev/x86/i8042.cc index 746a08778..1e6464815 100644 --- a/src/dev/x86/i8042.cc +++ b/src/dev/x86/i8042.cc @@ -44,9 +44,10 @@ const uint8_t CommandNack = 0xfe; const uint8_t BatSuccessful = 0xaa; AddrRangeList -X86ISA::I8042::getAddrRanges() +X86ISA::I8042::getAddrRanges() const { AddrRangeList ranges; + // TODO: Are these really supposed to be a single byte and not 4? ranges.push_back(RangeSize(dataPort, 1)); ranges.push_back(RangeSize(commandPort, 1)); return ranges; diff --git a/src/dev/x86/i8042.hh b/src/dev/x86/i8042.hh index 61220b45d..800fffc40 100644 --- a/src/dev/x86/i8042.hh +++ b/src/dev/x86/i8042.hh @@ -255,7 +255,7 @@ class I8042 : public BasicPioDevice commandByte.keyboardFullInt = 1; } - AddrRangeList getAddrRanges(); + AddrRangeList getAddrRanges() const; Tick read(PacketPtr pkt); diff --git a/src/dev/x86/i82094aa.hh b/src/dev/x86/i82094aa.hh index d3eedea7b..c90a5b812 100644 --- a/src/dev/x86/i82094aa.hh +++ b/src/dev/x86/i82094aa.hh @@ -101,7 +101,7 @@ class I82094AA : public PioDevice, public IntDev Tick read(PacketPtr pkt); Tick write(PacketPtr pkt); - AddrRangeList getAddrRanges() + AddrRangeList getAddrRanges() const { AddrRangeList ranges; ranges.push_back(RangeEx(pioAddr, pioAddr + 4)); @@ -109,7 +109,7 @@ class I82094AA : public PioDevice, public IntDev return ranges; } - AddrRangeList getIntAddrRange() + AddrRangeList getIntAddrRange() const { AddrRangeList ranges; ranges.push_back(RangeEx(x86InterruptAddress(initialApicId, 0), diff --git a/src/dev/x86/intdev.hh b/src/dev/x86/intdev.hh index bbdd98b24..a32182a92 100644 --- a/src/dev/x86/intdev.hh +++ b/src/dev/x86/intdev.hh @@ -74,7 +74,7 @@ class IntDev { } - AddrRangeList getAddrRanges() + AddrRangeList getAddrRanges() const { return device->getIntAddrRange(); } @@ -152,7 +152,7 @@ class IntDev } virtual AddrRangeList - getIntAddrRange() + getIntAddrRange() const { panic("intAddrRange not implemented.\n"); } diff --git a/src/mem/bridge.cc b/src/mem/bridge.cc index eabfbc44d..3a5313e7b 100644 --- a/src/mem/bridge.cc +++ b/src/mem/bridge.cc @@ -443,7 +443,7 @@ Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt) } AddrRangeList -Bridge::BridgeSlavePort::getAddrRanges() +Bridge::BridgeSlavePort::getAddrRanges() const { return ranges; } diff --git a/src/mem/bridge.hh b/src/mem/bridge.hh index 4595cf516..eefb4d121 100644 --- a/src/mem/bridge.hh +++ b/src/mem/bridge.hh @@ -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; }; diff --git a/src/mem/bus.cc b/src/mem/bus.cc index 5be53dbcd..2e735e03b 100644 --- a/src/mem/bus.cc +++ b/src/mem/bus.cc @@ -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) || diff --git a/src/mem/bus.hh b/src/mem/bus.hh index 4f0e44b1c..94068d897 100644 --- a/src/mem/bus.hh +++ b/src/mem/bus.hh @@ -85,7 +85,8 @@ class BaseBus : public MemObject Event * drainEvent; - typedef range_map::iterator PortIter; + typedef range_map::iterator PortMapIter; + typedef range_map::const_iterator PortMapConstIter; range_map 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. diff --git a/src/mem/cache/cache.hh b/src/mem/cache/cache.hh index beb3903da..9bdbd3456 100644 --- a/src/mem/cache/cache.hh +++ b/src/mem/cache/cache.hh @@ -101,7 +101,7 @@ class Cache : public BaseCache virtual unsigned deviceBlockSize() const { return cache->getBlockSize(); } - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; public: diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index cc68bbd3d..f7901261f 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -1588,7 +1588,7 @@ Cache::unserialize(Checkpoint *cp, const std::string §ion) template AddrRangeList -Cache::CpuSidePort::getAddrRanges() +Cache::CpuSidePort::getAddrRanges() const { return cache->getAddrRanges(); } diff --git a/src/mem/coherent_bus.hh b/src/mem/coherent_bus.hh index a8737eeed..460afd828 100644 --- a/src/mem/coherent_bus.hh +++ b/src/mem/coherent_bus.hh @@ -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(); } /** diff --git a/src/mem/comm_monitor.cc b/src/mem/comm_monitor.cc index 8469a2469..1b030de5e 100644 --- a/src/mem/comm_monitor.cc +++ b/src/mem/comm_monitor.cc @@ -345,7 +345,7 @@ CommMonitor::deviceBlockSizeSlave() } AddrRangeList -CommMonitor::getAddrRanges() +CommMonitor::getAddrRanges() const { // get the address ranges of the connected slave port return masterPort.getAddrRanges(); diff --git a/src/mem/comm_monitor.hh b/src/mem/comm_monitor.hh index 54f9690ed..4b90306e1 100644 --- a/src/mem/comm_monitor.hh +++ b/src/mem/comm_monitor.hh @@ -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; diff --git a/src/mem/noncoherent_bus.hh b/src/mem/noncoherent_bus.hh index 7227d3bc6..46fc65fad 100644 --- a/src/mem/noncoherent_bus.hh +++ b/src/mem/noncoherent_bus.hh @@ -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(); } /** diff --git a/src/mem/port.hh b/src/mem/port.hh index cfeb87571..35f2993df 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -64,6 +64,7 @@ typedef std::list > AddrRangeList; typedef std::list >::iterator AddrRangeIter; +typedef std::list >::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: diff --git a/src/mem/ruby/system/RubyPort.cc b/src/mem/ruby/system/RubyPort.cc index 285017a06..a6eb4d22d 100644 --- a/src/mem/ruby/system/RubyPort.cc +++ b/src/mem/ruby/system/RubyPort.cc @@ -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; diff --git a/src/mem/ruby/system/RubyPort.hh b/src/mem/ruby/system/RubyPort.hh index 8833efb6e..3b19632e2 100644 --- a/src/mem/ruby/system/RubyPort.hh +++ b/src/mem/ruby/system/RubyPort.hh @@ -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); diff --git a/src/mem/simple_mem.cc b/src/mem/simple_mem.cc index 10e809d0b..aa9168bf7 100644 --- a/src/mem/simple_mem.cc +++ b/src/mem/simple_mem.cc @@ -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()); diff --git a/src/mem/simple_mem.hh b/src/mem/simple_mem.hh index b21b38fd8..5f136ed51 100644 --- a/src/mem/simple_mem.hh +++ b/src/mem/simple_mem.hh @@ -77,7 +77,7 @@ class SimpleMemory : public AbstractMemory virtual void recvFunctional(PacketPtr pkt); - virtual AddrRangeList getAddrRanges(); + virtual AddrRangeList getAddrRanges() const; };