Merge ktlim@zizzer:/bk/newmem
[gem5.git] / src / dev / io_device.hh
index 74730ad92e5bca6a17e894a736ce3b13a4182c47..cd2c25eeb7e95ae75ac02e6bde9f8da98f6315b4 100644 (file)
@@ -24,6 +24,9 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Ali Saidi
+ *          Nathan Binkert
  */
 
 #ifndef __DEV_IO_DEVICE_HH__
@@ -105,8 +108,9 @@ class PioPort : public Port
     void sendTiming(Packet *pkt, Tick time)
     { new PioPort::SendEvent(this, pkt, time); }
 
-    /** This function pops the last element off the transmit list and sends it.*/
-    virtual Packet *recvRetry();
+    /** This function is notification that the device should attempt to send a
+     * packet again. */
+    virtual void recvRetry();
 
   public:
     PioPort(PioDevice *dev, Platform *p);
@@ -117,10 +121,22 @@ class PioPort : public Port
 
 struct DmaReqState : public Packet::SenderState
 {
+    /** Event to call on the device when this transaction (all packets)
+     * complete. */
     Event *completionEvent;
+
+    /** Where we came from for some sanity checking. */
+    Port *outPort;
+
+    /** Total number of bytes that this transaction involves. */
+    Addr totBytes;
+
+    /** Number of bytes that have been acked for this transaction. */
+    Addr numBytes;
+
     bool final;
-    DmaReqState(Event *ce, bool f)
-        : completionEvent(ce), final(f)
+    DmaReqState(Event *ce, Port *p, Addr tb)
+        : completionEvent(ce), outPort(p), totBytes(tb), numBytes(0)
     {}
 };
 
@@ -146,29 +162,12 @@ class DmaPort : public Port
     virtual void recvStatusChange(Status status)
     { ; }
 
-    virtual Packet *recvRetry() ;
+    virtual void recvRetry() ;
 
     virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop)
     { resp.clear(); snoop.clear(); }
 
-    class SendEvent : public Event
-    {
-        DmaPort *port;
-        Packet *packet;
-
-        SendEvent(PioPort *p, Packet *pkt, Tick t)
-            : Event(&mainEventQueue), packet(pkt)
-        { schedule(curTick + t); }
-
-        virtual void process();
-
-        virtual const char *description()
-        { return "Future scheduled sendTiming event"; }
-
-        friend class DmaPort;
-    };
-
-    void sendDma(Packet *pkt);
+    void sendDma(Packet *pkt, bool front = false);
 
   public:
     DmaPort(DmaDevice *dev, Platform *p);
@@ -178,8 +177,6 @@ class DmaPort : public Port
 
     bool dmaPending() { return pendingCount > 0; }
 
-  friend class DmaPort::SendEvent;
-
 };
 
 /**
@@ -250,7 +247,7 @@ class PioDevice : public MemObject
 
     virtual void init();
 
-    virtual Port *getPort(const std::string &if_name)
+    virtual Port *getPort(const std::string &if_name, int idx = -1)
     {
         if (if_name == "pio") {
             if (pioPort != NULL)
@@ -312,7 +309,7 @@ class DmaDevice : public PioDevice
 
     bool dmaPending() { return dmaPort->dmaPending(); }
 
-    virtual Port *getPort(const std::string &if_name)
+    virtual Port *getPort(const std::string &if_name, int idx = -1)
     {
         if (if_name == "pio") {
             if (pioPort != NULL)