diff -r bd1a2503a5e0 -r ca898fd85b75 src/cpu/testers/directedtest/RubyDirectedTester.hh --- a/src/cpu/testers/directedtest/RubyDirectedTester.hh Sun Apr 08 15:08:44 2012 +0100 +++ b/src/cpu/testers/directedtest/RubyDirectedTester.hh Sun Apr 08 17:02:20 2012 +0100 @@ -54,12 +54,10 @@ public: CpuPort(const std::string &_name, RubyDirectedTester *_tester, - uint32_t _idx) - : MasterPort(_name, _tester), tester(_tester), idx(_idx) + Port::PortId _id) + : MasterPort(_name, _tester, _id), tester(_tester) {} - uint32_t idx; - protected: virtual bool recvTiming(PacketPtr pkt); virtual void recvRetry() diff -r bd1a2503a5e0 -r ca898fd85b75 src/cpu/testers/directedtest/RubyDirectedTester.cc --- a/src/cpu/testers/directedtest/RubyDirectedTester.cc Sun Apr 08 15:08:44 2012 +0100 +++ b/src/cpu/testers/directedtest/RubyDirectedTester.cc Sun Apr 08 17:02:20 2012 +0100 @@ -93,7 +93,7 @@ bool RubyDirectedTester::CpuPort::recvTiming(PacketPtr pkt) { - tester->hitCallback(idx, pkt->getAddr()); + tester->hitCallback(id, pkt->getAddr()); // // Now that the tester has completed, delete the packet, then return diff -r bd1a2503a5e0 -r ca898fd85b75 src/cpu/testers/rubytest/RubyTester.hh --- a/src/cpu/testers/rubytest/RubyTester.hh Sun Apr 08 15:08:44 2012 +0100 +++ b/src/cpu/testers/rubytest/RubyTester.hh Sun Apr 08 17:02:20 2012 +0100 @@ -57,12 +57,10 @@ // RubyPorts that support both types of requests, separate InstOnly // and DataOnly CpuPorts will map to that RubyPort - CpuPort(const std::string &_name, RubyTester *_tester, int _idx) - : MasterPort(_name, _tester), tester(_tester), idx(_idx) + CpuPort(const std::string &_name, RubyTester *_tester, PortId _id) + : MasterPort(_name, _tester, _id), tester(_tester) {} - int idx; - protected: virtual bool recvTiming(PacketPtr pkt); virtual void recvRetry() diff -r bd1a2503a5e0 -r ca898fd85b75 src/cpu/testers/rubytest/RubyTester.cc --- a/src/cpu/testers/rubytest/RubyTester.cc Sun Apr 08 15:08:44 2012 +0100 +++ b/src/cpu/testers/rubytest/RubyTester.cc Sun Apr 08 17:02:20 2012 +0100 @@ -156,7 +156,7 @@ // pop the sender state from the packet pkt->senderState = senderState->saved; - tester->hitCallback(idx, subblock); + tester->hitCallback(id, subblock); // Now that the tester has completed, delete the senderState // (includes sublock) and the packet, then return diff -r bd1a2503a5e0 -r ca898fd85b75 src/mem/bus.hh --- a/src/mem/bus.hh Sun Apr 08 15:08:44 2012 +0100 +++ b/src/mem/bus.hh Sun Apr 08 17:02:20 2012 +0100 @@ -77,18 +77,13 @@ /** A pointer to the bus to which this port belongs. */ Bus *bus; - /** A id to keep track of the interface ID of this port. */ - int id; - public: /** Constructor for the BusSlavePort.*/ - BusSlavePort(const std::string &_name, Bus *_bus, int _id) - : SlavePort(_name, _bus), bus(_bus), id(_id) + BusSlavePort(const std::string &_name, Bus *_bus, Port::PortId _id) + : SlavePort(_name, _bus, _id), bus(_bus) { } - int getId() const { return id; } - protected: /** @@ -147,18 +142,13 @@ /** A pointer to the bus to which this port belongs. */ Bus *bus; - /** A id to keep track of the interface ID of this port. */ - int id; - public: /** Constructor for the BusMasterPort.*/ - BusMasterPort(const std::string &_name, Bus *_bus, int _id) - : MasterPort(_name, _bus), bus(_bus), id(_id) + BusMasterPort(const std::string &_name, Bus *_bus, Port::PortId _id) + : MasterPort(_name, _bus, _id), bus(_bus) { } - int getId() const { return id; } - /** * Determine if this port should be considered a snooper. This * is determined by the bus. @@ -254,7 +244,7 @@ * @param pkt Packet to forward * @param exclude_slave_id Id of slave port to exclude */ - void forwardTiming(PacketPtr pkt, int exclude_slave_id); + void forwardTiming(PacketPtr pkt, Port::PortId exclude_slave_id); /** Function called by the port when the bus is recieving a Atomic transaction.*/ @@ -274,7 +264,8 @@ * * @return a pair containing the snoop response and snoop latency */ - std::pair forwardAtomic(PacketPtr pkt, int exclude_slave_id); + std::pair forwardAtomic(PacketPtr pkt, + Port::PortId exclude_slave_id); /** Function called by the port when the bus is recieving a Functional transaction.*/ @@ -292,14 +283,14 @@ * @param pkt Packet to forward * @param exclude_slave_id Id of slave port to exclude */ - void forwardFunctional(PacketPtr pkt, int exclude_slave_id); + void forwardFunctional(PacketPtr pkt, Port::PortId exclude_slave_id); /** Timing function called by port when it is once again able to process * requests. */ - void recvRetry(int id); + void recvRetry(Port::PortId id); /** Function called by the port when the bus is recieving a range change.*/ - void recvRangeChange(int id); + void recvRangeChange(Port::PortId id); /** Find which port connected to this bus (if any) should be given a packet * with this address. @@ -311,7 +302,7 @@ // Cache for the findPort function storing recently used ports from portMap struct PortCache { bool valid; - int id; + Port::PortId id; Addr start; Addr end; }; @@ -334,7 +325,7 @@ return portCache[2].id; } - return INVALID_PORT_ID; + return Port::INVALID_PORT_ID; } // Clears the earliest entry of the cache and inserts a new port entry @@ -369,7 +360,7 @@ * * @return a list of non-overlapping address ranges */ - AddrRangeList getAddrRanges(int id); + AddrRangeList getAddrRanges(Port::PortId id); /** * Determine if the bus port is snooping or not. @@ -378,7 +369,7 @@ * * @return a boolean indicating if this port is snooping or not */ - bool isSnooping(int id) const; + bool isSnooping(Port::PortId id) const; /** Calculate the timing parameters for the packet. Updates the * firstWordTime and finishTime fields of the packet object. @@ -407,13 +398,13 @@ * @param id id of the busport that made the request * @return the max of all the sizes */ - unsigned findBlockSize(int id); + unsigned findBlockSize(Port::PortId id); // event used to schedule a release of the bus EventWrapper busIdleEvent; bool inRetry; - std::set inRecvRangeChange; + std::set inRecvRangeChange; /** The master and slave ports of the bus */ std::vector slavePorts; @@ -445,9 +436,6 @@ /** Port that handles requests that don't match any of the interfaces.*/ short defaultPortId; - /** A symbolic name for a port id that denotes no port. */ - static const short INVALID_PORT_ID = -1; - /** If true, use address range provided by default device. Any address not handled by another port and not in default device's range will cause a fatal error. If false, just send all diff -r bd1a2503a5e0 -r ca898fd85b75 src/mem/bus.cc --- a/src/mem/bus.cc Sun Apr 08 15:08:44 2012 +0100 +++ b/src/mem/bus.cc Sun Apr 08 17:02:20 2012 +0100 @@ -57,7 +57,8 @@ : MemObject(p), clock(p->clock), headerCycles(p->header_cycles), width(p->width), tickNextIdle(0), drainEvent(NULL), busIdleEvent(this), inRetry(false), - defaultPortId(INVALID_PORT_ID), useDefaultRange(p->use_default_range), + defaultPortId(Port::INVALID_PORT_ID), + useDefaultRange(p->use_default_range), defaultBlockSize(p->block_size), cachedBlockSize(0), cachedBlockSizeValid(false) { @@ -340,7 +341,7 @@ assert(pkt->isExpressSnoop()); // forward to all snoopers - forwardTiming(pkt, INVALID_PORT_ID); + forwardTiming(pkt, Port::INVALID_PORT_ID); // a snoop request came from a connected slave (one of our // master ports), and if it is not coming from the slave @@ -449,7 +450,7 @@ // (corresponding to our own slave port that is also in // snoopPorts) and should not send it back to where it came // from - if (exclude_slave_id == INVALID_PORT_ID || + if (exclude_slave_id == Port::INVALID_PORT_ID || p->getId() != exclude_slave_id) { // cache is not allowed to refuse snoop bool success M5_VAR_USED = p->sendTimingSnoop(pkt); @@ -513,7 +514,7 @@ } void -Bus::recvRetry(int id) +Bus::recvRetry(Port::PortId id) { // we got a retry from a peer that we tried to send something to // and failed, but we sent it on the account of someone else, and @@ -539,7 +540,7 @@ int dest_id; dest_id = checkPortCache(addr); - if (dest_id != INVALID_PORT_ID) + if (dest_id != Port::INVALID_PORT_ID) return dest_id; // Check normal port ranges @@ -559,7 +560,7 @@ return defaultPortId; } } - } else if (defaultPortId != INVALID_PORT_ID) { + } else if (defaultPortId != Port::INVALID_PORT_ID) { DPRINTF(Bus, "Unable to find destination for addr %#llx, " "will use default port\n", addr); return defaultPortId; @@ -616,7 +617,8 @@ assert(pkt->isRequest()); // forward to all snoopers - std::pair snoop_result = forwardAtomic(pkt, INVALID_PORT_ID); + std::pair snoop_result = + forwardAtomic(pkt, Port::INVALID_PORT_ID); MemCmd snoop_response_cmd = snoop_result.first; Tick snoop_response_latency = snoop_result.second; @@ -649,7 +651,7 @@ // (corresponding to our own slave port that is also in // snoopPorts) and should not send it back to where it came // from - if (exclude_slave_id == INVALID_PORT_ID || + if (exclude_slave_id == Port::INVALID_PORT_ID || p->getId() != exclude_slave_id) { Tick latency = p->sendAtomicSnoop(pkt); // in contrast to a functional access, we have to keep on @@ -716,7 +718,7 @@ assert(pkt->isRequest()); // forward to all snoopers - forwardFunctional(pkt, INVALID_PORT_ID); + forwardFunctional(pkt, Port::INVALID_PORT_ID); } void @@ -729,7 +731,7 @@ // (corresponding to our own slave port that is also in // snoopPorts) and should not send it back to where it came // from - if (exclude_slave_id == INVALID_PORT_ID || + if (exclude_slave_id == Port::INVALID_PORT_ID || p->getId() != exclude_slave_id) p->sendFunctionalSnoop(pkt); @@ -742,7 +744,7 @@ /** Function called by the port when the bus is receiving a range change.*/ void -Bus::recvRangeChange(int id) +Bus::recvRangeChange(Port::PortId id) { AddrRangeList ranges; AddrRangeIter iter; @@ -806,7 +808,7 @@ } AddrRangeList -Bus::getAddrRanges(int id) +Bus::getAddrRanges(Port::PortId id) { AddrRangeList ranges; @@ -847,14 +849,14 @@ } bool -Bus::isSnooping(int id) const +Bus::isSnooping(Port::PortId id) const { // in essence, answer the question if there are snooping ports return !snoopPorts.empty(); } unsigned -Bus::findBlockSize(int id) +Bus::findBlockSize(Port::PortId id) { if (cachedBlockSizeValid) return cachedBlockSize; diff -r bd1a2503a5e0 -r ca898fd85b75 src/mem/port.hh --- a/src/mem/port.hh Sun Apr 08 15:08:44 2012 +0100 +++ b/src/mem/port.hh Sun Apr 08 17:02:20 2012 +0100 @@ -79,6 +79,14 @@ class Port { + public: + + /** A type name for the port identifier. */ + typedef int PortId; + + /** A symbolic name for the absence of a port id. */ + static const PortId INVALID_PORT_ID = -1; + private: /** Descriptive name (for DPRINTF output) */ @@ -86,6 +94,12 @@ protected: + /** + * A numeric identifier to distinguish ports in a vector, and set + * to INVALID_PORT_ID in case this port is not part of a vector. + */ + const PortId id; + /** A pointer to the peer port. */ Port* peer; @@ -97,8 +111,9 @@ * * @param _name Port name including the owners name * @param _owner The MemObject that is the structural owner of this port + * @param _id A port identifier for vector ports */ - Port(const std::string& _name, MemObject& _owner); + Port(const std::string& _name, MemObject& _owner, PortId _id); /** * Virtual destructor due to inheritance. @@ -110,6 +125,9 @@ /** Return port name (for DPRINTF). */ const std::string name() const { return portName; } + /** Get the port id. */ + PortId getId() const { return id; } + protected: /** These functions are protected because they should only be @@ -190,7 +208,8 @@ public: - MasterPort(const std::string& name, MemObject* owner); + MasterPort(const std::string& name, MemObject* owner, + PortId id = INVALID_PORT_ID); virtual ~MasterPort(); void bind(SlavePort& slave_port); @@ -286,7 +305,8 @@ public: - SlavePort(const std::string& name, MemObject* owner); + SlavePort(const std::string& name, MemObject* owner, + PortId id = INVALID_PORT_ID); virtual ~SlavePort(); void bind(MasterPort& master_port); diff -r bd1a2503a5e0 -r ca898fd85b75 src/mem/port.cc --- a/src/mem/port.cc Sun Apr 08 15:08:44 2012 +0100 +++ b/src/mem/port.cc Sun Apr 08 17:02:20 2012 +0100 @@ -50,8 +50,8 @@ #include "mem/mem_object.hh" #include "mem/port.hh" -Port::Port(const std::string &_name, MemObject& _owner) - : portName(_name), peer(NULL), owner(_owner) +Port::Port(const std::string &_name, MemObject& _owner, PortId _id) + : portName(_name), id(_id), peer(NULL), owner(_owner) { } @@ -62,8 +62,8 @@ /** * Master port */ -MasterPort::MasterPort(const std::string& name, MemObject* owner) - : Port(name, *owner), _slavePort(NULL) +MasterPort::MasterPort(const std::string& name, MemObject* owner, PortId _id) + : Port(name, *owner, _id), _slavePort(NULL) { } @@ -130,8 +130,8 @@ /** * Slave port */ -SlavePort::SlavePort(const std::string& name, MemObject* owner) - : Port(name, *owner), _masterPort(NULL) +SlavePort::SlavePort(const std::string& name, MemObject* owner, PortId id) + : Port(name, *owner, id), _masterPort(NULL) { }