qport.hh revision 9163
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 */ 598922Swilliam.wang@arm.comclass QueuedSlavePort : public SlavePort 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. */ 658975Sandreas.hansson@arm.com SlavePacketQueue &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 718922Swilliam.wang@arm.com public: 728922Swilliam.wang@arm.com 738922Swilliam.wang@arm.com /** 748922Swilliam.wang@arm.com * Create a QueuedPort with a given name, owner, and a supplied 758922Swilliam.wang@arm.com * implementation of a packet queue. The external definition of 768922Swilliam.wang@arm.com * the queue enables e.g. the cache to implement a specific queue 778922Swilliam.wang@arm.com * behaviuor in a subclass, and provide the latter to the 788922Swilliam.wang@arm.com * QueuePort constructor. 798922Swilliam.wang@arm.com */ 808922Swilliam.wang@arm.com QueuedSlavePort(const std::string& name, MemObject* owner, 818975Sandreas.hansson@arm.com SlavePacketQueue &queue) : 828922Swilliam.wang@arm.com SlavePort(name, owner), queue(queue) 838922Swilliam.wang@arm.com { } 848922Swilliam.wang@arm.com 858922Swilliam.wang@arm.com virtual ~QueuedSlavePort() { } 868922Swilliam.wang@arm.com 879163Sandreas.hansson@arm.com /** 889163Sandreas.hansson@arm.com * Schedule the sending of a timing response. 899163Sandreas.hansson@arm.com * 909163Sandreas.hansson@arm.com * @param pkt Packet to send 919163Sandreas.hansson@arm.com * @param when Absolute time (in ticks) to send packet 929163Sandreas.hansson@arm.com */ 939163Sandreas.hansson@arm.com void schedTimingResp(PacketPtr pkt, Tick when) 949163Sandreas.hansson@arm.com { queue.schedSendTiming(pkt, when); } 959163Sandreas.hansson@arm.com 968922Swilliam.wang@arm.com /** Check the list of buffered packets against the supplied 978922Swilliam.wang@arm.com * functional request. */ 988922Swilliam.wang@arm.com bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); } 998922Swilliam.wang@arm.com 1008922Swilliam.wang@arm.com /** 1018922Swilliam.wang@arm.com * Hook for draining the queued port. 1028922Swilliam.wang@arm.com * 1038922Swilliam.wang@arm.com * @param de an event which is used to signal back to the caller 1048922Swilliam.wang@arm.com * @returns a number indicating how many times process will be called 1058922Swilliam.wang@arm.com */ 1068922Swilliam.wang@arm.com unsigned int drain(Event *de) { return queue.drain(de); } 1078922Swilliam.wang@arm.com}; 1088922Swilliam.wang@arm.com 1098922Swilliam.wang@arm.comclass QueuedMasterPort : public MasterPort 1108922Swilliam.wang@arm.com{ 1118922Swilliam.wang@arm.com 1128922Swilliam.wang@arm.com protected: 1138922Swilliam.wang@arm.com 1148922Swilliam.wang@arm.com /** Packet queue used to store outgoing requests and responses. */ 1158975Sandreas.hansson@arm.com MasterPacketQueue &queue; 1168922Swilliam.wang@arm.com 1178922Swilliam.wang@arm.com /** This function is notification that the device should attempt to send a 1188922Swilliam.wang@arm.com * packet again. */ 1198922Swilliam.wang@arm.com virtual void recvRetry() { queue.retry(); } 1208914Sandreas.hansson@arm.com 1218914Sandreas.hansson@arm.com public: 1228914Sandreas.hansson@arm.com 1238914Sandreas.hansson@arm.com /** 1248914Sandreas.hansson@arm.com * Create a QueuedPort with a given name, owner, and a supplied 1258914Sandreas.hansson@arm.com * implementation of a packet queue. The external definition of 1268914Sandreas.hansson@arm.com * the queue enables e.g. the cache to implement a specific queue 1278914Sandreas.hansson@arm.com * behaviuor in a subclass, and provide the latter to the 1288914Sandreas.hansson@arm.com * QueuePort constructor. 1298914Sandreas.hansson@arm.com */ 1308922Swilliam.wang@arm.com QueuedMasterPort(const std::string& name, MemObject* owner, 1318975Sandreas.hansson@arm.com MasterPacketQueue &queue) : 1328922Swilliam.wang@arm.com MasterPort(name, owner), queue(queue) 1338914Sandreas.hansson@arm.com { } 1348914Sandreas.hansson@arm.com 1358922Swilliam.wang@arm.com virtual ~QueuedMasterPort() { } 1368914Sandreas.hansson@arm.com 1379163Sandreas.hansson@arm.com /** 1389163Sandreas.hansson@arm.com * Schedule the sending of a timing request. 1399163Sandreas.hansson@arm.com * 1409163Sandreas.hansson@arm.com * @param pkt Packet to send 1419163Sandreas.hansson@arm.com * @param when Absolute time (in ticks) to send packet 1429163Sandreas.hansson@arm.com */ 1439163Sandreas.hansson@arm.com void schedTimingReq(PacketPtr pkt, Tick when) 1449163Sandreas.hansson@arm.com { queue.schedSendTiming(pkt, when); } 1459163Sandreas.hansson@arm.com 1469163Sandreas.hansson@arm.com /** 1479163Sandreas.hansson@arm.com * Schedule the sending of a timing snoop response. 1489163Sandreas.hansson@arm.com * 1499163Sandreas.hansson@arm.com * @param pkt Packet to send 1509163Sandreas.hansson@arm.com * @param when Absolute time (in ticks) to send packet 1519163Sandreas.hansson@arm.com */ 1529163Sandreas.hansson@arm.com void schedTimingSnoopResp(PacketPtr pkt, Tick when) 1539163Sandreas.hansson@arm.com { queue.schedSendTiming(pkt, when, true); } 1549163Sandreas.hansson@arm.com 1558914Sandreas.hansson@arm.com /** Check the list of buffered packets against the supplied 1568914Sandreas.hansson@arm.com * functional request. */ 1578914Sandreas.hansson@arm.com bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); } 1588914Sandreas.hansson@arm.com 1598914Sandreas.hansson@arm.com /** 1608914Sandreas.hansson@arm.com * Hook for draining the queued port. 1618914Sandreas.hansson@arm.com * 1628914Sandreas.hansson@arm.com * @param de an event which is used to signal back to the caller 1638914Sandreas.hansson@arm.com * @returns a number indicating how many times process will be called 1648914Sandreas.hansson@arm.com */ 1658914Sandreas.hansson@arm.com unsigned int drain(Event *de) { return queue.drain(de); } 1668914Sandreas.hansson@arm.com}; 1678914Sandreas.hansson@arm.com 1688914Sandreas.hansson@arm.com#endif // __MEM_QPORT_HH__ 169