mem-cache: Add match functions to QueueEntry
[gem5.git] / src / mem / port.hh
index 2c30e31d12000ea9f8d63b57248fa3e0b1470dd1..72a02711c5f2836a44815d801273f9d40e535086 100644 (file)
 #define __MEM_PORT_HH__
 
 #include "base/addr_range.hh"
+#include "mem/backdoor.hh"
 #include "mem/packet.hh"
+#include "sim/port.hh"
 
 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, an owner, and an identifier.
- */
-class Port
-{
-
-  private:
-
-    /** Descriptive name (for DPRINTF output) */
-    std::string portName;
-
-  protected:
-
-    /**
-     * A numeric identifier to distinguish ports in a vector, and set
-     * to InvalidPortID in case this port is not part of a vector.
-     */
-    const PortID id;
-
-    /**
-     * Abstract base class for ports
-     *
-     * @param _name Port name including the owners name
-     * @param _id A port identifier for vector ports
-     */
-    Port(const std::string& _name, PortID _id);
-
-    /**
-     * Virtual destructor due to inheritance.
-     */
-    virtual ~Port();
-
-  public:
-
-    /** Return port name (for DPRINTF). */
-    const std::string name() const { return portName; }
-
-    /** Get the port id. */
-    PortID getId() const { return id; }
-
-};
-
 /** Forward declaration */
 class BaseSlavePort;
 
@@ -120,10 +78,7 @@ class BaseMasterPort : public Port
 
   public:
 
-    virtual void bind(BaseSlavePort& slave_port) = 0;
-    virtual void unbind() = 0;
     BaseSlavePort& getSlavePort() const;
-    bool isConnected() const;
 
 };
 
@@ -144,7 +99,6 @@ class BaseSlavePort : public Port
   public:
 
     BaseMasterPort& getMasterPort() const;
-    bool isConnected() const;
 
 };
 
@@ -181,12 +135,12 @@ class MasterPort : public BaseMasterPort
      * Bind this master port to a slave port. This also does the
      * mirror action and binds the slave port to the master port.
      */
-    void bind(BaseSlavePort& slave_port);
+    void bind(Port &peer) override;
 
     /**
      * Unbind this master port and the associated slave port.
      */
-    void unbind();
+    void unbind() override;
 
     /**
      * Send an atomic request packet, where the data is moved and the
@@ -199,6 +153,18 @@ class MasterPort : public BaseMasterPort
      */
     Tick sendAtomic(PacketPtr pkt);
 
+    /**
+     * Send an atomic request packet like above, but also request a backdoor
+     * to the data being accessed.
+     *
+     * @param pkt Packet to send.
+     * @param backdoor Can be set to a back door pointer by the target to let
+     *        caller have direct access to the requested data.
+     *
+     * @return Estimated latency of access.
+     */
+    Tick sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor);
+
     /**
      * Send a functional request packet, where the data is instantly
      * updated everywhere in the memory system, without affecting the
@@ -347,6 +313,7 @@ class SlavePort : public BaseSlavePort
   private:
 
     MasterPort* _masterPort;
+    bool defaultBackdoorWarned;
 
   protected:
 
@@ -437,25 +404,37 @@ class SlavePort : public BaseSlavePort
      */
     virtual AddrRangeList getAddrRanges() const = 0;
 
+    /**
+     * We let the master port do the work, so these don't do anything.
+     */
+    void unbind() override {}
+    void bind(Port &peer) override {}
+
   protected:
 
     /**
      * Called by the master port to unbind. Should never be called
      * directly.
      */
-    void unbind();
+    void slaveUnbind();
 
     /**
      * Called by the master port to bind. Should never be called
      * directly.
      */
-    void bind(MasterPort& master_port);
+    void slaveBind(MasterPort& master_port);
 
     /**
      * Receive an atomic request packet from the master port.
      */
     virtual Tick recvAtomic(PacketPtr pkt) = 0;
 
+    /**
+     * Receive an atomic request packet from the master port, and optionally
+     * provide a backdoor to the data being accessed.
+     */
+    virtual Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor);
+
     /**
      * Receive a functional request packet from the master port.
      */