ARM: Use a stl queue for the table walker state
[gem5.git] / src / mem / port.hh
index 5e55225bf637423de3e95a71ff1e5f949819411b..bb74bf497a35f6667ccef0c77ee1ef8ba155aac8 100644 (file)
 #define __MEM_PORT_HH__
 
 #include <list>
-#include <inttypes.h>
 
 #include "base/misc.hh"
 #include "base/range.hh"
+#include "base/types.hh"
 #include "mem/packet.hh"
 #include "mem/request.hh"
+#include "sim/eventq.hh"
 
 /** This typedef is used to clean up the parameter list of
  * getDeviceAddressRanges() and getPeerAddressRanges().  It's declared
@@ -58,6 +59,7 @@
 typedef std::list<Range<Addr> > AddrRangeList;
 typedef std::list<Range<Addr> >::iterator AddrRangeIter;
 
+class EventQueue;
 class MemObject;
 
 /**
@@ -71,10 +73,9 @@ class MemObject;
  * Send accessor functions are being called from the device the port is
  * associated with, and it will call the peer recv. accessor function.
  */
-class Port
+class Port : public EventManager
 {
-  private:
-
+  protected:
     /** Descriptive name (for DPRINTF output) */
     mutable std::string portName;
 
@@ -87,11 +88,6 @@ class Port
     MemObject *owner;
 
   public:
-
-    Port()
-        : peer(NULL), owner(NULL)
-    { }
-
     /**
      * Constructor.
      *
@@ -100,14 +96,12 @@ class Port
      * @param _owner Pointer to the MemObject that owns this port.
      * Will not necessarily be set.
      */
-    Port(const std::string &_name, MemObject *_owner = NULL)
-        : portName(_name), peer(NULL), owner(_owner)
-    { }
+    Port(const std::string &_name, MemObject *_owner);
 
     /** Return port name (for DPRINTF). */
     const std::string &name() const { return portName; }
 
-    virtual ~Port() {};
+    virtual ~Port();
 
     // mey be better to use subclasses & RTTI?
     /** Holds the ports status.  Currently just that a range recomputation needs
@@ -120,17 +114,25 @@ class Port
     { portName = name; }
 
     /** Function to set the pointer for the peer port. */
-    void setPeer(Port *port);
+    virtual void setPeer(Port *port);
 
     /** Function to get the pointer to the peer port. */
     Port *getPeer() { return peer; }
 
     /** Function to set the owner of this port. */
-    void setOwner(MemObject *_owner) { owner = _owner; }
+    void setOwner(MemObject *_owner);
 
     /** Function to return the owner of this port. */
     MemObject *getOwner() { return owner; }
 
+    /** Inform the peer port to delete itself and notify it's owner about it's
+     * demise. */
+    void removeConn();
+
+    virtual bool isDefaultPort() const { return false; }
+
+    bool isConnected() { return peer && !peer->isDefaultPort(); }
+
   protected:
 
     /** These functions are protected because they should only be
@@ -156,10 +158,10 @@ class Port
 
     /** Called by a peer port in order to determine the block size of the
         device connected to this port.  It sometimes doesn't make sense for
-        this function to be called, a DMA interface doesn't really have a
-        block size, so it is defaulted to a panic.
+        this function to be called, so it just returns 0. Anytthing that is
+        concerned with the size should just ignore that.
     */
-    virtual int deviceBlockSize() { panic("??"); M5_DUMMY_RETURN }
+    virtual unsigned deviceBlockSize() const { return 0; }
 
     /** The peer port is requesting us to reply with a list of the ranges we
         are responsible for.
@@ -167,7 +169,7 @@ class Port
         @param snoop is a list of ranges snooped
     */
     virtual void getDeviceAddressRanges(AddrRangeList &resp,
-            AddrRangeList &snoop)
+                                        bool &snoop)
     { panic("??"); }
 
   public:
@@ -212,12 +214,12 @@ class Port
     /** Called by the associated device if it wishes to find out the blocksize
         of the device on attached to the peer port.
     */
-    int peerBlockSize() { return peer->deviceBlockSize(); }
+    unsigned peerBlockSize() const { return peer->deviceBlockSize(); }
 
     /** Called by the associated device if it wishes to find out the address
         ranges connected to the peer ports devices.
     */
-    void getPeerAddressRanges(AddrRangeList &resp, AddrRangeList &snoop)
+    void getPeerAddressRanges(AddrRangeList &resp, bool &snoop)
     { peer->getDeviceAddressRanges(resp, snoop); }
 
     /** This function is a wrapper around sendFunctional()
@@ -241,11 +243,16 @@ class Port
     */
     virtual void memsetBlob(Addr addr, uint8_t val, int size);
 
+    /** Inject a PrintReq for the given address to print the state of
+     * that address throughout the memory system.  For debugging.
+     */
+    void printAddr(Addr a);
+
   private:
 
     /** Internal helper function for read/writeBlob().
      */
-    void blobHelper(Addr addr, uint8_t *p, int size, Packet::Command cmd);
+    void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd);
 };
 
 /** A simple functional port that is only meant for one way communication to