mshr.hh revision 4871
12810SN/A/* 29725Sandreas.hansson@arm.com * Copyright (c) 2002-2005 The Regents of The University of Michigan 39663Suri.wiener@arm.com * All rights reserved. 49663Suri.wiener@arm.com * 59663Suri.wiener@arm.com * Redistribution and use in source and binary forms, with or without 69663Suri.wiener@arm.com * modification, are permitted provided that the following conditions are 79663Suri.wiener@arm.com * met: redistributions of source code must retain the above copyright 89663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer; 99663Suri.wiener@arm.com * redistributions in binary form must reproduce the above copyright 109663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer in the 119663Suri.wiener@arm.com * documentation and/or other materials provided with the distribution; 129663Suri.wiener@arm.com * neither the name of the copyright holders nor the names of its 139663Suri.wiener@arm.com * contributors may be used to endorse or promote products derived from 142810SN/A * this software without specific prior written permission. 152810SN/A * 162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272810SN/A * 282810SN/A * Authors: Erik Hallnor 292810SN/A */ 302810SN/A 312810SN/A/** 322810SN/A * @file 332810SN/A * Miss Status and Handling Register (MSHR) declaration. 342810SN/A */ 352810SN/A 362810SN/A#ifndef __MSHR_HH__ 372810SN/A#define __MSHR_HH__ 382810SN/A 392810SN/A#include <list> 402810SN/A 412810SN/A#include "mem/packet.hh" 422810SN/A 432810SN/Aclass CacheBlk; 442810SN/Aclass MSHRQueue; 452810SN/A 462810SN/A/** 472810SN/A * Miss Status and handling Register. This class keeps all the information 482810SN/A * needed to handle a cache miss including a list of target requests. 492810SN/A */ 502810SN/Aclass MSHR : public Packet::SenderState 514626SN/A{ 524626SN/A 535314SN/A public: 542810SN/A 552810SN/A class Target { 564626SN/A public: 574626SN/A Tick recvTime; //!< Time when request was received (for stats) 582810SN/A Tick readyTime; //!< Time when request is ready to be serviced 592810SN/A Counter order; //!< Global order (for memory consistency mgmt) 602810SN/A PacketPtr pkt; //!< Pending request packet. 613374SN/A bool cpuSide; //!< Did request come from cpu side or mem side? 629264Sdjordje.kovacevic@arm.com 632810SN/A bool isCpuSide() { return cpuSide; } 645314SN/A 654626SN/A Target(PacketPtr _pkt, Tick _readyTime, Counter _order, bool _cpuSide) 664626SN/A : recvTime(curTick), readyTime(_readyTime), order(_order), 679725Sandreas.hansson@arm.com pkt(_pkt), cpuSide(_cpuSide) 689725Sandreas.hansson@arm.com {} 699725Sandreas.hansson@arm.com }; 709725Sandreas.hansson@arm.com 719725Sandreas.hansson@arm.com /** Defines the Data structure of the MSHR targetlist. */ 729725Sandreas.hansson@arm.com typedef std::list<Target> TargetList; 739725Sandreas.hansson@arm.com /** Target list iterator. */ 749725Sandreas.hansson@arm.com typedef std::list<Target>::iterator TargetListIterator; 759725Sandreas.hansson@arm.com /** A list of MSHRs. */ 769725Sandreas.hansson@arm.com typedef std::list<MSHR *> List; 779725Sandreas.hansson@arm.com /** MSHR list iterator. */ 789725Sandreas.hansson@arm.com typedef List::iterator Iterator; 799725Sandreas.hansson@arm.com /** MSHR list const_iterator. */ 809725Sandreas.hansson@arm.com typedef List::const_iterator ConstIterator; 819725Sandreas.hansson@arm.com 829725Sandreas.hansson@arm.com /** Pointer to queue containing this MSHR. */ 839725Sandreas.hansson@arm.com MSHRQueue *queue; 849725Sandreas.hansson@arm.com 859725Sandreas.hansson@arm.com /** Cycle when ready to issue */ 869725Sandreas.hansson@arm.com Tick readyTime; 879725Sandreas.hansson@arm.com 889725Sandreas.hansson@arm.com /** Order number assigned by the miss queue. */ 899725Sandreas.hansson@arm.com Counter order; 909725Sandreas.hansson@arm.com 919725Sandreas.hansson@arm.com /** Address of the request. */ 922810SN/A Addr addr; 934626SN/A 944626SN/A /** Size of the request. */ 954626SN/A int size; 965875Ssteve.reinhardt@amd.com 975875Ssteve.reinhardt@amd.com /** True if the request has been sent to the bus. */ 985875Ssteve.reinhardt@amd.com bool inService; 995875Ssteve.reinhardt@amd.com 1005875Ssteve.reinhardt@amd.com /** True if we will be putting the returned block in the cache */ 1015875Ssteve.reinhardt@amd.com bool isCacheFill; 1025875Ssteve.reinhardt@amd.com /** True if we need to get an exclusive copy of the block. */ 1034871SN/A bool needsExclusive; 1044871SN/A 1054666SN/A /** True if the request is uncacheable */ 1064626SN/A bool _isUncacheable; 1075875Ssteve.reinhardt@amd.com 1085318SN/A bool deferredNeedsExclusive; 1095318SN/A bool pendingInvalidate; 1104626SN/A bool pendingShared; 1115318SN/A 1125875Ssteve.reinhardt@amd.com /** Thread number of the miss. */ 1137823Ssteve.reinhardt@amd.com short threadNum; 1145875Ssteve.reinhardt@amd.com /** The number of currently allocated targets. */ 1154626SN/A short ntargets; 1164626SN/A 1174626SN/A 1184903SN/A /** Data buffer (if needed). Currently used only for pending 1194903SN/A * upgrade handling. */ 1204903SN/A uint8_t *data; 1215314SN/A 1224903SN/A /** 1234903SN/A * Pointer to this MSHR on the ready list. 1244903SN/A * @sa MissQueue, MSHRQueue::readyList 1254903SN/A */ 1264903SN/A Iterator readyIter; 1274903SN/A 1284903SN/A /** 1294903SN/A * Pointer to this MSHR on the allocated list. 1305318SN/A * @sa MissQueue, MSHRQueue::allocatedList 1315875Ssteve.reinhardt@amd.com */ 1324903SN/A Iterator allocIter; 1334908SN/A 1344920SN/Aprivate: 1355314SN/A /** List of all requests that match the address */ 1365314SN/A TargetList targets; 1374903SN/A 1384903SN/A TargetList deferredTargets; 1392810SN/A 1402810SN/Apublic: 1412810SN/A 1422810SN/A bool isUncacheable() { return _isUncacheable; } 1432810SN/A 1442810SN/A /** 1452810SN/A * Allocate a miss to this MSHR. 1464626SN/A * @param cmd The requesting command. 1474626SN/A * @param addr The address of the miss. 1484626SN/A * @param asid The address space id of the miss. 1494666SN/A * @param size The number of bytes to request. 1504666SN/A * @param pkt The original miss. 1514666SN/A */ 1524626SN/A void allocate(Addr addr, int size, PacketPtr pkt, 1532810SN/A Tick when, Counter _order); 1544626SN/A 1554626SN/A /** 1564626SN/A * Mark this MSHR as free. 1574626SN/A */ 15810028SGiacomo.Gabrielli@arm.com void deallocate(); 15910028SGiacomo.Gabrielli@arm.com 16010028SGiacomo.Gabrielli@arm.com /** 1613374SN/A * Add a request to the list of targets. 1622810SN/A * @param target The target. 1634626SN/A */ 1645730SSteve.Reinhardt@amd.com void allocateTarget(PacketPtr target, Tick when, Counter order); 1655730SSteve.Reinhardt@amd.com void allocateSnoopTarget(PacketPtr target, Tick when, Counter order); 1664903SN/A 1677667Ssteve.reinhardt@amd.com /** A simple constructor. */ 1687667Ssteve.reinhardt@amd.com MSHR(); 1697667Ssteve.reinhardt@amd.com /** A simple destructor. */ 1707667Ssteve.reinhardt@amd.com ~MSHR(); 1717667Ssteve.reinhardt@amd.com 1729725Sandreas.hansson@arm.com /** 1739725Sandreas.hansson@arm.com * Returns the current number of allocated targets. 1749725Sandreas.hansson@arm.com * @return The current number of allocated targets. 1757667Ssteve.reinhardt@amd.com */ 1767667Ssteve.reinhardt@amd.com int getNumTargets() { return ntargets; } 1777667Ssteve.reinhardt@amd.com 1787667Ssteve.reinhardt@amd.com /** 1797667Ssteve.reinhardt@amd.com * Returns a pointer to the target list. 1807667Ssteve.reinhardt@amd.com * @return a pointer to the target list. 1817667Ssteve.reinhardt@amd.com */ 1827667Ssteve.reinhardt@amd.com TargetList* getTargetList() { return &targets; } 1837667Ssteve.reinhardt@amd.com 1847667Ssteve.reinhardt@amd.com /** 1857667Ssteve.reinhardt@amd.com * Returns a reference to the first target. 1864665SN/A * @return A pointer to the first target. 1872810SN/A */ 1886221Snate@binkert.org Target *getTarget() { return &targets.front(); } 1892810SN/A 1909725Sandreas.hansson@arm.com /** 1914668SN/A * Pop first target. 1924668SN/A */ 1934668SN/A void popTarget() 1944668SN/A { 1954668SN/A --ntargets; 1962810SN/A targets.pop_front(); 1972810SN/A } 1982810SN/A 1992810SN/A /** 2002810SN/A * Returns true if there are targets left. 2014626SN/A * @return true if there are targets 2022810SN/A */ 2032810SN/A bool hasTargets() { return !targets.empty(); } 2042810SN/A 2052810SN/A bool isSimpleForward() 2062810SN/A { 2072810SN/A if (getNumTargets() != 1) 2083374SN/A return false; 2099725Sandreas.hansson@arm.com Target *tgt = getTarget(); 2102810SN/A return tgt->isCpuSide() && !tgt->pkt->needsResponse(); 2119725Sandreas.hansson@arm.com } 2124665SN/A 2139725Sandreas.hansson@arm.com bool promoteDeferredTargets(); 2144626SN/A 2159725Sandreas.hansson@arm.com void handleFill(Packet *pkt, CacheBlk *blk); 2164626SN/A 2172810SN/A /** 2182810SN/A * Prints the contents of this MSHR to stderr. 2193374SN/A */ 2202810SN/A void dump(); 2212810SN/A}; 2223374SN/A 2232982SN/A#endif //__MSHR_HH__ 2242810SN/A