write_queue.cc revision 11375
112841Sgabeblack@google.com/* 212841Sgabeblack@google.com * Copyright (c) 2012-2013, 2015-2016 ARM Limited 312841Sgabeblack@google.com * All rights reserved. 412841Sgabeblack@google.com * 512841Sgabeblack@google.com * The license below extends only to copyright in the software and shall 612841Sgabeblack@google.com * not be construed as granting a license to any other intellectual 712841Sgabeblack@google.com * property including but not limited to intellectual property relating 812841Sgabeblack@google.com * to a hardware implementation of the functionality of the software 912841Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1012841Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1112841Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1212841Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1312841Sgabeblack@google.com * 1412841Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 1512841Sgabeblack@google.com * All rights reserved. 1612841Sgabeblack@google.com * 1712841Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1812841Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1912841Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 2012841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 2112841Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 2212841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2312841Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2412841Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2512841Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2612841Sgabeblack@google.com * this software without specific prior written permission. 2712841Sgabeblack@google.com * 2812841Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2912841Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3012841Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3112841Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3212841Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3313201Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3412841Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3512841Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3612841Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3712841Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3812841Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3912853Sgabeblack@google.com * 4012841Sgabeblack@google.com * Authors: Erik Hallnor 4112841Sgabeblack@google.com * Andreas Sandberg 4212841Sgabeblack@google.com * Andreas Hansson 4312841Sgabeblack@google.com */ 4412853Sgabeblack@google.com 4512841Sgabeblack@google.com/** @file 4612841Sgabeblack@google.com * Definition of WriteQueue class functions. 4712841Sgabeblack@google.com */ 4812841Sgabeblack@google.com 4913201Sgabeblack@google.com#include "mem/cache/write_queue.hh" 5012841Sgabeblack@google.com 5112841Sgabeblack@google.comusing namespace std; 5212841Sgabeblack@google.com 5312841Sgabeblack@google.comWriteQueue::WriteQueue(const std::string &_label, 5412841Sgabeblack@google.com int num_entries, int reserve) 5512841Sgabeblack@google.com : Queue<WriteQueueEntry>(_label, num_entries, reserve) 5612841Sgabeblack@google.com{} 5712841Sgabeblack@google.com 5812841Sgabeblack@google.comWriteQueueEntry * 5912841Sgabeblack@google.comWriteQueue::allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, 6012841Sgabeblack@google.com Tick when_ready, Counter order) 6112841Sgabeblack@google.com{ 6212841Sgabeblack@google.com assert(!freeList.empty()); 6312841Sgabeblack@google.com WriteQueueEntry *entry = freeList.front(); 6413201Sgabeblack@google.com assert(entry->getNumTargets() == 0); 6512841Sgabeblack@google.com freeList.pop_front(); 6612841Sgabeblack@google.com 6712841Sgabeblack@google.com entry->allocate(blk_addr, blk_size, pkt, when_ready, order); 6813201Sgabeblack@google.com entry->allocIter = allocatedList.insert(allocatedList.end(), entry); 6912841Sgabeblack@google.com entry->readyIter = addToReadyList(entry); 7012841Sgabeblack@google.com 7112841Sgabeblack@google.com allocated += 1; 7212841Sgabeblack@google.com return entry; 7312841Sgabeblack@google.com} 74 75void 76WriteQueue::markInService(WriteQueueEntry *entry) 77{ 78 if (!entry->isUncacheable()) { 79 // a normal eviction, such as a writeback or a clean evict, no 80 // more to do as we are done from the perspective of this 81 // cache 82 entry->popTarget(); 83 deallocate(entry); 84 } else { 85 // uncacheable write, and we will eventually receive a 86 // response 87 entry->markInService(); 88 readyList.erase(entry->readyIter); 89 _numInService += 1; 90 } 91} 92