Cache: Remove dangling doWriteback declaration
[gem5.git] / src / mem / port.hh
index 61c92d8e4388654e9d513474602deec2c803e58f..840952354716ec9c07fa73f5bf31073a4c11586a 100644 (file)
@@ -73,12 +73,19 @@ class MemObject;
  * opposite role.
  *
  * Each port has a name and an owner, and enables three basic types of
- * accesses to the peer port: sendFunctional, sendAtomic and
- * sendTiming.
+ * accesses to the peer port: functional, atomic and timing.
  */
 class Port
 {
 
+  public:
+
+    /** A type name for the port identifier. */
+    typedef int PortId;
+
+    /** A symbolic name for the absence of a port id. */
+    static const PortId INVALID_PORT_ID = -1;
+
   private:
 
     /** Descriptive name (for DPRINTF output) */
@@ -86,6 +93,12 @@ class Port
 
   protected:
 
+    /**
+     * A numeric identifier to distinguish ports in a vector, and set
+     * to INVALID_PORT_ID in case this port is not part of a vector.
+     */
+    const PortId id;
+
     /** A pointer to the peer port.  */
     Port* peer;
 
@@ -97,8 +110,9 @@ class Port
      *
      * @param _name Port name including the owners name
      * @param _owner The MemObject that is the structural owner of this port
+     * @param _id A port identifier for vector ports
      */
-    Port(const std::string& _name, MemObject& _owner);
+    Port(const std::string& _name, MemObject& _owner, PortId _id);
 
     /**
      * Virtual destructor due to inheritance.
@@ -110,63 +124,23 @@ class Port
     /** Return port name (for DPRINTF). */
     const std::string name() const { return portName; }
 
-  protected:
-
-    /** These functions are protected because they should only be
-     * called by a peer port, never directly by any outside object. */
+    /** Get the port id. */
+    PortId getId() const { return id; }
 
-    /**
-     * Receive a timing request or response packet from the peer port.
-     */
-    virtual bool recvTiming(PacketPtr pkt) = 0;
-
-    /**
-     * Receive a timing snoop request or snoop response packet from
-     * the peer port.
-     */
-    virtual bool recvTimingSnoop(PacketPtr pkt)
-    {
-        panic("%s was not expecting a timing snoop\n", name());
-        return false;
-    }
+  protected:
 
     /**
-     * Called by a peer port if sendTiming or sendTimingSnoop was
-     * unsuccesful, and had to wait.
+     * Called by a peer port if sendTimingReq, sendTimingResp or
+     * sendTimingSnoopResp was unsuccesful, and had to wait.
      */
     virtual void recvRetry() = 0;
 
   public:
 
-    /**
-     * Attempt to send a timing request or response packet to the peer
-     * port by calling its receive function. If the send does not
-     * succeed, as indicated by the return value, then the sender must
-     * wait for a recvRetry at which point it can re-issue a
-     * sendTiming.
-     *
-     * @param pkt Packet to send.
-     *
-     * @return If the send was succesful or not.
-    */
-    bool sendTiming(PacketPtr pkt) { return peer->recvTiming(pkt); }
-
-    /**
-     * Attempt to send a timing snoop request or snoop response packet
-     * to the peer port by calling its receive function. If the send
-     * does not succeed, as indicated by the return value, then the
-     * sender must wait for a recvRetry at which point it can re-issue
-     * a sendTimingSnoop.
-     *
-     * @param pkt Packet to send.
-     *
-     * @return If the send was succesful or not.
-    */
-    bool sendTimingSnoop(PacketPtr pkt) { return peer->recvTimingSnoop(pkt); }
-
     /**
      * Send a retry to a peer port that previously attempted a
-     * sendTiming or sendTimingSnoop which was unsuccessful.
+     * sendTimingReq, sendTimingResp or sendTimingSnoopResp which was
+     * unsuccessful.
      */
     void sendRetry() { return peer->recvRetry(); }
 
@@ -184,13 +158,16 @@ class SlavePort;
 class MasterPort : public Port
 {
 
+    friend class SlavePort;
+
   private:
 
     SlavePort* _slavePort;
 
   public:
 
-    MasterPort(const std::string& name, MemObject* owner);
+    MasterPort(const std::string& name, MemObject* owner,
+               PortId id = INVALID_PORT_ID);
     virtual ~MasterPort();
 
     void bind(SlavePort& slave_port);
@@ -218,30 +195,28 @@ class MasterPort : public Port
     void sendFunctional(PacketPtr pkt);
 
     /**
-     * Receive an atomic snoop request packet from the slave port.
-     */
-    virtual Tick recvAtomicSnoop(PacketPtr pkt)
-    {
-        panic("%s was not expecting an atomic snoop\n", name());
-        return 0;
-    }
-
-    /**
-     * Receive a functional snoop request packet from the slave port.
-     */
-    virtual void recvFunctionalSnoop(PacketPtr pkt)
-    {
-        panic("%s was not expecting a functional snoop\n", name());
-    }
+     * Attempt to send a timing request to the slave port by calling
+     * its corresponding receive function. If the send does not
+     * succeed, as indicated by the return value, then the sender must
+     * wait for a recvRetry at which point it can re-issue a
+     * sendTimingReq.
+     *
+     * @param pkt Packet to send.
+     *
+     * @return If the send was succesful or not.
+    */
+    bool sendTimingReq(PacketPtr pkt);
 
     /**
-     * Called to receive an address range change from the peer slave
-     * port. the default implementation ignored the change and does
-     * nothing. Override this function in a derived class if the owner
-     * needs to be aware of he laesddress ranges, e.g. in an
-     * interconnect component like a bus.
+     * Attempt to send a timing snoop response packet to the slave
+     * port by calling its corresponding receive function. If the send
+     * does not succeed, as indicated by the return value, then the
+     * sender must wait for a recvRetry at which point it can re-issue
+     * a sendTimingSnoopResp.
+     *
+     * @param pkt Packet to send.
      */
-    virtual void recvRangeChange() { }
+    bool sendTimingSnoopResp(PacketPtr pkt);
 
     /**
      * Determine if this master port is snooping or not. The default
@@ -269,6 +244,47 @@ class MasterPort : public Port
      * that address throughout the memory system.  For debugging.
      */
     void printAddr(Addr a);
+
+  protected:
+
+    /**
+     * Receive an atomic snoop request packet from the slave port.
+     */
+    virtual Tick recvAtomicSnoop(PacketPtr pkt)
+    {
+        panic("%s was not expecting an atomic snoop request\n", name());
+        return 0;
+    }
+
+    /**
+     * Receive a functional snoop request packet from the slave port.
+     */
+    virtual void recvFunctionalSnoop(PacketPtr pkt)
+    {
+        panic("%s was not expecting a functional snoop request\n", name());
+    }
+
+    /**
+     * Receive a timing response from the slave port.
+     */
+    virtual bool recvTimingResp(PacketPtr pkt) = 0;
+
+    /**
+     * Receive a timing snoop request from the slave port.
+     */
+    virtual void recvTimingSnoopReq(PacketPtr pkt)
+    {
+        panic("%s was not expecting a timing snoop request\n", name());
+    }
+
+    /**
+     * Called to receive an address range change from the peer slave
+     * port. the default implementation ignored the change and does
+     * nothing. Override this function in a derived class if the owner
+     * needs to be aware of he laesddress ranges, e.g. in an
+     * interconnect component like a bus.
+     */
+    virtual void recvRangeChange() { }
 };
 
 /**
@@ -280,13 +296,16 @@ class MasterPort : public Port
 class SlavePort : public Port
 {
 
+    friend class MasterPort;
+
   private:
 
     MasterPort* _masterPort;
 
   public:
 
-    SlavePort(const std::string& name, MemObject* owner);
+    SlavePort(const std::string& name, MemObject* owner,
+              PortId id = INVALID_PORT_ID);
     virtual ~SlavePort();
 
     void bind(MasterPort& master_port);
@@ -314,14 +333,26 @@ class SlavePort : public Port
     void sendFunctionalSnoop(PacketPtr pkt);
 
     /**
-     * Receive an atomic request packet from the master port.
-     */
-    virtual Tick recvAtomic(PacketPtr pkt) = 0;
+     * Attempt to send a timing response to the master port by calling
+     * its corresponding receive function. If the send does not
+     * succeed, as indicated by the return value, then the sender must
+     * wait for a recvRetry at which point it can re-issue a
+     * sendTimingResp.
+     *
+     * @param pkt Packet to send.
+     *
+     * @return If the send was succesful or not.
+    */
+    bool sendTimingResp(PacketPtr pkt);
 
     /**
-     * Receive a functional request packet from the master port.
+     * Attempt to send a timing snoop request packet to the master port
+     * by calling its corresponding receive function. Snoop requests
+     * always succeed and hence no return value is needed.
+     *
+     * @param pkt Packet to send.
      */
-    virtual void recvFunctional(PacketPtr pkt) = 0;
+    void sendTimingSnoopReq(PacketPtr pkt);
 
     /**
      * Called by a peer port in order to determine the block size of
@@ -347,6 +378,32 @@ class SlavePort : public Port
      * @return a list of ranges responded to
      */
     virtual AddrRangeList getAddrRanges() = 0;
+
+  protected:
+
+    /**
+     * Receive an atomic request packet from the master port.
+     */
+    virtual Tick recvAtomic(PacketPtr pkt) = 0;
+
+    /**
+     * Receive a functional request packet from the master port.
+     */
+    virtual void recvFunctional(PacketPtr pkt) = 0;
+
+    /**
+     * Receive a timing request from the master port.
+     */
+    virtual bool recvTimingReq(PacketPtr pkt) = 0;
+
+    /**
+     * Receive a timing snoop response from the master port.
+     */
+    virtual bool recvTimingSnoopResp(PacketPtr pkt)
+    {
+        panic("%s was not expecting a timing snoop response\n", name());
+    }
+
 };
 
 #endif //__MEM_PORT_HH__