qport.hh revision 8914
18914Sandreas.hansson@arm.com/*
28914Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited
38914Sandreas.hansson@arm.com * All rights reserved.
48914Sandreas.hansson@arm.com *
58914Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall
68914Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual
78914Sandreas.hansson@arm.com * property including but not limited to intellectual property relating
88914Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software
98914Sandreas.hansson@arm.com * licensed hereunder.  You may use the software subject to the license
108914Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated
118914Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software,
128914Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form.
138914Sandreas.hansson@arm.com *
148914Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
158914Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
168914Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
178914Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
188914Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
198914Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
208914Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
218914Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
228914Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
238914Sandreas.hansson@arm.com * this software without specific prior written permission.
248914Sandreas.hansson@arm.com *
258914Sandreas.hansson@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
268914Sandreas.hansson@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
278914Sandreas.hansson@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
288914Sandreas.hansson@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
298914Sandreas.hansson@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
308914Sandreas.hansson@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
318914Sandreas.hansson@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
328914Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
338914Sandreas.hansson@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
348914Sandreas.hansson@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
358914Sandreas.hansson@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
368914Sandreas.hansson@arm.com *
378914Sandreas.hansson@arm.com * Authors: Andreas Hansson
388914Sandreas.hansson@arm.com */
398914Sandreas.hansson@arm.com
408914Sandreas.hansson@arm.com#ifndef __MEM_QPORT_HH__
418914Sandreas.hansson@arm.com#define __MEM_QPORT_HH__
428914Sandreas.hansson@arm.com
438914Sandreas.hansson@arm.com/**
448914Sandreas.hansson@arm.com * @file
458914Sandreas.hansson@arm.com * Declaration of the queued port.
468914Sandreas.hansson@arm.com */
478914Sandreas.hansson@arm.com
488914Sandreas.hansson@arm.com#include "mem/packet_queue.hh"
498914Sandreas.hansson@arm.com#include "mem/port.hh"
508914Sandreas.hansson@arm.com
518914Sandreas.hansson@arm.com/**
528914Sandreas.hansson@arm.com * A queued port is a port that has an infinite queue for outgoing
538914Sandreas.hansson@arm.com * packets and thus decouples the module that wants to send
548914Sandreas.hansson@arm.com * request/responses from the flow control (retry mechanism) of the
558914Sandreas.hansson@arm.com * port. A queued port can be used by both a master and a slave. The
568914Sandreas.hansson@arm.com * queue is a parameter to allow tailoring of the queue implementation
578914Sandreas.hansson@arm.com * (used in the cache).
588914Sandreas.hansson@arm.com */
598914Sandreas.hansson@arm.comclass QueuedPort : public Port
608914Sandreas.hansson@arm.com{
618914Sandreas.hansson@arm.com
628914Sandreas.hansson@arm.com  protected:
638914Sandreas.hansson@arm.com
648914Sandreas.hansson@arm.com    /** Packet queue used to store outgoing requests and responses. */
658914Sandreas.hansson@arm.com    PacketQueue &queue;
668914Sandreas.hansson@arm.com
678914Sandreas.hansson@arm.com     /** This function is notification that the device should attempt to send a
688914Sandreas.hansson@arm.com      * packet again. */
698914Sandreas.hansson@arm.com    virtual void recvRetry() { queue.retry(); }
708914Sandreas.hansson@arm.com
718914Sandreas.hansson@arm.com    virtual void recvRangeChange() { }
728914Sandreas.hansson@arm.com
738914Sandreas.hansson@arm.com  public:
748914Sandreas.hansson@arm.com
758914Sandreas.hansson@arm.com    /**
768914Sandreas.hansson@arm.com     * Create a QueuedPort with a given name, owner, and a supplied
778914Sandreas.hansson@arm.com     * implementation of a packet queue. The external definition of
788914Sandreas.hansson@arm.com     * the queue enables e.g. the cache to implement a specific queue
798914Sandreas.hansson@arm.com     * behaviuor in a subclass, and provide the latter to the
808914Sandreas.hansson@arm.com     * QueuePort constructor.
818914Sandreas.hansson@arm.com     */
828914Sandreas.hansson@arm.com    QueuedPort(const std::string& name, MemObject* owner, PacketQueue &queue) :
838914Sandreas.hansson@arm.com        Port(name, owner), queue(queue)
848914Sandreas.hansson@arm.com    { }
858914Sandreas.hansson@arm.com
868914Sandreas.hansson@arm.com    virtual ~QueuedPort() { }
878914Sandreas.hansson@arm.com
888914Sandreas.hansson@arm.com    /** Check the list of buffered packets against the supplied
898914Sandreas.hansson@arm.com     * functional request. */
908914Sandreas.hansson@arm.com    bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); }
918914Sandreas.hansson@arm.com
928914Sandreas.hansson@arm.com    /**
938914Sandreas.hansson@arm.com     * Hook for draining the queued port.
948914Sandreas.hansson@arm.com     *
958914Sandreas.hansson@arm.com     * @param de an event which is used to signal back to the caller
968914Sandreas.hansson@arm.com     * @returns a number indicating how many times process will be called
978914Sandreas.hansson@arm.com     */
988914Sandreas.hansson@arm.com    unsigned int drain(Event *de) { return queue.drain(de); }
998914Sandreas.hansson@arm.com};
1008914Sandreas.hansson@arm.com
1018914Sandreas.hansson@arm.com#endif // __MEM_QPORT_HH__
102