mshr.hh revision 2810
16691Stjones1@inf.ed.ac.uk/* 26691Stjones1@inf.ed.ac.uk * Copyright (c) 2002-2005 The Regents of The University of Michigan 36691Stjones1@inf.ed.ac.uk * All rights reserved. 46691Stjones1@inf.ed.ac.uk * 56691Stjones1@inf.ed.ac.uk * Redistribution and use in source and binary forms, with or without 66691Stjones1@inf.ed.ac.uk * modification, are permitted provided that the following conditions are 76691Stjones1@inf.ed.ac.uk * met: redistributions of source code must retain the above copyright 86691Stjones1@inf.ed.ac.uk * notice, this list of conditions and the following disclaimer; 96691Stjones1@inf.ed.ac.uk * redistributions in binary form must reproduce the above copyright 106691Stjones1@inf.ed.ac.uk * notice, this list of conditions and the following disclaimer in the 116691Stjones1@inf.ed.ac.uk * documentation and/or other materials provided with the distribution; 126691Stjones1@inf.ed.ac.uk * neither the name of the copyright holders nor the names of its 136691Stjones1@inf.ed.ac.uk * contributors may be used to endorse or promote products derived from 146691Stjones1@inf.ed.ac.uk * this software without specific prior written permission. 156691Stjones1@inf.ed.ac.uk * 166691Stjones1@inf.ed.ac.uk * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176691Stjones1@inf.ed.ac.uk * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186691Stjones1@inf.ed.ac.uk * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196691Stjones1@inf.ed.ac.uk * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206691Stjones1@inf.ed.ac.uk * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216691Stjones1@inf.ed.ac.uk * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226691Stjones1@inf.ed.ac.uk * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236691Stjones1@inf.ed.ac.uk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246691Stjones1@inf.ed.ac.uk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256691Stjones1@inf.ed.ac.uk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266691Stjones1@inf.ed.ac.uk * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276691Stjones1@inf.ed.ac.uk * 286691Stjones1@inf.ed.ac.uk * Authors: Erik Hallnor 296691Stjones1@inf.ed.ac.uk */ 306691Stjones1@inf.ed.ac.uk 316691Stjones1@inf.ed.ac.uk/** 326691Stjones1@inf.ed.ac.uk * @file 336691Stjones1@inf.ed.ac.uk * Miss Status and Handling Register (MSHR) declaration. 346691Stjones1@inf.ed.ac.uk */ 356691Stjones1@inf.ed.ac.uk 366691Stjones1@inf.ed.ac.uk#ifndef __MSHR_HH__ 376691Stjones1@inf.ed.ac.uk#define __MSHR_HH__ 386691Stjones1@inf.ed.ac.uk 396691Stjones1@inf.ed.ac.uk#include "mem/packet.hh" 408542Sgblack@eecs.umich.edu#include <list> 416691Stjones1@inf.ed.ac.uk#include <deque> 427811Ssteve.reinhardt@amd.com 436691Stjones1@inf.ed.ac.ukclass MSHR; 446691Stjones1@inf.ed.ac.uk 456691Stjones1@inf.ed.ac.uk/** 466691Stjones1@inf.ed.ac.uk * Miss Status and handling Register. This class keeps all the information 476691Stjones1@inf.ed.ac.uk * needed to handle a cache miss including a list of target requests. 486691Stjones1@inf.ed.ac.uk */ 496691Stjones1@inf.ed.ac.ukclass MSHR { 506691Stjones1@inf.ed.ac.uk public: 516691Stjones1@inf.ed.ac.uk /** Defines the Data structure of the MSHR targetlist. */ 526691Stjones1@inf.ed.ac.uk typedef std::list<Packet *> TargetList; 536691Stjones1@inf.ed.ac.uk /** Target list iterator. */ 546691Stjones1@inf.ed.ac.uk typedef std::list<Packet *>::iterator TargetListIterator; 556691Stjones1@inf.ed.ac.uk /** A list of MSHRs. */ 566691Stjones1@inf.ed.ac.uk typedef std::list<MSHR *> List; 576691Stjones1@inf.ed.ac.uk /** MSHR list iterator. */ 586691Stjones1@inf.ed.ac.uk typedef List::iterator Iterator; 596691Stjones1@inf.ed.ac.uk /** MSHR list const_iterator. */ 606691Stjones1@inf.ed.ac.uk typedef List::const_iterator ConstIterator; 616691Stjones1@inf.ed.ac.uk 626691Stjones1@inf.ed.ac.uk /** Address of the miss. */ 636691Stjones1@inf.ed.ac.uk Addr addr; 646691Stjones1@inf.ed.ac.uk /** Adress space id of the miss. */ 656691Stjones1@inf.ed.ac.uk short asid; 666691Stjones1@inf.ed.ac.uk /** True if the request has been sent to the bus. */ 676691Stjones1@inf.ed.ac.uk bool inService; 686691Stjones1@inf.ed.ac.uk /** Thread number of the miss. */ 699057SAli.Saidi@ARM.com int threadNum; 709057SAli.Saidi@ARM.com /** The request that is forwarded to the next level of the hierarchy. */ 716691Stjones1@inf.ed.ac.uk Packet * pkt; 726974Stjones1@inf.ed.ac.uk /** The number of currently allocated targets. */ 736974Stjones1@inf.ed.ac.uk short ntargets; 746974Stjones1@inf.ed.ac.uk /** The original requesting command. */ 759329Sdam.sunwoo@arm.com Packet::Command originalCmd; 769329Sdam.sunwoo@arm.com /** Order number of assigned by the miss queue. */ 779329Sdam.sunwoo@arm.com uint64_t order; 787811Ssteve.reinhardt@amd.com 796691Stjones1@inf.ed.ac.uk /** 806691Stjones1@inf.ed.ac.uk * Pointer to this MSHR on the ready list. 81 * @sa MissQueue, MSHRQueue::readyList 82 */ 83 Iterator readyIter; 84 /** 85 * Pointer to this MSHR on the allocated list. 86 * @sa MissQueue, MSHRQueue::allocatedList 87 */ 88 Iterator allocIter; 89 90private: 91 /** List of all requests that match the address */ 92 TargetList targets; 93 94public: 95 /** 96 * Allocate a miss to this MSHR. 97 * @param cmd The requesting command. 98 * @param addr The address of the miss. 99 * @param asid The address space id of the miss. 100 * @param size The number of bytes to request. 101 * @param req The original miss. 102 */ 103 void allocate(Packet::Command cmd, Addr addr, int asid, int size, 104 Packet * &pkt); 105 106 /** 107 * Allocate this MSHR as a buffer for the given request. 108 * @param target The memory request to buffer. 109 */ 110 void allocateAsBuffer(Packet * &target); 111 112 /** 113 * Mark this MSHR as free. 114 */ 115 void deallocate(); 116 117 /** 118 * Add a request to the list of targets. 119 * @param target The target. 120 */ 121 void allocateTarget(Packet * &target); 122 123 /** A simple constructor. */ 124 MSHR(); 125 /** A simple destructor. */ 126 ~MSHR(); 127 128 /** 129 * Returns the current number of allocated targets. 130 * @return The current number of allocated targets. 131 */ 132 int getNumTargets() 133 { 134 return(ntargets); 135 } 136 137 /** 138 * Returns a pointer to the target list. 139 * @return a pointer to the target list. 140 */ 141 TargetList* getTargetList() 142 { 143 return &targets; 144 } 145 146 /** 147 * Returns a reference to the first target. 148 * @return A pointer to the first target. 149 */ 150 Packet * getTarget() 151 { 152 return targets.front(); 153 } 154 155 /** 156 * Pop first target. 157 */ 158 void popTarget() 159 { 160 --ntargets; 161 targets.pop_front(); 162 } 163 164 /** 165 * Returns true if there are targets left. 166 * @return true if there are targets 167 */ 168 bool hasTargets() 169 { 170 return !targets.empty(); 171 } 172 173 /** 174 * Prints the contents of this MSHR to stderr. 175 */ 176 void dump(); 177}; 178 179#endif //__MSHR_HH__ 180