write_queue.cc revision 12727:56c23b54bcb1
112027Sjungma@eit.uni-kl.de/* 212027Sjungma@eit.uni-kl.de * Copyright (c) 2012-2013, 2015-2016 ARM Limited 312027Sjungma@eit.uni-kl.de * All rights reserved. 412027Sjungma@eit.uni-kl.de * 512027Sjungma@eit.uni-kl.de * The license below extends only to copyright in the software and shall 612027Sjungma@eit.uni-kl.de * not be construed as granting a license to any other intellectual 712027Sjungma@eit.uni-kl.de * property including but not limited to intellectual property relating 812027Sjungma@eit.uni-kl.de * to a hardware implementation of the functionality of the software 912027Sjungma@eit.uni-kl.de * licensed hereunder. You may use the software subject to the license 1012027Sjungma@eit.uni-kl.de * terms below provided that you ensure that this notice is replicated 1112027Sjungma@eit.uni-kl.de * unmodified and in its entirety in all distributions of the software, 1212027Sjungma@eit.uni-kl.de * modified or unmodified, in source code or in binary form. 1312027Sjungma@eit.uni-kl.de * 1412027Sjungma@eit.uni-kl.de * Copyright (c) 2003-2005 The Regents of The University of Michigan 1512027Sjungma@eit.uni-kl.de * All rights reserved. 1612027Sjungma@eit.uni-kl.de * 1712027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without 1812027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are 1912027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright 2012027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer; 2112027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright 2212027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the 2312027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution; 2412027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its 2512027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from 2612027Sjungma@eit.uni-kl.de * this software without specific prior written permission. 2712027Sjungma@eit.uni-kl.de * 2812027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2912027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3012027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3112027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3212027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3312027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3412027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3512027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3612027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3712027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3812027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3912027Sjungma@eit.uni-kl.de * 4012027Sjungma@eit.uni-kl.de * Authors: Erik Hallnor 4112027Sjungma@eit.uni-kl.de * Andreas Sandberg 4212027Sjungma@eit.uni-kl.de * Andreas Hansson 4312027Sjungma@eit.uni-kl.de */ 4412027Sjungma@eit.uni-kl.de 4512027Sjungma@eit.uni-kl.de/** @file 4612027Sjungma@eit.uni-kl.de * Definition of WriteQueue class functions. 4712027Sjungma@eit.uni-kl.de */ 4812027Sjungma@eit.uni-kl.de 4912027Sjungma@eit.uni-kl.de#include "mem/cache/write_queue.hh" 5012027Sjungma@eit.uni-kl.de 5112027Sjungma@eit.uni-kl.de#include <cassert> 5212027Sjungma@eit.uni-kl.de 5312027Sjungma@eit.uni-kl.de#include "mem/cache/write_queue_entry.hh" 5412027Sjungma@eit.uni-kl.de 5512027Sjungma@eit.uni-kl.deWriteQueue::WriteQueue(const std::string &_label, 5612027Sjungma@eit.uni-kl.de int num_entries, int reserve) 5712027Sjungma@eit.uni-kl.de : Queue<WriteQueueEntry>(_label, num_entries, reserve) 5812027Sjungma@eit.uni-kl.de{} 5912027Sjungma@eit.uni-kl.de 6012027Sjungma@eit.uni-kl.deWriteQueueEntry * 6112027Sjungma@eit.uni-kl.deWriteQueue::allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, 6212027Sjungma@eit.uni-kl.de Tick when_ready, Counter order) 6312027Sjungma@eit.uni-kl.de{ 6412027Sjungma@eit.uni-kl.de assert(!freeList.empty()); 6512027Sjungma@eit.uni-kl.de WriteQueueEntry *entry = freeList.front(); 6612027Sjungma@eit.uni-kl.de assert(entry->getNumTargets() == 0); 6712027Sjungma@eit.uni-kl.de freeList.pop_front(); 6812027Sjungma@eit.uni-kl.de 6912027Sjungma@eit.uni-kl.de entry->allocate(blk_addr, blk_size, pkt, when_ready, order); 7012027Sjungma@eit.uni-kl.de entry->allocIter = allocatedList.insert(allocatedList.end(), entry); 7112027Sjungma@eit.uni-kl.de entry->readyIter = addToReadyList(entry); 7212027Sjungma@eit.uni-kl.de 7312027Sjungma@eit.uni-kl.de allocated += 1; 7412027Sjungma@eit.uni-kl.de return entry; 7512027Sjungma@eit.uni-kl.de} 7612027Sjungma@eit.uni-kl.de 7712027Sjungma@eit.uni-kl.devoid 7812027Sjungma@eit.uni-kl.deWriteQueue::markInService(WriteQueueEntry *entry) 7912027Sjungma@eit.uni-kl.de{ 8012027Sjungma@eit.uni-kl.de // for a normal eviction, such as a writeback or a clean evict, 8112027Sjungma@eit.uni-kl.de // there is no more to do as we are done from the perspective of 8212027Sjungma@eit.uni-kl.de // this cache, and for uncacheable write we do not need the entry 8312027Sjungma@eit.uni-kl.de // as part of the response handling 8412027Sjungma@eit.uni-kl.de entry->popTarget(); 8512027Sjungma@eit.uni-kl.de deallocate(entry); 8612027Sjungma@eit.uni-kl.de} 8712027Sjungma@eit.uni-kl.de