cache.hh revision 10713
12810Srdreslin@umich.edu/* 210343SCurtis.Dunham@arm.com * Copyright (c) 2012-2014 ARM Limited 38702Sandreas.hansson@arm.com * All rights reserved. 48702Sandreas.hansson@arm.com * 58702Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68702Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78702Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88702Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98702Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108702Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118702Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128702Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138702Sandreas.hansson@arm.com * 142810Srdreslin@umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan 152810Srdreslin@umich.edu * All rights reserved. 162810Srdreslin@umich.edu * 172810Srdreslin@umich.edu * Redistribution and use in source and binary forms, with or without 182810Srdreslin@umich.edu * modification, are permitted provided that the following conditions are 192810Srdreslin@umich.edu * met: redistributions of source code must retain the above copyright 202810Srdreslin@umich.edu * notice, this list of conditions and the following disclaimer; 212810Srdreslin@umich.edu * redistributions in binary form must reproduce the above copyright 222810Srdreslin@umich.edu * notice, this list of conditions and the following disclaimer in the 232810Srdreslin@umich.edu * documentation and/or other materials provided with the distribution; 242810Srdreslin@umich.edu * neither the name of the copyright holders nor the names of its 252810Srdreslin@umich.edu * contributors may be used to endorse or promote products derived from 262810Srdreslin@umich.edu * this software without specific prior written permission. 272810Srdreslin@umich.edu * 282810Srdreslin@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292810Srdreslin@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302810Srdreslin@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312810Srdreslin@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322810Srdreslin@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332810Srdreslin@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342810Srdreslin@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352810Srdreslin@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362810Srdreslin@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372810Srdreslin@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382810Srdreslin@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392810Srdreslin@umich.edu * 402810Srdreslin@umich.edu * Authors: Erik Hallnor 412810Srdreslin@umich.edu * Dave Greene 422810Srdreslin@umich.edu * Steve Reinhardt 434458Sstever@eecs.umich.edu * Ron Dreslinski 448856Sandreas.hansson@arm.com * Andreas Hansson 452810Srdreslin@umich.edu */ 462810Srdreslin@umich.edu 472810Srdreslin@umich.edu/** 482810Srdreslin@umich.edu * @file 492810Srdreslin@umich.edu * Describes a cache based on template policies. 502810Srdreslin@umich.edu */ 512810Srdreslin@umich.edu 522810Srdreslin@umich.edu#ifndef __CACHE_HH__ 532810Srdreslin@umich.edu#define __CACHE_HH__ 542810Srdreslin@umich.edu 552810Srdreslin@umich.edu#include "base/misc.hh" // fatal, panic, and warn 565338Sstever@gmail.com#include "mem/cache/base.hh" 575338Sstever@gmail.com#include "mem/cache/blk.hh" 585338Sstever@gmail.com#include "mem/cache/mshr.hh" 594458Sstever@eecs.umich.edu#include "sim/eventq.hh" 604458Sstever@eecs.umich.edu 612813Srdreslin@umich.edu//Forward decleration 623861Sstever@eecs.umich.educlass BasePrefetcher; 632810Srdreslin@umich.edu 642810Srdreslin@umich.edu/** 652810Srdreslin@umich.edu * A template-policy based cache. The behavior of the cache can be altered by 662810Srdreslin@umich.edu * supplying different template policies. TagStore handles all tag and data 679264Sdjordje.kovacevic@arm.com * storage @sa TagStore, \ref gem5MemorySystem "gem5 Memory System" 682810Srdreslin@umich.edu */ 694672Sstever@eecs.umich.edutemplate <class TagStore> 702810Srdreslin@umich.educlass Cache : public BaseCache 712810Srdreslin@umich.edu{ 722810Srdreslin@umich.edu public: 732810Srdreslin@umich.edu /** Define the type of cache block to use. */ 742810Srdreslin@umich.edu typedef typename TagStore::BlkType BlkType; 753860Sstever@eecs.umich.edu /** A typedef for a list of BlkType pointers. */ 763860Sstever@eecs.umich.edu typedef typename TagStore::BlkList BlkList; 772810Srdreslin@umich.edu 782810Srdreslin@umich.edu protected: 799347SAndreas.Sandberg@arm.com typedef CacheBlkVisitorWrapper<Cache<TagStore>, BlkType> WrappedBlkVisitor; 802810Srdreslin@umich.edu 818856Sandreas.hansson@arm.com /** 828856Sandreas.hansson@arm.com * The CPU-side port extends the base cache slave port with access 838856Sandreas.hansson@arm.com * functions for functional, atomic and timing requests. 848856Sandreas.hansson@arm.com */ 858856Sandreas.hansson@arm.com class CpuSidePort : public CacheSlavePort 863738Sstever@eecs.umich.edu { 878856Sandreas.hansson@arm.com private: 883738Sstever@eecs.umich.edu 898856Sandreas.hansson@arm.com // a pointer to our specific cache implementation 908856Sandreas.hansson@arm.com Cache<TagStore> *cache; 913738Sstever@eecs.umich.edu 928856Sandreas.hansson@arm.com protected: 934478Sstever@eecs.umich.edu 948975Sandreas.hansson@arm.com virtual bool recvTimingSnoopResp(PacketPtr pkt); 958948Sandreas.hansson@arm.com 968975Sandreas.hansson@arm.com virtual bool recvTimingReq(PacketPtr pkt); 973738Sstever@eecs.umich.edu 983738Sstever@eecs.umich.edu virtual Tick recvAtomic(PacketPtr pkt); 993738Sstever@eecs.umich.edu 1003738Sstever@eecs.umich.edu virtual void recvFunctional(PacketPtr pkt); 1018856Sandreas.hansson@arm.com 1029090Sandreas.hansson@arm.com virtual AddrRangeList getAddrRanges() const; 1038856Sandreas.hansson@arm.com 1048856Sandreas.hansson@arm.com public: 1058856Sandreas.hansson@arm.com 1068856Sandreas.hansson@arm.com CpuSidePort(const std::string &_name, Cache<TagStore> *_cache, 1078856Sandreas.hansson@arm.com const std::string &_label); 1088856Sandreas.hansson@arm.com 1093738Sstever@eecs.umich.edu }; 1103738Sstever@eecs.umich.edu 1118856Sandreas.hansson@arm.com /** 1128914Sandreas.hansson@arm.com * Override the default behaviour of sendDeferredPacket to enable 1138914Sandreas.hansson@arm.com * the memory-side cache port to also send requests based on the 1148914Sandreas.hansson@arm.com * current MSHR status. This queue has a pointer to our specific 1158914Sandreas.hansson@arm.com * cache implementation and is used by the MemSidePort. 1168914Sandreas.hansson@arm.com */ 11710713Sandreas.hansson@arm.com class CacheReqPacketQueue : public ReqPacketQueue 1188914Sandreas.hansson@arm.com { 1198914Sandreas.hansson@arm.com 1208914Sandreas.hansson@arm.com protected: 1218914Sandreas.hansson@arm.com 1228914Sandreas.hansson@arm.com Cache<TagStore> &cache; 12310713Sandreas.hansson@arm.com SnoopRespPacketQueue &snoopRespQueue; 1248914Sandreas.hansson@arm.com 1258914Sandreas.hansson@arm.com public: 1268914Sandreas.hansson@arm.com 12710713Sandreas.hansson@arm.com CacheReqPacketQueue(Cache<TagStore> &cache, MasterPort &port, 12810713Sandreas.hansson@arm.com SnoopRespPacketQueue &snoop_resp_queue, 12910713Sandreas.hansson@arm.com const std::string &label) : 13010713Sandreas.hansson@arm.com ReqPacketQueue(cache, port, label), cache(cache), 13110713Sandreas.hansson@arm.com snoopRespQueue(snoop_resp_queue) { } 1328914Sandreas.hansson@arm.com 1338914Sandreas.hansson@arm.com /** 1348914Sandreas.hansson@arm.com * Override the normal sendDeferredPacket and do not only 1358914Sandreas.hansson@arm.com * consider the transmit list (used for responses), but also 1368914Sandreas.hansson@arm.com * requests. 1378914Sandreas.hansson@arm.com */ 1388914Sandreas.hansson@arm.com virtual void sendDeferredPacket(); 1398914Sandreas.hansson@arm.com 1408914Sandreas.hansson@arm.com }; 1418914Sandreas.hansson@arm.com 1428914Sandreas.hansson@arm.com /** 1438856Sandreas.hansson@arm.com * The memory-side port extends the base cache master port with 1448856Sandreas.hansson@arm.com * access functions for functional, atomic and timing snoops. 1458856Sandreas.hansson@arm.com */ 1468856Sandreas.hansson@arm.com class MemSidePort : public CacheMasterPort 1473738Sstever@eecs.umich.edu { 1488856Sandreas.hansson@arm.com private: 1493738Sstever@eecs.umich.edu 1508914Sandreas.hansson@arm.com /** The cache-specific queue. */ 15110713Sandreas.hansson@arm.com CacheReqPacketQueue _reqQueue; 15210713Sandreas.hansson@arm.com 15310713Sandreas.hansson@arm.com SnoopRespPacketQueue _snoopRespQueue; 1548914Sandreas.hansson@arm.com 1558856Sandreas.hansson@arm.com // a pointer to our specific cache implementation 1568856Sandreas.hansson@arm.com Cache<TagStore> *cache; 1573738Sstever@eecs.umich.edu 1588856Sandreas.hansson@arm.com protected: 1594478Sstever@eecs.umich.edu 1608975Sandreas.hansson@arm.com virtual void recvTimingSnoopReq(PacketPtr pkt); 1618948Sandreas.hansson@arm.com 1628975Sandreas.hansson@arm.com virtual bool recvTimingResp(PacketPtr pkt); 1633738Sstever@eecs.umich.edu 1648948Sandreas.hansson@arm.com virtual Tick recvAtomicSnoop(PacketPtr pkt); 1653738Sstever@eecs.umich.edu 1668948Sandreas.hansson@arm.com virtual void recvFunctionalSnoop(PacketPtr pkt); 1674458Sstever@eecs.umich.edu 1688856Sandreas.hansson@arm.com public: 1698856Sandreas.hansson@arm.com 1708856Sandreas.hansson@arm.com MemSidePort(const std::string &_name, Cache<TagStore> *_cache, 1718856Sandreas.hansson@arm.com const std::string &_label); 1723738Sstever@eecs.umich.edu }; 1733738Sstever@eecs.umich.edu 1742810Srdreslin@umich.edu /** Tag and data Storage */ 1752810Srdreslin@umich.edu TagStore *tags; 1764626Sstever@eecs.umich.edu 1772810Srdreslin@umich.edu /** Prefetcher */ 1783861Sstever@eecs.umich.edu BasePrefetcher *prefetcher; 1792810Srdreslin@umich.edu 1804671Sstever@eecs.umich.edu /** Temporary cache block for occasional transitory use */ 1814671Sstever@eecs.umich.edu BlkType *tempBlock; 1824671Sstever@eecs.umich.edu 1832810Srdreslin@umich.edu /** 1845707Shsul@eecs.umich.edu * This cache should allocate a block on a line-sized write miss. 1853860Sstever@eecs.umich.edu */ 1863860Sstever@eecs.umich.edu const bool doFastWrites; 1873860Sstever@eecs.umich.edu 1885875Ssteve.reinhardt@amd.com /** 18910345SCurtis.Dunham@arm.com * Turn line-sized writes into WriteInvalidate transactions. 19010345SCurtis.Dunham@arm.com */ 19110345SCurtis.Dunham@arm.com void promoteWholeLineWrites(PacketPtr pkt); 19210345SCurtis.Dunham@arm.com 19310345SCurtis.Dunham@arm.com /** 1945875Ssteve.reinhardt@amd.com * Notify the prefetcher on every access, not just misses. 1955875Ssteve.reinhardt@amd.com */ 1965875Ssteve.reinhardt@amd.com const bool prefetchOnAccess; 1973860Sstever@eecs.umich.edu 1983860Sstever@eecs.umich.edu /** 1999063SAli.Saidi@ARM.com * @todo this is a temporary workaround until the 4-phase code is committed. 2009063SAli.Saidi@ARM.com * upstream caches need this packet until true is returned, so hold it for 2019063SAli.Saidi@ARM.com * deletion until a subsequent call 2029063SAli.Saidi@ARM.com */ 2039063SAli.Saidi@ARM.com std::vector<PacketPtr> pendingDelete; 2049063SAli.Saidi@ARM.com 2059063SAli.Saidi@ARM.com /** 2063860Sstever@eecs.umich.edu * Does all the processing necessary to perform the provided request. 2073860Sstever@eecs.umich.edu * @param pkt The memory request to perform. 20810048Saminfar@gmail.com * @param blk The cache block to be updated. 2093860Sstever@eecs.umich.edu * @param lat The latency of the access. 2103860Sstever@eecs.umich.edu * @param writebacks List for any writebacks that need to be performed. 2115707Shsul@eecs.umich.edu * @return Boolean indicating whether the request was satisfied. 2123860Sstever@eecs.umich.edu */ 2135388Sstever@gmail.com bool access(PacketPtr pkt, BlkType *&blk, 2149288Sandreas.hansson@arm.com Cycles &lat, PacketList &writebacks); 2154219Srdreslin@umich.edu 2164219Srdreslin@umich.edu /** 2174219Srdreslin@umich.edu *Handle doing the Compare and Swap function for SPARC. 2184219Srdreslin@umich.edu */ 2194626Sstever@eecs.umich.edu void cmpAndSwap(BlkType *blk, PacketPtr pkt); 2203860Sstever@eecs.umich.edu 2213860Sstever@eecs.umich.edu /** 22210028SGiacomo.Gabrielli@arm.com * Find a block frame for new block at address addr targeting the 22310028SGiacomo.Gabrielli@arm.com * given security space, assuming that the block is not currently 22410028SGiacomo.Gabrielli@arm.com * in the cache. Append writebacks if any to provided packet 22510028SGiacomo.Gabrielli@arm.com * list. Return free block frame. May return NULL if there are 22610028SGiacomo.Gabrielli@arm.com * no replaceable blocks at the moment. 2275350Sstever@gmail.com */ 22810028SGiacomo.Gabrielli@arm.com BlkType *allocateBlock(Addr addr, bool is_secure, PacketList &writebacks); 2295350Sstever@gmail.com 2305350Sstever@gmail.com /** 2313860Sstever@eecs.umich.edu * Populates a cache block and handles all outstanding requests for the 2323860Sstever@eecs.umich.edu * satisfied fill request. This version takes two memory requests. One 2333860Sstever@eecs.umich.edu * contains the fill data, the other is an optional target to satisfy. 2344626Sstever@eecs.umich.edu * @param pkt The memory request with the fill data. 2353860Sstever@eecs.umich.edu * @param blk The cache block if it already exists. 2363860Sstever@eecs.umich.edu * @param writebacks List for any writebacks that need to be performed. 2373860Sstever@eecs.umich.edu * @return Pointer to the new cache block. 2383860Sstever@eecs.umich.edu */ 2394626Sstever@eecs.umich.edu BlkType *handleFill(PacketPtr pkt, BlkType *blk, 2404626Sstever@eecs.umich.edu PacketList &writebacks); 2413860Sstever@eecs.umich.edu 2429548Sandreas.hansson@arm.com 2439548Sandreas.hansson@arm.com /** 2449548Sandreas.hansson@arm.com * Performs the access specified by the request. 2459548Sandreas.hansson@arm.com * @param pkt The request to perform. 2469548Sandreas.hansson@arm.com * @return The result of the access. 2479548Sandreas.hansson@arm.com */ 2489548Sandreas.hansson@arm.com bool recvTimingReq(PacketPtr pkt); 2499548Sandreas.hansson@arm.com 2509548Sandreas.hansson@arm.com /** 2519548Sandreas.hansson@arm.com * Handles a response (cache line fill/write ack) from the bus. 2529548Sandreas.hansson@arm.com * @param pkt The response packet 2539548Sandreas.hansson@arm.com */ 2549548Sandreas.hansson@arm.com void recvTimingResp(PacketPtr pkt); 2559548Sandreas.hansson@arm.com 2569548Sandreas.hansson@arm.com /** 2579548Sandreas.hansson@arm.com * Snoops bus transactions to maintain coherence. 2589548Sandreas.hansson@arm.com * @param pkt The current bus transaction. 2599548Sandreas.hansson@arm.com */ 2609548Sandreas.hansson@arm.com void recvTimingSnoopReq(PacketPtr pkt); 2619548Sandreas.hansson@arm.com 2629548Sandreas.hansson@arm.com /** 2639548Sandreas.hansson@arm.com * Handle a snoop response. 2649548Sandreas.hansson@arm.com * @param pkt Snoop response packet 2659548Sandreas.hansson@arm.com */ 2669548Sandreas.hansson@arm.com void recvTimingSnoopResp(PacketPtr pkt); 2679548Sandreas.hansson@arm.com 2689548Sandreas.hansson@arm.com /** 2699548Sandreas.hansson@arm.com * Performs the access specified by the request. 2709548Sandreas.hansson@arm.com * @param pkt The request to perform. 2719782Sandreas.hansson@arm.com * @return The number of ticks required for the access. 2729548Sandreas.hansson@arm.com */ 2739782Sandreas.hansson@arm.com Tick recvAtomic(PacketPtr pkt); 2749548Sandreas.hansson@arm.com 2759548Sandreas.hansson@arm.com /** 2769548Sandreas.hansson@arm.com * Snoop for the provided request in the cache and return the estimated 2779782Sandreas.hansson@arm.com * time taken. 2789548Sandreas.hansson@arm.com * @param pkt The memory request to snoop 2799782Sandreas.hansson@arm.com * @return The number of ticks required for the snoop. 2809548Sandreas.hansson@arm.com */ 2819782Sandreas.hansson@arm.com Tick recvAtomicSnoop(PacketPtr pkt); 2829548Sandreas.hansson@arm.com 2839548Sandreas.hansson@arm.com /** 2849548Sandreas.hansson@arm.com * Performs the access specified by the request. 2859548Sandreas.hansson@arm.com * @param pkt The request to perform. 2869548Sandreas.hansson@arm.com * @param fromCpuSide from the CPU side port or the memory side port 2879548Sandreas.hansson@arm.com */ 2889548Sandreas.hansson@arm.com void functionalAccess(PacketPtr pkt, bool fromCpuSide); 2899548Sandreas.hansson@arm.com 2907667Ssteve.reinhardt@amd.com void satisfyCpuSideRequest(PacketPtr pkt, BlkType *blk, 2917667Ssteve.reinhardt@amd.com bool deferred_response = false, 2927667Ssteve.reinhardt@amd.com bool pending_downgrade = false); 2934628Sstever@eecs.umich.edu bool satisfyMSHR(MSHR *mshr, PacketPtr pkt, BlkType *blk); 2944626Sstever@eecs.umich.edu 29510563Sandreas.hansson@arm.com void doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data, 2965319Sstever@gmail.com bool already_copied, bool pending_inval); 2973860Sstever@eecs.umich.edu 2983860Sstever@eecs.umich.edu /** 2993860Sstever@eecs.umich.edu * Sets the blk to the new state. 3003860Sstever@eecs.umich.edu * @param blk The cache block being snooped. 3013860Sstever@eecs.umich.edu * @param new_state The new coherence state for the block. 3023860Sstever@eecs.umich.edu */ 3034670Sstever@eecs.umich.edu void handleSnoop(PacketPtr ptk, BlkType *blk, 3045319Sstever@gmail.com bool is_timing, bool is_deferred, bool pending_inval); 3053860Sstever@eecs.umich.edu 3063860Sstever@eecs.umich.edu /** 3073860Sstever@eecs.umich.edu * Create a writeback request for the given block. 3083860Sstever@eecs.umich.edu * @param blk The block to writeback. 3093860Sstever@eecs.umich.edu * @return The writeback request for the block. 3103860Sstever@eecs.umich.edu */ 3113860Sstever@eecs.umich.edu PacketPtr writebackBlk(BlkType *blk); 3123860Sstever@eecs.umich.edu 3139347SAndreas.Sandberg@arm.com 3149347SAndreas.Sandberg@arm.com void memWriteback(); 3159347SAndreas.Sandberg@arm.com void memInvalidate(); 3169347SAndreas.Sandberg@arm.com bool isDirty() const; 3179347SAndreas.Sandberg@arm.com 3189347SAndreas.Sandberg@arm.com /** 3199347SAndreas.Sandberg@arm.com * Cache block visitor that writes back dirty cache blocks using 3209347SAndreas.Sandberg@arm.com * functional writes. 3219347SAndreas.Sandberg@arm.com * 3229347SAndreas.Sandberg@arm.com * \return Always returns true. 3239347SAndreas.Sandberg@arm.com */ 3249347SAndreas.Sandberg@arm.com bool writebackVisitor(BlkType &blk); 3259347SAndreas.Sandberg@arm.com /** 3269347SAndreas.Sandberg@arm.com * Cache block visitor that invalidates all blocks in the cache. 3279347SAndreas.Sandberg@arm.com * 3289347SAndreas.Sandberg@arm.com * @warn Dirty cache lines will not be written back to memory. 3299347SAndreas.Sandberg@arm.com * 3309347SAndreas.Sandberg@arm.com * \return Always returns true. 3319347SAndreas.Sandberg@arm.com */ 3329347SAndreas.Sandberg@arm.com bool invalidateVisitor(BlkType &blk); 3339347SAndreas.Sandberg@arm.com 3349445SAndreas.Sandberg@ARM.com /** 3359445SAndreas.Sandberg@ARM.com * Flush a cache line due to an uncacheable memory access to the 3369445SAndreas.Sandberg@ARM.com * line. 3379445SAndreas.Sandberg@ARM.com * 3389445SAndreas.Sandberg@ARM.com * @note This shouldn't normally happen, but we need to handle it 3399445SAndreas.Sandberg@ARM.com * since some architecture models don't implement cache 3409445SAndreas.Sandberg@ARM.com * maintenance operations. We won't even try to get a decent 3419445SAndreas.Sandberg@ARM.com * timing here since the line should have been flushed earlier by 3429445SAndreas.Sandberg@ARM.com * a cache maintenance operation. 3439445SAndreas.Sandberg@ARM.com */ 3449445SAndreas.Sandberg@ARM.com void uncacheableFlush(PacketPtr pkt); 3459445SAndreas.Sandberg@ARM.com 3462810Srdreslin@umich.edu /** 3472982Sstever@eecs.umich.edu * Squash all requests associated with specified thread. 3482810Srdreslin@umich.edu * intended for use by I-cache. 3492982Sstever@eecs.umich.edu * @param threadNum The thread to squash. 3502810Srdreslin@umich.edu */ 3514626Sstever@eecs.umich.edu void squash(int threadNum); 3524626Sstever@eecs.umich.edu 3534626Sstever@eecs.umich.edu /** 3545365Sstever@gmail.com * Generate an appropriate downstream bus request packet for the 3555365Sstever@gmail.com * given parameters. 3565365Sstever@gmail.com * @param cpu_pkt The upstream request that needs to be satisfied. 3575365Sstever@gmail.com * @param blk The block currently in the cache corresponding to 3585365Sstever@gmail.com * cpu_pkt (NULL if none). 3595365Sstever@gmail.com * @param needsExclusive Indicates that an exclusive copy is required 3605365Sstever@gmail.com * even if the request in cpu_pkt doesn't indicate that. 3615365Sstever@gmail.com * @return A new Packet containing the request, or NULL if the 3625365Sstever@gmail.com * current request in cpu_pkt should just be forwarded on. 3634626Sstever@eecs.umich.edu */ 3644628Sstever@eecs.umich.edu PacketPtr getBusPacket(PacketPtr cpu_pkt, BlkType *blk, 3659529Sandreas.hansson@arm.com bool needsExclusive) const; 3665365Sstever@gmail.com 3675365Sstever@gmail.com /** 3685365Sstever@gmail.com * Return the next MSHR to service, either a pending miss from the 3695365Sstever@gmail.com * mshrQueue, a buffered write from the write buffer, or something 3705365Sstever@gmail.com * from the prefetcher. This function is responsible for 3715365Sstever@gmail.com * prioritizing among those sources on the fly. 3725365Sstever@gmail.com */ 3734626Sstever@eecs.umich.edu MSHR *getNextMSHR(); 3745365Sstever@gmail.com 3755365Sstever@gmail.com /** 3765365Sstever@gmail.com * Selects an outstanding request to service. Called when the 3775365Sstever@gmail.com * cache gets granted the downstream bus in timing mode. 3785365Sstever@gmail.com * @return The request to service, NULL if none found. 3795365Sstever@gmail.com */ 3804628Sstever@eecs.umich.edu PacketPtr getTimingPacket(); 3814626Sstever@eecs.umich.edu 3824626Sstever@eecs.umich.edu /** 38310679Sandreas.hansson@arm.com * Marks a request as in service (sent on the bus). This can have 38410679Sandreas.hansson@arm.com * side effect since storage for no response commands is 38510679Sandreas.hansson@arm.com * deallocated once they are successfully sent. Also remember if 38610679Sandreas.hansson@arm.com * we are expecting a dirty response from another cache, 38710679Sandreas.hansson@arm.com * effectively making this MSHR the ordering point. 3884626Sstever@eecs.umich.edu */ 38910679Sandreas.hansson@arm.com void markInService(MSHR *mshr, bool pending_dirty_resp); 3904626Sstever@eecs.umich.edu 3914626Sstever@eecs.umich.edu /** 3924626Sstever@eecs.umich.edu * Return whether there are any outstanding misses. 3934626Sstever@eecs.umich.edu */ 3944626Sstever@eecs.umich.edu bool outstandingMisses() const 3952810Srdreslin@umich.edu { 3964626Sstever@eecs.umich.edu return mshrQueue.allocated != 0; 3972810Srdreslin@umich.edu } 3982810Srdreslin@umich.edu 39910028SGiacomo.Gabrielli@arm.com CacheBlk *findBlock(Addr addr, bool is_secure) const { 40010028SGiacomo.Gabrielli@arm.com return tags->findBlock(addr, is_secure); 4012810Srdreslin@umich.edu } 4022810Srdreslin@umich.edu 40310028SGiacomo.Gabrielli@arm.com bool inCache(Addr addr, bool is_secure) const { 40410028SGiacomo.Gabrielli@arm.com return (tags->findBlock(addr, is_secure) != 0); 4053861Sstever@eecs.umich.edu } 4063861Sstever@eecs.umich.edu 40710028SGiacomo.Gabrielli@arm.com bool inMissQueue(Addr addr, bool is_secure) const { 40810028SGiacomo.Gabrielli@arm.com return (mshrQueue.findMatch(addr, is_secure) != 0); 4093861Sstever@eecs.umich.edu } 4105875Ssteve.reinhardt@amd.com 4115875Ssteve.reinhardt@amd.com /** 4125875Ssteve.reinhardt@amd.com * Find next request ready time from among possible sources. 4135875Ssteve.reinhardt@amd.com */ 4149529Sandreas.hansson@arm.com Tick nextMSHRReadyTime() const; 4159529Sandreas.hansson@arm.com 4169529Sandreas.hansson@arm.com public: 4179529Sandreas.hansson@arm.com /** Instantiates a basic cache object. */ 4189796Sprakash.ramrakhyani@arm.com Cache(const Params *p); 4199529Sandreas.hansson@arm.com 4209813Srioshering@gmail.com /** Non-default destructor is needed to deallocate memory. */ 4219813Srioshering@gmail.com virtual ~Cache(); 4229813Srioshering@gmail.com 4239529Sandreas.hansson@arm.com void regStats(); 4248985SAli.Saidi@ARM.com 4258985SAli.Saidi@ARM.com /** serialize the state of the caches 4268985SAli.Saidi@ARM.com * We currently don't support checkpointing cache state, so this panics. 4278985SAli.Saidi@ARM.com */ 4288985SAli.Saidi@ARM.com virtual void serialize(std::ostream &os); 4298985SAli.Saidi@ARM.com void unserialize(Checkpoint *cp, const std::string §ion); 4302810Srdreslin@umich.edu}; 4312810Srdreslin@umich.edu 4322810Srdreslin@umich.edu#endif // __CACHE_HH__ 433