cpu: remove unnecessary data ptr from O3 internal read() funcs
[gem5.git] / src / dev / io_device.hh
index ea2364f33039154ac4632e54cd215a34bd1fbd20..7e323b3bccc7cd11c3dba15b94593a0073da484a 100644 (file)
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright (c) 2004-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
 #ifndef __DEV_IO_DEVICE_HH__
 #define __DEV_IO_DEVICE_HH__
 
-#include "base/fast_alloc.hh"
 #include "mem/mem_object.hh"
-#include "mem/packet.hh"
 #include "mem/tport.hh"
 #include "params/BasicPioDevice.hh"
-#include "params/DmaDevice.hh"
 #include "params/PioDevice.hh"
-#include "sim/sim_object.hh"
 
-class Event;
 class PioDevice;
-class DmaDevice;
 class System;
 
 /**
@@ -61,118 +67,11 @@ class PioPort : public SimpleTimingPort
 
     virtual Tick recvAtomic(PacketPtr pkt);
 
-    virtual AddrRangeList getAddrRanges();
+    virtual AddrRangeList getAddrRanges() const;
 
   public:
 
-    PioPort(PioDevice *dev, System *s, std::string pname = "-pioport");
-};
-
-
-class DmaPort : public Port
-{
-  protected:
-    struct DmaReqState : public Packet::SenderState, public FastAlloc
-    {
-        /** 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;
-
-        /** Amount to delay completion of dma by */
-        Tick delay;
-
-
-        DmaReqState(Event *ce, Port *p, Addr tb, Tick _delay)
-            : completionEvent(ce), outPort(p), totBytes(tb), numBytes(0),
-              delay(_delay)
-        {}
-    };
-
-    MemObject *device;
-    std::list<PacketPtr> transmitList;
-
-    /** The system that device/port are in. This is used to select which mode
-     * we are currently operating in. */
-    System *sys;
-
-    /** Number of outstanding packets the dma port has. */
-    int pendingCount;
-
-    /** If a dmaAction is in progress. */
-    int actionInProgress;
-
-    /** If we need to drain, keep the drain event around until we're done
-     * here.*/
-    Event *drainEvent;
-
-    /** time to wait between sending another packet, increases as NACKs are
-     * recived, decreases as responses are recived. */
-    Tick backoffTime;
-
-    /** Minimum time that device should back off for after failed sendTiming */
-    Tick minBackoffDelay;
-
-    /** Maximum time that device should back off for after failed sendTiming */
-    Tick maxBackoffDelay;
-
-    /** If the port is currently waiting for a retry before it can send whatever
-     * it is that it's sending. */
-    bool inRetry;
-
-    /** Port accesses a cache which requires snooping */
-    bool recvSnoops;
-
-    virtual bool recvTiming(PacketPtr pkt);
-    virtual Tick recvAtomic(PacketPtr pkt)
-    {
-        if (recvSnoops) return 0;
-
-        panic("dma port shouldn't be used for pio access."); M5_DUMMY_RETURN
-    }
-    virtual void recvFunctional(PacketPtr pkt)
-    {
-        if (recvSnoops) return;
-
-        panic("dma port shouldn't be used for pio access.");
-    }
-
-    virtual void recvRangeChange()
-    {
-        // DMA port is a master with a single slave so there is no choice and
-        // thus no need to worry about any address changes
-    }
-
-    virtual void recvRetry() ;
-
-    virtual bool isSnooping()
-    { return recvSnoops; }
-
-    void queueDma(PacketPtr pkt, bool front = false);
-    void sendDma();
-
-    /** event to give us a kick every time we backoff time is reached. */
-    EventWrapper<DmaPort, &DmaPort::sendDma> backoffEvent;
-
-  public:
-    DmaPort(MemObject *dev, System *s, Tick min_backoff, Tick max_backoff,
-            bool recv_snoops = false);
-
-    void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
-                   uint8_t *data, Tick delay, Request::Flags flag = 0);
-
-    bool dmaPending() { return pendingCount > 0; }
-
-    unsigned cacheBlockSize() const { return peerBlockSize(); }
-    unsigned int drain(Event *de);
+    PioPort(PioDevice *dev);
 };
 
 /**
@@ -189,7 +88,7 @@ class PioDevice : public MemObject
 
     /** The pioPort that handles the requests for us and provides us requests
      * that it sees. */
-    PioPort *pioPort;
+    PioPort pioPort;
 
     /**
      * Every PIO device is obliged to provide an implementation that
@@ -197,7 +96,7 @@ class PioDevice : public MemObject
      *
      * @return a list of non-overlapping address ranges
      */
-    virtual AddrRangeList getAddrRanges() = 0;
+    virtual AddrRangeList getAddrRanges() const = 0;
 
     /** Pure virtual function that the device must implement. Called
      * when a read command is recieved by the port.
@@ -226,9 +125,8 @@ class PioDevice : public MemObject
 
     virtual void init();
 
-    virtual unsigned int drain(Event *de);
-
-    virtual Port *getPort(const std::string &if_name, int idx = -1);
+    virtual BaseSlavePort &getSlavePort(const std::string &if_name,
+                                        PortID idx = InvalidPortID);
 
     friend class PioPort;
 
@@ -248,7 +146,7 @@ class BasicPioDevice : public PioDevice
 
   public:
     typedef BasicPioDeviceParams Params;
-    BasicPioDevice(const Params *p);
+    BasicPioDevice(const Params *p, Addr size);
 
     const Params *
     params() const
@@ -261,46 +159,8 @@ class BasicPioDevice : public PioDevice
      *
      * @return a list of non-overlapping address ranges
      */
-    virtual AddrRangeList getAddrRanges();
-
-};
-
-class DmaDevice : public PioDevice
-{
-   protected:
-    DmaPort *dmaPort;
-
-  public:
-    typedef DmaDeviceParams Params;
-    DmaDevice(const Params *p);
-    virtual ~DmaDevice();
+    virtual AddrRangeList getAddrRanges() const;
 
-    const Params *
-    params() const
-    {
-        return dynamic_cast<const Params *>(_params);
-    }
-
-    void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, Tick delay = 0)
-    {
-        dmaPort->dmaAction(MemCmd::WriteReq, addr, size, event, data, delay);
-    }
-
-    void dmaRead(Addr addr, int size, Event *event, uint8_t *data, Tick delay = 0)
-    {
-        dmaPort->dmaAction(MemCmd::ReadReq, addr, size, event, data, delay);
-    }
-
-    bool dmaPending() { return dmaPort->dmaPending(); }
-
-    virtual unsigned int drain(Event *de);
-
-    unsigned cacheBlockSize() const { return dmaPort->cacheBlockSize(); }
-
-    virtual Port *getPort(const std::string &if_name, int idx = -1);
-
-    friend class DmaPort;
 };
 
-
 #endif // __DEV_IO_DEVICE_HH__