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
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()
// 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
// 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()
: 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)
{
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 device (one of
// our master ports), and if it is not coming from the slave
// (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_port_id == INVALID_PORT_ID ||
+ if (exclude_slave_port_id == Port::INVALID_PORT_ID ||
p->getId() != exclude_slave_port_id) {
// cache is not allowed to refuse snoop
bool success M5_VAR_USED = p->sendTimingSnoop(pkt);
}
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
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
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;
assert(pkt->isRequest());
// forward to all snoopers
- std::pair<MemCmd, Tick> snoop_result = forwardAtomic(pkt, INVALID_PORT_ID);
+ std::pair<MemCmd, Tick> snoop_result =
+ forwardAtomic(pkt, Port::INVALID_PORT_ID);
MemCmd snoop_response_cmd = snoop_result.first;
Tick snoop_response_latency = snoop_result.second;
// (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_port_id == INVALID_PORT_ID ||
+ if (exclude_slave_port_id == Port::INVALID_PORT_ID ||
p->getId() != exclude_slave_port_id) {
Tick latency = p->sendAtomicSnoop(pkt);
// in contrast to a functional access, we have to keep on
assert(pkt->isRequest());
// forward to all snoopers
- forwardFunctional(pkt, INVALID_PORT_ID);
+ forwardFunctional(pkt, Port::INVALID_PORT_ID);
}
void
// (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_port_id == INVALID_PORT_ID ||
+ if (exclude_slave_port_id == Port::INVALID_PORT_ID ||
p->getId() != exclude_slave_port_id)
p->sendFunctionalSnoop(pkt);
/** 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;
}
AddrRangeList
-Bus::getAddrRanges(int id)
+Bus::getAddrRanges(Port::PortId id)
{
AddrRangeList ranges;
}
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;
/** 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:
/**
/** 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.
* @param pkt Packet to forward
* @param exclude_slave_port_id Id of slave port to exclude
*/
- void forwardTiming(PacketPtr pkt, int exclude_slave_port_id);
+ void forwardTiming(PacketPtr pkt, Port::PortId exclude_slave_port_id);
/**
* Determine if the bus is to be considered occupied when being
* @return a pair containing the snoop response and snoop latency
*/
std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt,
- int exclude_slave_port_id);
+ Port::PortId exclude_slave_port_id);
/** Function called by the port when the bus is recieving a Functional
transaction.*/
* @param pkt Packet to forward
* @param exclude_slave_port_id Id of slave port to exclude
*/
- void forwardFunctional(PacketPtr pkt, int exclude_slave_port_id);
+ void forwardFunctional(PacketPtr pkt, Port::PortId exclude_slave_port_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.
// Cache for the findPort function storing recently used ports from portMap
struct PortCache {
bool valid;
- int id;
+ Port::PortId id;
Addr start;
Addr end;
};
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
*
* @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.
*
* @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.
* @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<Bus, &Bus::releaseBus> busIdleEvent;
bool inRetry;
- std::set<int> inRecvRangeChange;
+ std::set<Port::PortId> inRecvRangeChange;
/** The master and slave ports of the bus */
std::vector<BusSlavePort*> slavePorts;
/** 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
#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)
{
}
/**
* 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)
{
}
/**
* 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)
{
}
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) */
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;
*
* @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.
/** 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
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);
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);