write_queue.cc revision 11375
111878Sandreas.sandberg@arm.com/* 211878Sandreas.sandberg@arm.com * Copyright (c) 2012-2013, 2015-2016 ARM Limited 311878Sandreas.sandberg@arm.com * All rights reserved. 411878Sandreas.sandberg@arm.com * 511878Sandreas.sandberg@arm.com * The license below extends only to copyright in the software and shall 611878Sandreas.sandberg@arm.com * not be construed as granting a license to any other intellectual 711878Sandreas.sandberg@arm.com * property including but not limited to intellectual property relating 811878Sandreas.sandberg@arm.com * to a hardware implementation of the functionality of the software 911878Sandreas.sandberg@arm.com * licensed hereunder. You may use the software subject to the license 1011878Sandreas.sandberg@arm.com * terms below provided that you ensure that this notice is replicated 1111878Sandreas.sandberg@arm.com * unmodified and in its entirety in all distributions of the software, 1211878Sandreas.sandberg@arm.com * modified or unmodified, in source code or in binary form. 134126SN/A * 148295Snate@binkert.org * Copyright (c) 2003-2005 The Regents of The University of Michigan 154126SN/A * All rights reserved. 164126SN/A * 174126SN/A * Redistribution and use in source and binary forms, with or without 184126SN/A * modification, are permitted provided that the following conditions are 194126SN/A * met: redistributions of source code must retain the above copyright 204126SN/A * notice, this list of conditions and the following disclaimer; 214126SN/A * redistributions in binary form must reproduce the above copyright 224126SN/A * notice, this list of conditions and the following disclaimer in the 234126SN/A * documentation and/or other materials provided with the distribution; 244126SN/A * neither the name of the copyright holders nor the names of its 254126SN/A * contributors may be used to endorse or promote products derived from 264126SN/A * this software without specific prior written permission. 274126SN/A * 284126SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 294126SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 304126SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 314126SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 324126SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 334126SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 344126SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 354126SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 364126SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 374126SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 384126SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 394126SN/A * 404126SN/A * Authors: Erik Hallnor 4111878Sandreas.sandberg@arm.com * Andreas Sandberg 424126SN/A * Andreas Hansson 438296Snate@binkert.org */ 448296Snate@binkert.org 4511802Sandreas.sandberg@arm.com/** @file 468295Snate@binkert.org * Definition of WriteQueue class functions. 478296Snate@binkert.org */ 484126SN/A 4911766Sandreas.sandberg@arm.com#include "mem/cache/write_queue.hh" 5011802Sandreas.sandberg@arm.com 5111802Sandreas.sandberg@arm.comusing namespace std; 5211766Sandreas.sandberg@arm.com 538296Snate@binkert.orgWriteQueue::WriteQueue(const std::string &_label, 5411878Sandreas.sandberg@arm.com int num_entries, int reserve) 5511878Sandreas.sandberg@arm.com : Queue<WriteQueueEntry>(_label, num_entries, reserve) 5611878Sandreas.sandberg@arm.com{} 5711878Sandreas.sandberg@arm.com 5811878Sandreas.sandberg@arm.comWriteQueueEntry * 5911878Sandreas.sandberg@arm.comWriteQueue::allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, 6011878Sandreas.sandberg@arm.com Tick when_ready, Counter order) 6111878Sandreas.sandberg@arm.com{ 6211878Sandreas.sandberg@arm.com assert(!freeList.empty()); 6311878Sandreas.sandberg@arm.com WriteQueueEntry *entry = freeList.front(); 6411878Sandreas.sandberg@arm.com assert(entry->getNumTargets() == 0); 6511878Sandreas.sandberg@arm.com freeList.pop_front(); 6611878Sandreas.sandberg@arm.com 6711878Sandreas.sandberg@arm.com entry->allocate(blk_addr, blk_size, pkt, when_ready, order); 6811878Sandreas.sandberg@arm.com entry->allocIter = allocatedList.insert(allocatedList.end(), entry); 6911878Sandreas.sandberg@arm.com entry->readyIter = addToReadyList(entry); 7011878Sandreas.sandberg@arm.com 7111878Sandreas.sandberg@arm.com allocated += 1; 7211878Sandreas.sandberg@arm.com return entry; 7311878Sandreas.sandberg@arm.com} 7411878Sandreas.sandberg@arm.com 7511878Sandreas.sandberg@arm.comvoid 7611878Sandreas.sandberg@arm.comWriteQueue::markInService(WriteQueueEntry *entry) 7711878Sandreas.sandberg@arm.com{ 7811878Sandreas.sandberg@arm.com if (!entry->isUncacheable()) { 7911878Sandreas.sandberg@arm.com // a normal eviction, such as a writeback or a clean evict, no 8011878Sandreas.sandberg@arm.com // more to do as we are done from the perspective of this 8111878Sandreas.sandberg@arm.com // cache 8211878Sandreas.sandberg@arm.com entry->popTarget(); 8311878Sandreas.sandberg@arm.com deallocate(entry); 8411878Sandreas.sandberg@arm.com } else { 8511878Sandreas.sandberg@arm.com // uncacheable write, and we will eventually receive a 8611878Sandreas.sandberg@arm.com // response 8711878Sandreas.sandberg@arm.com entry->markInService(); 8811878Sandreas.sandberg@arm.com readyList.erase(entry->readyIter); 8911878Sandreas.sandberg@arm.com _numInService += 1; 9011878Sandreas.sandberg@arm.com } 9111878Sandreas.sandberg@arm.com} 9211878Sandreas.sandberg@arm.com