write_queue_entry.cc revision 12727:56c23b54bcb1
11689SN/A/* 22329SN/A * Copyright (c) 2012-2013, 2015-2017 ARM Limited 31689SN/A * All rights reserved. 41689SN/A * 51689SN/A * The license below extends only to copyright in the software and shall 61689SN/A * not be construed as granting a license to any other intellectual 71689SN/A * property including but not limited to intellectual property relating 81689SN/A * to a hardware implementation of the functionality of the software 91689SN/A * licensed hereunder. You may use the software subject to the license 101689SN/A * terms below provided that you ensure that this notice is replicated 111689SN/A * unmodified and in its entirety in all distributions of the software, 121689SN/A * modified or unmodified, in source code or in binary form. 131689SN/A * 141689SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 151689SN/A * Copyright (c) 2010 Advanced Micro Devices, Inc. 161689SN/A * All rights reserved. 171689SN/A * 181689SN/A * Redistribution and use in source and binary forms, with or without 191689SN/A * modification, are permitted provided that the following conditions are 201689SN/A * met: redistributions of source code must retain the above copyright 211689SN/A * notice, this list of conditions and the following disclaimer; 221689SN/A * redistributions in binary form must reproduce the above copyright 231689SN/A * notice, this list of conditions and the following disclaimer in the 241689SN/A * documentation and/or other materials provided with the distribution; 251689SN/A * neither the name of the copyright holders nor the names of its 261689SN/A * contributors may be used to endorse or promote products derived from 272665Ssaidi@eecs.umich.edu * this software without specific prior written permission. 282665Ssaidi@eecs.umich.edu * 292831Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 301689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 311689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 321858SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 331717SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 341060SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 352980Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 362292SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 371061SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 382292SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 392980Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 402292SN/A * 411060SN/A * Authors: Erik Hallnor 421060SN/A * Dave Greene 431060SN/A * Andreas Hansson 442292SN/A */ 451060SN/A 462292SN/A/** 472877Sksewell@umich.edu * @file 482292SN/A * Miss Status and Handling Register (WriteQueueEntry) definitions. 492292SN/A */ 502292SN/A 512292SN/A#include "mem/cache/write_queue_entry.hh" 522980Sgblack@eecs.umich.edu 532292SN/A#include <cassert> 542292SN/A#include <string> 552292SN/A 562292SN/A#include "base/logging.hh" 572292SN/A#include "base/types.hh" 582292SN/A#include "mem/cache/base.hh" 592292SN/A#include "mem/request.hh" 602292SN/A 612292SN/Ainline void 622292SN/AWriteQueueEntry::TargetList::add(PacketPtr pkt, Tick readyTime, 632292SN/A Counter order) 642292SN/A{ 652292SN/A emplace_back(pkt, readyTime, order); 662292SN/A} 672292SN/A 682292SN/Abool 692292SN/AWriteQueueEntry::TargetList::checkFunctional(PacketPtr pkt) 702292SN/A{ 712292SN/A for (auto& t : *this) { 722292SN/A if (pkt->checkFunctional(t.pkt)) { 732292SN/A return true; 742292SN/A } 752292SN/A } 762292SN/A 772292SN/A return false; 782292SN/A} 792292SN/A 802292SN/Avoid 812292SN/AWriteQueueEntry::TargetList::print(std::ostream &os, int verbosity, 822292SN/A const std::string &prefix) const 832292SN/A{ 842292SN/A for (auto& t : *this) { 852292SN/A ccprintf(os, "%sFromCPU: ", prefix); 862292SN/A t.pkt->print(os, verbosity, ""); 872292SN/A } 882292SN/A} 892292SN/A 902292SN/Avoid 912292SN/AWriteQueueEntry::allocate(Addr blk_addr, unsigned blk_size, PacketPtr target, 922292SN/A Tick when_ready, Counter _order) 932292SN/A{ 942292SN/A blkAddr = blk_addr; 952292SN/A blkSize = blk_size; 962292SN/A isSecure = target->isSecure(); 972292SN/A readyTime = when_ready; 982292SN/A order = _order; 992292SN/A assert(target); 1001060SN/A _isUncacheable = target->req->isUncacheable(); 1011060SN/A inService = false; 1021061SN/A 1031060SN/A // we should never have more than a single target for cacheable 1042733Sktlim@umich.edu // writes (writebacks and clean evictions) 1051060SN/A panic_if(!_isUncacheable && !targets.empty(), 1061060SN/A "Write queue entry %#llx should never have more than one " 1071060SN/A "cacheable target", blkAddr); 1082292SN/A panic_if(!((target->isWrite() && _isUncacheable) || 1092292SN/A (target->isEviction() && !_isUncacheable) || 1102292SN/A target->cmd == MemCmd::WriteClean), 1112292SN/A "Write queue entry %#llx should be an uncacheable write or " 1121060SN/A "a cacheable eviction or a writeclean"); 1132292SN/A 1142292SN/A targets.add(target, when_ready, _order); 1152292SN/A} 1162292SN/A 1172292SN/Avoid 1182292SN/AWriteQueueEntry::deallocate() 1192292SN/A{ 1202292SN/A assert(targets.empty()); 1212980Sgblack@eecs.umich.edu inService = false; 1222292SN/A} 1232292SN/A 1242292SN/Abool 1252292SN/AWriteQueueEntry::checkFunctional(PacketPtr pkt) 1262292SN/A{ 1272307SN/A // For printing, we treat the WriteQueueEntry as a whole as single 1282307SN/A // entity. For other requests, we iterate over the individual 1292307SN/A // targets since that's where the actual data lies. 1302307SN/A if (pkt->isPrint()) { 1312307SN/A pkt->checkFunctional(this, blkAddr, isSecure, blkSize, nullptr); 1322307SN/A return false; 1332307SN/A } else { 1342307SN/A return targets.checkFunctional(pkt); 1352307SN/A } 1362307SN/A} 1372307SN/A 1382307SN/Abool 1392307SN/AWriteQueueEntry::sendPacket(BaseCache &cache) 1402307SN/A{ 1412307SN/A return cache.sendWriteQueuePacket(this); 1422307SN/A} 1432307SN/A 1442307SN/Avoid 1452307SN/AWriteQueueEntry::print(std::ostream &os, int verbosity, 1462307SN/A const std::string &prefix) const 1472307SN/A{ 1482307SN/A ccprintf(os, "%s[%#llx:%#llx](%s) %s %s %s state: %s %s %s %s %s\n", 1492307SN/A prefix, blkAddr, blkAddr + blkSize - 1, 1502307SN/A isSecure ? "s" : "ns", 1512307SN/A _isUncacheable ? "Unc" : "", 1522292SN/A inService ? "InSvc" : ""); 1532292SN/A 1542292SN/A ccprintf(os, "%s Targets:\n", prefix); 1552292SN/A targets.print(os, verbosity, prefix + " "); 1562292SN/A} 1572292SN/A 1583867Sbinkertn@umich.edustd::string 1592292SN/AWriteQueueEntry::print() const 1603867Sbinkertn@umich.edu{ 1613867Sbinkertn@umich.edu std::ostringstream str; 1622292SN/A print(str); 1633867Sbinkertn@umich.edu return str.str(); 1643867Sbinkertn@umich.edu} 1653867Sbinkertn@umich.edu