diff options
Diffstat (limited to 'src/mem/tport.hh')
-rw-r--r-- | src/mem/tport.hh | 107 |
1 files changed, 58 insertions, 49 deletions
diff --git a/src/mem/tport.hh b/src/mem/tport.hh index 5473e945e..df6d48196 100644 --- a/src/mem/tport.hh +++ b/src/mem/tport.hh @@ -28,67 +28,52 @@ * Authors: Ali Saidi */ +#ifndef __MEM_TPORT_HH__ +#define __MEM_TPORT_HH__ + /** * @file - * Implement a port which adds simple support of a sendTiming() function that - * takes a delay. In this way the * device can immediatly call - * sendTiming(pkt, time) after processing a request and the request will be - * handled by the port even if the port bus the device connects to is blocked. + * + * Declaration of SimpleTimingPort. */ -/** recvTiming and drain should be implemented something like this when this - * class is used. - -bool -PioPort::recvTiming(Packet *pkt) -{ - if (pkt->result == Packet::Nacked) { - resendNacked(pkt); - } else { - Tick latency = device->recvAtomic(pkt); - // turn packet around to go back to requester - pkt->makeTimingResponse(); - sendTiming(pkt, latency); - } - return true; -} - -PioDevice::drain(Event *de) -{ - unsigned int count; - count = SimpleTimingPort->drain(de); - if (count) - changeState(Draining); - else - changeState(Drained); - return count; -} -*/ - -#ifndef __MEM_TPORT_HH__ -#define __MEM_TPORT_HH__ - #include "mem/port.hh" #include "sim/eventq.hh" #include <list> #include <string> +/** + * A simple port for interfacing objects that basically have only + * functional memory behavior (e.g. I/O devices) to the memory system. + * Both timing and functional accesses are implemented in terms of + * atomic accesses. A derived port class thus only needs to provide + * recvAtomic() to support all memory access modes. + * + * The tricky part is handling recvTiming(), where the response must + * be scheduled separately via a later call to sendTiming(). This + * feature is handled by scheduling an internal event that calls + * sendTiming() after a delay, and optionally rescheduling the + * response if it is nacked. + */ class SimpleTimingPort : public Port { protected: - /** A list of outgoing timing response packets that haven't been serviced - * yet. */ + /** A list of outgoing timing response packets that haven't been + * serviced yet. */ std::list<Packet*> transmitList; + /** - * This class is used to implemented sendTiming() with a delay. When a delay - * is requested a new event is created. When the event time expires it - * attempts to send the packet. If it cannot, the packet is pushed onto the - * transmit list to be sent when recvRetry() is called. */ + * This class is used to implemented sendTiming() with a delay. When + * a delay is requested a new event is created. When the event time + * expires it attempts to send the packet. If it cannot, the packet + * is pushed onto the transmit list to be sent when recvRetry() is + * called. */ class SendEvent : public Event { SimpleTimingPort *port; Packet *packet; + public: SendEvent(SimpleTimingPort *p, Packet *pkt, Tick t) : Event(&mainEventQueue), port(p), packet(pkt) { setFlags(AutoDelete); schedule(curTick + t); } @@ -97,8 +82,6 @@ class SimpleTimingPort : public Port virtual const char *description() { return "Future scheduled sendTiming event"; } - - friend class SimpleTimingPort; }; @@ -112,23 +95,49 @@ class SimpleTimingPort : public Port Event *drainEvent; /** Schedule a sendTiming() event to be called in the future. */ - void sendTiming(Packet *pkt, Tick time) - { outTiming++; new SimpleTimingPort::SendEvent(this, pkt, time); } + void sendTimingLater(Packet *pkt, Tick time) + { outTiming++; new SendEvent(this, pkt, time); } /** This function is notification that the device should attempt to send a * packet again. */ virtual void recvRetry(); - void resendNacked(Packet *pkt); + /** Implemented using recvAtomic(). */ + void recvFunctional(Packet *pkt); + + /** Implemented using recvAtomic(). */ + bool recvTiming(Packet *pkt); + + /** + * Simple ports generally don't care about any status + * changes... can always override this in cases where that's not + * true. */ + virtual void recvStatusChange(Status status) { } + + public: SimpleTimingPort(std::string pname) : Port(pname), outTiming(0), drainEvent(NULL) {} + /** Hook for draining timing accesses from the system. The + * associated SimObject's drain() functions should be implemented + * something like this when this class is used: + \code + PioDevice::drain(Event *de) + { + unsigned int count; + count = SimpleTimingPort->drain(de); + if (count) + changeState(Draining); + else + changeState(Drained); + return count; + } + \endcode + */ unsigned int drain(Event *de); - - friend class SimpleTimingPort::SendEvent; }; #endif // __MEM_TPORT_HH__ |