write_queue.cc revision 11375:f98df9231cdd
110399Sstephan.diestelhorst@arm.com/* 211128Sali.jafri@arm.com * Copyright (c) 2012-2013, 2015-2016 ARM Limited 310399Sstephan.diestelhorst@arm.com * All rights reserved. 410399Sstephan.diestelhorst@arm.com * 510399Sstephan.diestelhorst@arm.com * The license below extends only to copyright in the software and shall 610399Sstephan.diestelhorst@arm.com * not be construed as granting a license to any other intellectual 710399Sstephan.diestelhorst@arm.com * property including but not limited to intellectual property relating 810399Sstephan.diestelhorst@arm.com * to a hardware implementation of the functionality of the software 910399Sstephan.diestelhorst@arm.com * licensed hereunder. You may use the software subject to the license 1010399Sstephan.diestelhorst@arm.com * terms below provided that you ensure that this notice is replicated 1110399Sstephan.diestelhorst@arm.com * unmodified and in its entirety in all distributions of the software, 1210399Sstephan.diestelhorst@arm.com * modified or unmodified, in source code or in binary form. 1310399Sstephan.diestelhorst@arm.com * 1410399Sstephan.diestelhorst@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 1510399Sstephan.diestelhorst@arm.com * All rights reserved. 1610399Sstephan.diestelhorst@arm.com * 1710399Sstephan.diestelhorst@arm.com * Redistribution and use in source and binary forms, with or without 1810399Sstephan.diestelhorst@arm.com * modification, are permitted provided that the following conditions are 1910399Sstephan.diestelhorst@arm.com * met: redistributions of source code must retain the above copyright 2010399Sstephan.diestelhorst@arm.com * notice, this list of conditions and the following disclaimer; 2110399Sstephan.diestelhorst@arm.com * redistributions in binary form must reproduce the above copyright 2210399Sstephan.diestelhorst@arm.com * notice, this list of conditions and the following disclaimer in the 2310399Sstephan.diestelhorst@arm.com * documentation and/or other materials provided with the distribution; 2410399Sstephan.diestelhorst@arm.com * neither the name of the copyright holders nor the names of its 2510399Sstephan.diestelhorst@arm.com * contributors may be used to endorse or promote products derived from 2610399Sstephan.diestelhorst@arm.com * this software without specific prior written permission. 2710399Sstephan.diestelhorst@arm.com * 2810399Sstephan.diestelhorst@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2910399Sstephan.diestelhorst@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3010399Sstephan.diestelhorst@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3110399Sstephan.diestelhorst@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3210399Sstephan.diestelhorst@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3310399Sstephan.diestelhorst@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3410399Sstephan.diestelhorst@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3510399Sstephan.diestelhorst@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3610399Sstephan.diestelhorst@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3711135Sandreas.hansson@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3810399Sstephan.diestelhorst@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3910399Sstephan.diestelhorst@arm.com * 4010399Sstephan.diestelhorst@arm.com * Authors: Erik Hallnor 4110399Sstephan.diestelhorst@arm.com * Andreas Sandberg 4211135Sandreas.hansson@arm.com * Andreas Hansson 4310399Sstephan.diestelhorst@arm.com */ 4410399Sstephan.diestelhorst@arm.com 4510399Sstephan.diestelhorst@arm.com/** @file 4610399Sstephan.diestelhorst@arm.com * Definition of WriteQueue class functions. 4710399Sstephan.diestelhorst@arm.com */ 4810399Sstephan.diestelhorst@arm.com 4910399Sstephan.diestelhorst@arm.com#include "mem/cache/write_queue.hh" 5010399Sstephan.diestelhorst@arm.com 5111129Sali.jafri@arm.comusing namespace std; 5211129Sali.jafri@arm.com 5311129Sali.jafri@arm.comWriteQueue::WriteQueue(const std::string &_label, 5411129Sali.jafri@arm.com int num_entries, int reserve) 5511129Sali.jafri@arm.com : Queue<WriteQueueEntry>(_label, num_entries, reserve) 5611129Sali.jafri@arm.com{} 5711129Sali.jafri@arm.com 5811129Sali.jafri@arm.comWriteQueueEntry * 5911129Sali.jafri@arm.comWriteQueue::allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, 6011129Sali.jafri@arm.com Tick when_ready, Counter order) 6111129Sali.jafri@arm.com{ 6210399Sstephan.diestelhorst@arm.com assert(!freeList.empty()); 6310399Sstephan.diestelhorst@arm.com WriteQueueEntry *entry = freeList.front(); 6410399Sstephan.diestelhorst@arm.com assert(entry->getNumTargets() == 0); 6510399Sstephan.diestelhorst@arm.com freeList.pop_front(); 6610399Sstephan.diestelhorst@arm.com 6710399Sstephan.diestelhorst@arm.com entry->allocate(blk_addr, blk_size, pkt, when_ready, order); 6811128Sali.jafri@arm.com entry->allocIter = allocatedList.insert(allocatedList.end(), entry); 6911128Sali.jafri@arm.com entry->readyIter = addToReadyList(entry); 7011128Sali.jafri@arm.com 7111128Sali.jafri@arm.com allocated += 1; 7210399Sstephan.diestelhorst@arm.com return entry; 7311131Sandreas.hansson@arm.com} 7411131Sandreas.hansson@arm.com 7511128Sali.jafri@arm.comvoid 7611128Sali.jafri@arm.comWriteQueue::markInService(WriteQueueEntry *entry) 7711128Sali.jafri@arm.com{ 7811128Sali.jafri@arm.com if (!entry->isUncacheable()) { 7911128Sali.jafri@arm.com // a normal eviction, such as a writeback or a clean evict, no 8011128Sali.jafri@arm.com // more to do as we are done from the perspective of this 8111128Sali.jafri@arm.com // cache 8211131Sandreas.hansson@arm.com entry->popTarget(); 8311131Sandreas.hansson@arm.com deallocate(entry); 8411131Sandreas.hansson@arm.com } else { 8511131Sandreas.hansson@arm.com // uncacheable write, and we will eventually receive a 8610403Sstephan.diestelhorst@arm.com // response 8710403Sstephan.diestelhorst@arm.com entry->markInService(); 8811129Sali.jafri@arm.com readyList.erase(entry->readyIter); 8911129Sali.jafri@arm.com _numInService += 1; 9011129Sali.jafri@arm.com } 9111129Sali.jafri@arm.com} 9211129Sali.jafri@arm.com