diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-07-09 12:35:31 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-07-09 12:35:31 -0400 |
commit | 17f9270dada824ab7a1b52ed4470abef5aa56d6c (patch) | |
tree | f363339d3329d2c01a6e76f653a918a47a47bc2d /src | |
parent | ff5718f042ecccee694ae79c9386a589fd77e8ef (diff) | |
download | gem5-17f9270dada824ab7a1b52ed4470abef5aa56d6c.tar.xz |
Port: Move retry from port base class to Master/SlavePort
This patch is the last part of moving all protocol-related
functionality out of the Port base class. All the send/recv functions
are already moved, and the retry (which still governs all the timing
transport functions) is the only part that remained in the base class.
The only point where this currently causes a bit of inconvenience is
in the bus where the retry list is global and holds Port pointers (not
Master/SlavePort). This is about to change with the split into a
request/response bus and will soon be removed anyway.
The patch has no impact on any regressions.
Diffstat (limited to 'src')
-rw-r--r-- | src/cpu/simple/timing.hh | 2 | ||||
-rw-r--r-- | src/mem/bus.cc | 5 | ||||
-rw-r--r-- | src/mem/cache/base.hh | 2 | ||||
-rw-r--r-- | src/mem/port.cc | 16 | ||||
-rw-r--r-- | src/mem/port.hh | 53 |
5 files changed, 48 insertions, 30 deletions
diff --git a/src/cpu/simple/timing.hh b/src/cpu/simple/timing.hh index 77057ad02..95edea0b6 100644 --- a/src/cpu/simple/timing.hh +++ b/src/cpu/simple/timing.hh @@ -170,7 +170,7 @@ class TimingSimpleCPU : public BaseSimpleCPU void schedule(PacketPtr _pkt, Tick t); }; - EventWrapper<Port, &Port::sendRetry> retryEvent; + EventWrapper<MasterPort, &MasterPort::sendRetry> retryEvent; }; class IcachePort : public TimingCPUPort diff --git a/src/mem/bus.cc b/src/mem/bus.cc index 8040118d2..648b66f4d 100644 --- a/src/mem/bus.cc +++ b/src/mem/bus.cc @@ -218,7 +218,10 @@ BaseBus::retryWaiting() // note that we might have blocked on the receiving port being // busy (rather than the bus itself) and now call retry before the // destination called retry on the bus - retryList.front()->sendRetry(); + if (dynamic_cast<SlavePort*>(retryList.front()) != NULL) + (dynamic_cast<SlavePort*>(retryList.front()))->sendRetry(); + else + (dynamic_cast<MasterPort*>(retryList.front()))->sendRetry(); // If inRetry is still true, sendTiming wasn't called in zero time // (e.g. the cache does this) diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh index 55d5e85e1..79280f377 100644 --- a/src/mem/cache/base.hh +++ b/src/mem/cache/base.hh @@ -204,7 +204,7 @@ class BaseCache : public MemObject private: - EventWrapper<Port, &Port::sendRetry> sendRetryEvent; + EventWrapper<SlavePort, &SlavePort::sendRetry> sendRetryEvent; }; diff --git a/src/mem/port.cc b/src/mem/port.cc index 554f5bb1e..6007d303c 100644 --- a/src/mem/port.cc +++ b/src/mem/port.cc @@ -51,7 +51,7 @@ #include "mem/port.hh" Port::Port(const std::string &_name, MemObject& _owner, PortID _id) - : portName(_name), id(_id), peer(NULL), owner(_owner) + : portName(_name), id(_id), owner(_owner) { } @@ -86,7 +86,6 @@ MasterPort::bind(SlavePort& slave_port) { // master port keeps track of the slave port _slavePort = &slave_port; - peer = &slave_port; // slave port also keeps track of master port _slavePort->bind(*this); @@ -133,6 +132,12 @@ MasterPort::sendTimingSnoopResp(PacketPtr pkt) } void +MasterPort::sendRetry() +{ + _slavePort->recvRetry(); +} + +void MasterPort::printAddr(Addr a) { Request req(a, 1, 0, Request::funcMasterId); @@ -159,7 +164,6 @@ void SlavePort::bind(MasterPort& master_port) { _masterPort = &master_port; - peer = &master_port; } MasterPort& @@ -211,3 +215,9 @@ SlavePort::sendTimingSnoopReq(PacketPtr pkt) assert(pkt->isRequest()); _masterPort->recvTimingSnoopReq(pkt); } + +void +SlavePort::sendRetry() +{ + _masterPort->recvRetry(); +} diff --git a/src/mem/port.hh b/src/mem/port.hh index c70733bf6..b93d5d444 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -70,10 +70,7 @@ class MemObject; /** * Ports are used to interface memory objects to each other. A port is * either a master or a slave and the connected peer is always of the - * opposite role. - * - * Each port has a name and an owner, and enables three basic types of - * accesses to the peer port: functional, atomic and timing. + * opposite role. Each port has a name, an owner, and an identifier. */ class Port { @@ -91,9 +88,6 @@ class Port */ const PortID id; - /** A pointer to the peer port. */ - Port* peer; - /** A reference to the MemObject that owns this port. */ MemObject& owner; @@ -119,23 +113,6 @@ class Port /** Get the port id. */ PortID getId() const { return id; } - protected: - - /** - * Called by a peer port if sendTimingReq, sendTimingResp or - * sendTimingSnoopResp was unsuccesful, and had to wait. - */ - virtual void recvRetry() = 0; - - public: - - /** - * Send a retry to a peer port that previously attempted a - * sendTimingReq, sendTimingResp or sendTimingSnoopResp which was - * unsuccessful. - */ - void sendRetry() { return peer->recvRetry(); } - }; /** Forward declaration */ @@ -211,6 +188,12 @@ class MasterPort : public Port bool sendTimingSnoopResp(PacketPtr pkt); /** + * Send a retry to the slave port that previously attempted a + * sendTimingResp to this master port and failed. + */ + void sendRetry(); + + /** * Determine if this master port is snooping or not. The default * implementation returns false and thus tells the neighbour we * are not snooping. Any master port that wants to receive snoop @@ -270,6 +253,14 @@ class MasterPort : public Port } /** + * Called by the slave port if sendTimingReq or + * sendTimingSnoopResp was called on this master port (causing + * recvTimingReq and recvTimingSnoopResp to be called on the + * slave port) and was unsuccesful. + */ + virtual void recvRetry() = 0; + + /** * Called to receive an address range change from the peer slave * port. the default implementation ignored the change and does * nothing. Override this function in a derived class if the owner @@ -347,6 +338,13 @@ class SlavePort : public Port void sendTimingSnoopReq(PacketPtr pkt); /** + * Send a retry to the master port that previously attempted a + * sendTimingReq or sendTimingSnoopResp to this slave port and + * failed. + */ + void sendRetry(); + + /** * Called by a peer port in order to determine the block size of * the owner of this port. */ @@ -396,6 +394,13 @@ class SlavePort : public Port panic("%s was not expecting a timing snoop response\n", name()); } + /** + * Called by the master port if sendTimingResp was called on this + * slave port (causing recvTimingResp to be called on the master + * port) and was unsuccesful. + */ + virtual void recvRetry() = 0; + }; #endif //__MEM_PORT_HH__ |