port.hh revision 13769
12381SN/A/*
212342Snikos.nikoleris@arm.com * Copyright (c) 2011-2012,2015,2017 ARM Limited
38711Sandreas.hansson@arm.com * All rights reserved
48711Sandreas.hansson@arm.com *
58711Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall
68711Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual
78711Sandreas.hansson@arm.com * property including but not limited to intellectual property relating
88711Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software
98711Sandreas.hansson@arm.com * licensed hereunder.  You may use the software subject to the license
108711Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated
118711Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software,
128711Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form.
138711Sandreas.hansson@arm.com *
142381SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
152381SN/A * All rights reserved.
162381SN/A *
172381SN/A * Redistribution and use in source and binary forms, with or without
182381SN/A * modification, are permitted provided that the following conditions are
192381SN/A * met: redistributions of source code must retain the above copyright
202381SN/A * notice, this list of conditions and the following disclaimer;
212381SN/A * redistributions in binary form must reproduce the above copyright
222381SN/A * notice, this list of conditions and the following disclaimer in the
232381SN/A * documentation and/or other materials provided with the distribution;
242381SN/A * neither the name of the copyright holders nor the names of its
252381SN/A * contributors may be used to endorse or promote products derived from
262381SN/A * this software without specific prior written permission.
272381SN/A *
282381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665Ssaidi@eecs.umich.edu *
402665Ssaidi@eecs.umich.edu * Authors: Ron Dreslinski
418853Sandreas.hansson@arm.com *          Andreas Hansson
428922Swilliam.wang@arm.com *          William Wang
432381SN/A */
442381SN/A
452381SN/A/**
462381SN/A * @file
478922Swilliam.wang@arm.com * Port Object Declaration.
482381SN/A */
492381SN/A
502381SN/A#ifndef __MEM_PORT_HH__
512381SN/A#define __MEM_PORT_HH__
522381SN/A
539235Sandreas.hansson@arm.com#include "base/addr_range.hh"
542381SN/A#include "mem/packet.hh"
552381SN/A
563401Sktlim@umich.educlass MemObject;
573401Sktlim@umich.edu
582381SN/A/**
598922Swilliam.wang@arm.com * Ports are used to interface memory objects to each other. A port is
608922Swilliam.wang@arm.com * either a master or a slave and the connected peer is always of the
619087Sandreas.hansson@arm.com * opposite role. Each port has a name, an owner, and an identifier.
622381SN/A */
638708Sandreas.hansson@arm.comclass Port
642381SN/A{
658922Swilliam.wang@arm.com
668922Swilliam.wang@arm.com  private:
678922Swilliam.wang@arm.com
688922Swilliam.wang@arm.com    /** Descriptive name (for DPRINTF output) */
698922Swilliam.wang@arm.com    std::string portName;
708922Swilliam.wang@arm.com
715476Snate@binkert.org  protected:
722640Sstever@eecs.umich.edu
738965Sandreas.hansson@arm.com    /**
748965Sandreas.hansson@arm.com     * A numeric identifier to distinguish ports in a vector, and set
759031Sandreas.hansson@arm.com     * to InvalidPortID in case this port is not part of a vector.
768965Sandreas.hansson@arm.com     */
779031Sandreas.hansson@arm.com    const PortID id;
788965Sandreas.hansson@arm.com
798922Swilliam.wang@arm.com    /**
808922Swilliam.wang@arm.com     * Abstract base class for ports
818922Swilliam.wang@arm.com     *
828922Swilliam.wang@arm.com     * @param _name Port name including the owners name
838965Sandreas.hansson@arm.com     * @param _id A port identifier for vector ports
848922Swilliam.wang@arm.com     */
8513769Sgabeblack@google.com    Port(const std::string& _name, PortID _id);
868922Swilliam.wang@arm.com
878922Swilliam.wang@arm.com    /**
888922Swilliam.wang@arm.com     * Virtual destructor due to inheritance.
898922Swilliam.wang@arm.com     */
908922Swilliam.wang@arm.com    virtual ~Port();
913401Sktlim@umich.edu
922381SN/A  public:
932640Sstever@eecs.umich.edu
942640Sstever@eecs.umich.edu    /** Return port name (for DPRINTF). */
958922Swilliam.wang@arm.com    const std::string name() const { return portName; }
964190Ssaidi@eecs.umich.edu
978965Sandreas.hansson@arm.com    /** Get the port id. */
989031Sandreas.hansson@arm.com    PortID getId() const { return id; }
998965Sandreas.hansson@arm.com
1008922Swilliam.wang@arm.com};
1018922Swilliam.wang@arm.com
1028922Swilliam.wang@arm.com/** Forward declaration */
1039294Sandreas.hansson@arm.comclass BaseSlavePort;
1049294Sandreas.hansson@arm.com
1059294Sandreas.hansson@arm.com/**
1069294Sandreas.hansson@arm.com * A BaseMasterPort is a protocol-agnostic master port, responsible
1079294Sandreas.hansson@arm.com * only for the structural connection to a slave port. The final
1089294Sandreas.hansson@arm.com * master port that inherits from the base class must override the
1099294Sandreas.hansson@arm.com * bind member function for the specific slave port class.
1109294Sandreas.hansson@arm.com */
1119294Sandreas.hansson@arm.comclass BaseMasterPort : public Port
1129294Sandreas.hansson@arm.com{
1139294Sandreas.hansson@arm.com
1149294Sandreas.hansson@arm.com  protected:
1159294Sandreas.hansson@arm.com
1169294Sandreas.hansson@arm.com    BaseSlavePort* _baseSlavePort;
1179294Sandreas.hansson@arm.com
11813769Sgabeblack@google.com    BaseMasterPort(const std::string& name, PortID id=InvalidPortID);
1199294Sandreas.hansson@arm.com    virtual ~BaseMasterPort();
1209294Sandreas.hansson@arm.com
1219294Sandreas.hansson@arm.com  public:
1229294Sandreas.hansson@arm.com
1239294Sandreas.hansson@arm.com    virtual void bind(BaseSlavePort& slave_port) = 0;
1249294Sandreas.hansson@arm.com    virtual void unbind() = 0;
1259294Sandreas.hansson@arm.com    BaseSlavePort& getSlavePort() const;
1269294Sandreas.hansson@arm.com    bool isConnected() const;
1279294Sandreas.hansson@arm.com
1289294Sandreas.hansson@arm.com};
1299294Sandreas.hansson@arm.com
1309294Sandreas.hansson@arm.com/**
1319294Sandreas.hansson@arm.com * A BaseSlavePort is a protocol-agnostic slave port, responsible
1329294Sandreas.hansson@arm.com * only for the structural connection to a master port.
1339294Sandreas.hansson@arm.com */
1349294Sandreas.hansson@arm.comclass BaseSlavePort : public Port
1359294Sandreas.hansson@arm.com{
1369294Sandreas.hansson@arm.com
1379294Sandreas.hansson@arm.com  protected:
1389294Sandreas.hansson@arm.com
1399294Sandreas.hansson@arm.com    BaseMasterPort* _baseMasterPort;
1409294Sandreas.hansson@arm.com
14113769Sgabeblack@google.com    BaseSlavePort(const std::string& name, PortID id=InvalidPortID);
1429294Sandreas.hansson@arm.com    virtual ~BaseSlavePort();
1439294Sandreas.hansson@arm.com
1449294Sandreas.hansson@arm.com  public:
1459294Sandreas.hansson@arm.com
1469294Sandreas.hansson@arm.com    BaseMasterPort& getMasterPort() const;
1479294Sandreas.hansson@arm.com    bool isConnected() const;
1489294Sandreas.hansson@arm.com
1499294Sandreas.hansson@arm.com};
1509294Sandreas.hansson@arm.com
1519294Sandreas.hansson@arm.com/** Forward declaration */
1528922Swilliam.wang@arm.comclass SlavePort;
1538922Swilliam.wang@arm.com
1548922Swilliam.wang@arm.com/**
1559294Sandreas.hansson@arm.com * A MasterPort is a specialisation of a BaseMasterPort, which
1569294Sandreas.hansson@arm.com * implements the default protocol for the three different level of
1579294Sandreas.hansson@arm.com * transport functions. In addition to the basic functionality of
1589294Sandreas.hansson@arm.com * sending packets, it also has functions to receive range changes or
1599294Sandreas.hansson@arm.com * determine if the port is snooping or not.
1608922Swilliam.wang@arm.com */
1619294Sandreas.hansson@arm.comclass MasterPort : public BaseMasterPort
1628922Swilliam.wang@arm.com{
1638922Swilliam.wang@arm.com
1648975Sandreas.hansson@arm.com    friend class SlavePort;
1658975Sandreas.hansson@arm.com
1668922Swilliam.wang@arm.com  private:
1678922Swilliam.wang@arm.com
1688922Swilliam.wang@arm.com    SlavePort* _slavePort;
1698922Swilliam.wang@arm.com
17013769Sgabeblack@google.com  protected:
17113769Sgabeblack@google.com
17213769Sgabeblack@google.com    MemObject& owner;
17313769Sgabeblack@google.com
1748922Swilliam.wang@arm.com  public:
1758922Swilliam.wang@arm.com
17613769Sgabeblack@google.com    MasterPort(const std::string& name, MemObject* _owner,
17713769Sgabeblack@google.com               PortID id=InvalidPortID);
1788922Swilliam.wang@arm.com    virtual ~MasterPort();
1798922Swilliam.wang@arm.com
1809178Sandreas.hansson@arm.com    /**
1819178Sandreas.hansson@arm.com     * Bind this master port to a slave port. This also does the
1829178Sandreas.hansson@arm.com     * mirror action and binds the slave port to the master port.
1839178Sandreas.hansson@arm.com     */
1849294Sandreas.hansson@arm.com    void bind(BaseSlavePort& slave_port);
1859178Sandreas.hansson@arm.com
1869178Sandreas.hansson@arm.com    /**
1879178Sandreas.hansson@arm.com     * Unbind this master port and the associated slave port.
1889178Sandreas.hansson@arm.com     */
1899178Sandreas.hansson@arm.com    void unbind();
1909178Sandreas.hansson@arm.com
1918922Swilliam.wang@arm.com    /**
1928948Sandreas.hansson@arm.com     * Send an atomic request packet, where the data is moved and the
1938948Sandreas.hansson@arm.com     * state is updated in zero time, without interleaving with other
1948948Sandreas.hansson@arm.com     * memory accesses.
1958948Sandreas.hansson@arm.com     *
1968948Sandreas.hansson@arm.com     * @param pkt Packet to send.
1978948Sandreas.hansson@arm.com     *
1988948Sandreas.hansson@arm.com     * @return Estimated latency of access.
1998948Sandreas.hansson@arm.com     */
2008948Sandreas.hansson@arm.com    Tick sendAtomic(PacketPtr pkt);
2018948Sandreas.hansson@arm.com
2028948Sandreas.hansson@arm.com    /**
2038948Sandreas.hansson@arm.com     * Send a functional request packet, where the data is instantly
2048948Sandreas.hansson@arm.com     * updated everywhere in the memory system, without affecting the
2058948Sandreas.hansson@arm.com     * current state of any block or moving the block.
2068948Sandreas.hansson@arm.com     *
2078948Sandreas.hansson@arm.com     * @param pkt Packet to send.
2088948Sandreas.hansson@arm.com     */
2098948Sandreas.hansson@arm.com    void sendFunctional(PacketPtr pkt);
2108948Sandreas.hansson@arm.com
2118948Sandreas.hansson@arm.com    /**
2128975Sandreas.hansson@arm.com     * Attempt to send a timing request to the slave port by calling
2138975Sandreas.hansson@arm.com     * its corresponding receive function. If the send does not
2148975Sandreas.hansson@arm.com     * succeed, as indicated by the return value, then the sender must
21510713Sandreas.hansson@arm.com     * wait for a recvReqRetry at which point it can re-issue a
2168975Sandreas.hansson@arm.com     * sendTimingReq.
2178975Sandreas.hansson@arm.com     *
2188975Sandreas.hansson@arm.com     * @param pkt Packet to send.
2198975Sandreas.hansson@arm.com     *
2208975Sandreas.hansson@arm.com     * @return If the send was succesful or not.
2218975Sandreas.hansson@arm.com    */
2228975Sandreas.hansson@arm.com    bool sendTimingReq(PacketPtr pkt);
2238948Sandreas.hansson@arm.com
2248948Sandreas.hansson@arm.com    /**
22512342Snikos.nikoleris@arm.com     * Check if the slave can handle a timing request.
22612342Snikos.nikoleris@arm.com     *
22712342Snikos.nikoleris@arm.com     * If the send cannot be handled at the moment, as indicated by
22812342Snikos.nikoleris@arm.com     * the return value, then the sender will receive a recvReqRetry
22912342Snikos.nikoleris@arm.com     * at which point it can re-issue a sendTimingReq.
23012342Snikos.nikoleris@arm.com     *
23112342Snikos.nikoleris@arm.com     * @param pkt Packet to send.
23212342Snikos.nikoleris@arm.com     *
23312342Snikos.nikoleris@arm.com     * @return If the send was succesful or not.
23412342Snikos.nikoleris@arm.com     */
23512342Snikos.nikoleris@arm.com    bool tryTiming(PacketPtr pkt) const;
23612342Snikos.nikoleris@arm.com
23712342Snikos.nikoleris@arm.com    /**
2388975Sandreas.hansson@arm.com     * Attempt to send a timing snoop response packet to the slave
2398975Sandreas.hansson@arm.com     * port by calling its corresponding receive function. If the send
2408975Sandreas.hansson@arm.com     * does not succeed, as indicated by the return value, then the
24110713Sandreas.hansson@arm.com     * sender must wait for a recvRetrySnoop at which point it can
24210713Sandreas.hansson@arm.com     * re-issue a sendTimingSnoopResp.
2438975Sandreas.hansson@arm.com     *
2448975Sandreas.hansson@arm.com     * @param pkt Packet to send.
2458948Sandreas.hansson@arm.com     */
2468975Sandreas.hansson@arm.com    bool sendTimingSnoopResp(PacketPtr pkt);
2478922Swilliam.wang@arm.com
2488922Swilliam.wang@arm.com    /**
2499087Sandreas.hansson@arm.com     * Send a retry to the slave port that previously attempted a
25010713Sandreas.hansson@arm.com     * sendTimingResp to this master port and failed. Note that this
25110713Sandreas.hansson@arm.com     * is virtual so that the "fake" snoop response port in the
25210713Sandreas.hansson@arm.com     * coherent crossbar can override the behaviour.
2539087Sandreas.hansson@arm.com     */
25410713Sandreas.hansson@arm.com    virtual void sendRetryResp();
2559087Sandreas.hansson@arm.com
2569087Sandreas.hansson@arm.com    /**
2578922Swilliam.wang@arm.com     * Determine if this master port is snooping or not. The default
2588711Sandreas.hansson@arm.com     * implementation returns false and thus tells the neighbour we
2598922Swilliam.wang@arm.com     * are not snooping. Any master port that wants to receive snoop
2608922Swilliam.wang@arm.com     * requests (e.g. a cache connected to a bus) has to override this
2618922Swilliam.wang@arm.com     * function.
2628711Sandreas.hansson@arm.com     *
2638711Sandreas.hansson@arm.com     * @return true if the port should be considered a snooper
2648711Sandreas.hansson@arm.com     */
2658922Swilliam.wang@arm.com    virtual bool isSnooping() const { return false; }
2662381SN/A
2678711Sandreas.hansson@arm.com    /**
2689089Sandreas.hansson@arm.com     * Get the address ranges of the connected slave port.
2699089Sandreas.hansson@arm.com     */
2709089Sandreas.hansson@arm.com    AddrRangeList getAddrRanges() const;
2719089Sandreas.hansson@arm.com
2725314Sstever@gmail.com    /** Inject a PrintReq for the given address to print the state of
2735314Sstever@gmail.com     * that address throughout the memory system.  For debugging.
2745314Sstever@gmail.com     */
2755314Sstever@gmail.com    void printAddr(Addr a);
2768975Sandreas.hansson@arm.com
2778975Sandreas.hansson@arm.com  protected:
2788975Sandreas.hansson@arm.com
2798975Sandreas.hansson@arm.com    /**
2808975Sandreas.hansson@arm.com     * Receive an atomic snoop request packet from the slave port.
2818975Sandreas.hansson@arm.com     */
2828975Sandreas.hansson@arm.com    virtual Tick recvAtomicSnoop(PacketPtr pkt)
2838975Sandreas.hansson@arm.com    {
2848975Sandreas.hansson@arm.com        panic("%s was not expecting an atomic snoop request\n", name());
2858975Sandreas.hansson@arm.com        return 0;
2868975Sandreas.hansson@arm.com    }
2878975Sandreas.hansson@arm.com
2888975Sandreas.hansson@arm.com    /**
2898975Sandreas.hansson@arm.com     * Receive a functional snoop request packet from the slave port.
2908975Sandreas.hansson@arm.com     */
2918975Sandreas.hansson@arm.com    virtual void recvFunctionalSnoop(PacketPtr pkt)
2928975Sandreas.hansson@arm.com    {
2938975Sandreas.hansson@arm.com        panic("%s was not expecting a functional snoop request\n", name());
2948975Sandreas.hansson@arm.com    }
2958975Sandreas.hansson@arm.com
2968975Sandreas.hansson@arm.com    /**
2978975Sandreas.hansson@arm.com     * Receive a timing response from the slave port.
2988975Sandreas.hansson@arm.com     */
2998975Sandreas.hansson@arm.com    virtual bool recvTimingResp(PacketPtr pkt) = 0;
3008975Sandreas.hansson@arm.com
3018975Sandreas.hansson@arm.com    /**
3028975Sandreas.hansson@arm.com     * Receive a timing snoop request from the slave port.
3038975Sandreas.hansson@arm.com     */
3048975Sandreas.hansson@arm.com    virtual void recvTimingSnoopReq(PacketPtr pkt)
3058975Sandreas.hansson@arm.com    {
3068975Sandreas.hansson@arm.com        panic("%s was not expecting a timing snoop request\n", name());
3078975Sandreas.hansson@arm.com    }
3088975Sandreas.hansson@arm.com
3098975Sandreas.hansson@arm.com    /**
31010713Sandreas.hansson@arm.com     * Called by the slave port if sendTimingReq was called on this
31110713Sandreas.hansson@arm.com     * master port (causing recvTimingReq to be called on the slave
31210713Sandreas.hansson@arm.com     * port) and was unsuccesful.
3139087Sandreas.hansson@arm.com     */
31410713Sandreas.hansson@arm.com    virtual void recvReqRetry() = 0;
31510713Sandreas.hansson@arm.com
31610713Sandreas.hansson@arm.com    /**
31710713Sandreas.hansson@arm.com     * Called by the slave port if sendTimingSnoopResp was called on this
31810713Sandreas.hansson@arm.com     * master port (causing recvTimingSnoopResp to be called on the slave
31910713Sandreas.hansson@arm.com     * port) and was unsuccesful.
32010713Sandreas.hansson@arm.com     */
32110713Sandreas.hansson@arm.com    virtual void recvRetrySnoopResp()
32210713Sandreas.hansson@arm.com    {
32310713Sandreas.hansson@arm.com        panic("%s was not expecting a snoop retry\n", name());
32410713Sandreas.hansson@arm.com    }
3259087Sandreas.hansson@arm.com
3269087Sandreas.hansson@arm.com    /**
3278975Sandreas.hansson@arm.com     * Called to receive an address range change from the peer slave
3289325Sandreas.hansson@arm.com     * port. The default implementation ignores the change and does
3298975Sandreas.hansson@arm.com     * nothing. Override this function in a derived class if the owner
3309325Sandreas.hansson@arm.com     * needs to be aware of the address ranges, e.g. in an
3318975Sandreas.hansson@arm.com     * interconnect component like a bus.
3328975Sandreas.hansson@arm.com     */
3338975Sandreas.hansson@arm.com    virtual void recvRangeChange() { }
3342381SN/A};
3352381SN/A
3368922Swilliam.wang@arm.com/**
3378922Swilliam.wang@arm.com * A SlavePort is a specialisation of a port. In addition to the
3388922Swilliam.wang@arm.com * basic functionality of sending packets to its master peer, it also
3398922Swilliam.wang@arm.com * has functions specific to a slave, e.g. to send range changes
3408922Swilliam.wang@arm.com * and get the address ranges that the port responds to.
3418922Swilliam.wang@arm.com */
3429294Sandreas.hansson@arm.comclass SlavePort : public BaseSlavePort
3438922Swilliam.wang@arm.com{
3448922Swilliam.wang@arm.com
3458975Sandreas.hansson@arm.com    friend class MasterPort;
3468975Sandreas.hansson@arm.com
3478922Swilliam.wang@arm.com  private:
3488922Swilliam.wang@arm.com
3498922Swilliam.wang@arm.com    MasterPort* _masterPort;
3508922Swilliam.wang@arm.com
35113769Sgabeblack@google.com  protected:
35213769Sgabeblack@google.com
35313769Sgabeblack@google.com    MemObject& owner;
35413769Sgabeblack@google.com
3558922Swilliam.wang@arm.com  public:
3568922Swilliam.wang@arm.com
35713769Sgabeblack@google.com    SlavePort(const std::string& name, MemObject* _owner,
35813769Sgabeblack@google.com              PortID id=InvalidPortID);
3598922Swilliam.wang@arm.com    virtual ~SlavePort();
3608922Swilliam.wang@arm.com
3618922Swilliam.wang@arm.com    /**
3628948Sandreas.hansson@arm.com     * Send an atomic snoop request packet, where the data is moved
3638948Sandreas.hansson@arm.com     * and the state is updated in zero time, without interleaving
3648948Sandreas.hansson@arm.com     * with other memory accesses.
3658948Sandreas.hansson@arm.com     *
3668948Sandreas.hansson@arm.com     * @param pkt Snoop packet to send.
3678948Sandreas.hansson@arm.com     *
3688948Sandreas.hansson@arm.com     * @return Estimated latency of access.
3698948Sandreas.hansson@arm.com     */
3708948Sandreas.hansson@arm.com    Tick sendAtomicSnoop(PacketPtr pkt);
3718948Sandreas.hansson@arm.com
3728948Sandreas.hansson@arm.com    /**
3738948Sandreas.hansson@arm.com     * Send a functional snoop request packet, where the data is
3748948Sandreas.hansson@arm.com     * instantly updated everywhere in the memory system, without
3758948Sandreas.hansson@arm.com     * affecting the current state of any block or moving the block.
3768948Sandreas.hansson@arm.com     *
3778948Sandreas.hansson@arm.com     * @param pkt Snoop packet to send.
3788948Sandreas.hansson@arm.com     */
3798948Sandreas.hansson@arm.com    void sendFunctionalSnoop(PacketPtr pkt);
3808948Sandreas.hansson@arm.com
3818948Sandreas.hansson@arm.com    /**
3828975Sandreas.hansson@arm.com     * Attempt to send a timing response to the master port by calling
3838975Sandreas.hansson@arm.com     * its corresponding receive function. If the send does not
3848975Sandreas.hansson@arm.com     * succeed, as indicated by the return value, then the sender must
38510713Sandreas.hansson@arm.com     * wait for a recvRespRetry at which point it can re-issue a
3868975Sandreas.hansson@arm.com     * sendTimingResp.
3878975Sandreas.hansson@arm.com     *
3888975Sandreas.hansson@arm.com     * @param pkt Packet to send.
3898975Sandreas.hansson@arm.com     *
3908975Sandreas.hansson@arm.com     * @return If the send was succesful or not.
3918975Sandreas.hansson@arm.com    */
3928975Sandreas.hansson@arm.com    bool sendTimingResp(PacketPtr pkt);
3938948Sandreas.hansson@arm.com
3948948Sandreas.hansson@arm.com    /**
3958975Sandreas.hansson@arm.com     * Attempt to send a timing snoop request packet to the master port
3968975Sandreas.hansson@arm.com     * by calling its corresponding receive function. Snoop requests
3978975Sandreas.hansson@arm.com     * always succeed and hence no return value is needed.
3988975Sandreas.hansson@arm.com     *
3998975Sandreas.hansson@arm.com     * @param pkt Packet to send.
4008948Sandreas.hansson@arm.com     */
4018975Sandreas.hansson@arm.com    void sendTimingSnoopReq(PacketPtr pkt);
4028948Sandreas.hansson@arm.com
4038948Sandreas.hansson@arm.com    /**
4049087Sandreas.hansson@arm.com     * Send a retry to the master port that previously attempted a
40510713Sandreas.hansson@arm.com     * sendTimingReq to this slave port and failed.
4069087Sandreas.hansson@arm.com     */
40710713Sandreas.hansson@arm.com    void sendRetryReq();
40810713Sandreas.hansson@arm.com
40910713Sandreas.hansson@arm.com    /**
41010713Sandreas.hansson@arm.com     * Send a retry to the master port that previously attempted a
41110713Sandreas.hansson@arm.com     * sendTimingSnoopResp to this slave port and failed.
41210713Sandreas.hansson@arm.com     */
41310713Sandreas.hansson@arm.com    void sendRetrySnoopResp();
4149087Sandreas.hansson@arm.com
4159087Sandreas.hansson@arm.com    /**
4169088Sandreas.hansson@arm.com     * Find out if the peer master port is snooping or not.
4179088Sandreas.hansson@arm.com     *
4189088Sandreas.hansson@arm.com     * @return true if the peer master port is snooping
4199088Sandreas.hansson@arm.com     */
4209088Sandreas.hansson@arm.com    bool isSnooping() const { return _masterPort->isSnooping(); }
4219088Sandreas.hansson@arm.com
4229088Sandreas.hansson@arm.com    /**
4238922Swilliam.wang@arm.com     * Called by the owner to send a range change
4248922Swilliam.wang@arm.com     */
42510413SCurtis.Dunham@arm.com    void sendRangeChange() const {
42610413SCurtis.Dunham@arm.com        if (!_masterPort)
42710413SCurtis.Dunham@arm.com            fatal("%s cannot sendRangeChange() without master port", name());
42810413SCurtis.Dunham@arm.com        _masterPort->recvRangeChange();
42910413SCurtis.Dunham@arm.com    }
4308922Swilliam.wang@arm.com
4318922Swilliam.wang@arm.com    /**
4328922Swilliam.wang@arm.com     * Get a list of the non-overlapping address ranges the owner is
4338922Swilliam.wang@arm.com     * responsible for. All slave ports must override this function
4348922Swilliam.wang@arm.com     * and return a populated list with at least one item.
4358922Swilliam.wang@arm.com     *
4368922Swilliam.wang@arm.com     * @return a list of ranges responded to
4378922Swilliam.wang@arm.com     */
4389090Sandreas.hansson@arm.com    virtual AddrRangeList getAddrRanges() const = 0;
4398975Sandreas.hansson@arm.com
4408975Sandreas.hansson@arm.com  protected:
4418975Sandreas.hansson@arm.com
4428975Sandreas.hansson@arm.com    /**
4439178Sandreas.hansson@arm.com     * Called by the master port to unbind. Should never be called
4449178Sandreas.hansson@arm.com     * directly.
4459178Sandreas.hansson@arm.com     */
4469178Sandreas.hansson@arm.com    void unbind();
4479178Sandreas.hansson@arm.com
4489178Sandreas.hansson@arm.com    /**
4499178Sandreas.hansson@arm.com     * Called by the master port to bind. Should never be called
4509178Sandreas.hansson@arm.com     * directly.
4519178Sandreas.hansson@arm.com     */
4529178Sandreas.hansson@arm.com    void bind(MasterPort& master_port);
4539178Sandreas.hansson@arm.com
4549178Sandreas.hansson@arm.com    /**
4558975Sandreas.hansson@arm.com     * Receive an atomic request packet from the master port.
4568975Sandreas.hansson@arm.com     */
4578975Sandreas.hansson@arm.com    virtual Tick recvAtomic(PacketPtr pkt) = 0;
4588975Sandreas.hansson@arm.com
4598975Sandreas.hansson@arm.com    /**
4608975Sandreas.hansson@arm.com     * Receive a functional request packet from the master port.
4618975Sandreas.hansson@arm.com     */
4628975Sandreas.hansson@arm.com    virtual void recvFunctional(PacketPtr pkt) = 0;
4638975Sandreas.hansson@arm.com
4648975Sandreas.hansson@arm.com    /**
4658975Sandreas.hansson@arm.com     * Receive a timing request from the master port.
4668975Sandreas.hansson@arm.com     */
4678975Sandreas.hansson@arm.com    virtual bool recvTimingReq(PacketPtr pkt) = 0;
4688975Sandreas.hansson@arm.com
4698975Sandreas.hansson@arm.com    /**
47012342Snikos.nikoleris@arm.com     * Availability request from the master port.
47112342Snikos.nikoleris@arm.com     */
47212342Snikos.nikoleris@arm.com    virtual bool tryTiming(PacketPtr pkt) {
47312342Snikos.nikoleris@arm.com        panic("%s was not expecting a %s\n", name(), __func__);
47412342Snikos.nikoleris@arm.com    }
47512342Snikos.nikoleris@arm.com
47612342Snikos.nikoleris@arm.com    /**
4778975Sandreas.hansson@arm.com     * Receive a timing snoop response from the master port.
4788975Sandreas.hansson@arm.com     */
4798975Sandreas.hansson@arm.com    virtual bool recvTimingSnoopResp(PacketPtr pkt)
4808975Sandreas.hansson@arm.com    {
4818975Sandreas.hansson@arm.com        panic("%s was not expecting a timing snoop response\n", name());
4828975Sandreas.hansson@arm.com    }
4838975Sandreas.hansson@arm.com
4849087Sandreas.hansson@arm.com    /**
4859087Sandreas.hansson@arm.com     * Called by the master port if sendTimingResp was called on this
4869087Sandreas.hansson@arm.com     * slave port (causing recvTimingResp to be called on the master
4879087Sandreas.hansson@arm.com     * port) and was unsuccesful.
4889087Sandreas.hansson@arm.com     */
48910713Sandreas.hansson@arm.com    virtual void recvRespRetry() = 0;
4909087Sandreas.hansson@arm.com
4918922Swilliam.wang@arm.com};
4928922Swilliam.wang@arm.com
4932381SN/A#endif //__MEM_PORT_HH__
494