111375Sandreas.hansson@arm.com/*
211375Sandreas.hansson@arm.com * Copyright (c) 2012-2013, 2015-2016 ARM Limited
311375Sandreas.hansson@arm.com * All rights reserved.
411375Sandreas.hansson@arm.com *
511375Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall
611375Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual
711375Sandreas.hansson@arm.com * property including but not limited to intellectual property relating
811375Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software
911375Sandreas.hansson@arm.com * licensed hereunder.  You may use the software subject to the license
1011375Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated
1111375Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software,
1211375Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form.
1311375Sandreas.hansson@arm.com *
1411375Sandreas.hansson@arm.com * Copyright (c) 2002-2005 The Regents of The University of Michigan
1511375Sandreas.hansson@arm.com * All rights reserved.
1611375Sandreas.hansson@arm.com *
1711375Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
1811375Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
1911375Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
2011375Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
2111375Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
2211375Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
2311375Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
2411375Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
2511375Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
2611375Sandreas.hansson@arm.com * this software without specific prior written permission.
2711375Sandreas.hansson@arm.com *
2811375Sandreas.hansson@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2911375Sandreas.hansson@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3011375Sandreas.hansson@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3111375Sandreas.hansson@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3211375Sandreas.hansson@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3311375Sandreas.hansson@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3411375Sandreas.hansson@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3511375Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3611375Sandreas.hansson@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3711375Sandreas.hansson@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3811375Sandreas.hansson@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3911375Sandreas.hansson@arm.com *
4011375Sandreas.hansson@arm.com * Authors: Erik Hallnor
4111375Sandreas.hansson@arm.com *          Andreas Hansson
4211375Sandreas.hansson@arm.com */
4311375Sandreas.hansson@arm.com
4411375Sandreas.hansson@arm.com/**
4511375Sandreas.hansson@arm.com * @file
4611375Sandreas.hansson@arm.com * Generic queue entry
4711375Sandreas.hansson@arm.com */
4811375Sandreas.hansson@arm.com
4911375Sandreas.hansson@arm.com#ifndef __MEM_CACHE_QUEUE_ENTRY_HH__
5011375Sandreas.hansson@arm.com#define __MEM_CACHE_QUEUE_ENTRY_HH__
5111375Sandreas.hansson@arm.com
5212727Snikos.nikoleris@arm.com#include "base/types.hh"
5311375Sandreas.hansson@arm.com#include "mem/packet.hh"
5411375Sandreas.hansson@arm.com
5512724Snikos.nikoleris@arm.comclass BaseCache;
5611375Sandreas.hansson@arm.com
5711375Sandreas.hansson@arm.com/**
5811375Sandreas.hansson@arm.com * A queue entry base class, to be used by both the MSHRs and
5911375Sandreas.hansson@arm.com * write-queue entries.
6011375Sandreas.hansson@arm.com */
6111375Sandreas.hansson@arm.comclass QueueEntry : public Packet::SenderState
6211375Sandreas.hansson@arm.com{
6311375Sandreas.hansson@arm.com
6411375Sandreas.hansson@arm.com    /**
6511375Sandreas.hansson@arm.com     * Consider the Queue a friend to avoid making everything public
6611375Sandreas.hansson@arm.com     */
6711375Sandreas.hansson@arm.com    template <class Entry>
6811375Sandreas.hansson@arm.com    friend class Queue;
6911375Sandreas.hansson@arm.com
7011375Sandreas.hansson@arm.com  protected:
7111375Sandreas.hansson@arm.com
7211375Sandreas.hansson@arm.com    /** Tick when ready to issue */
7311375Sandreas.hansson@arm.com    Tick readyTime;
7411375Sandreas.hansson@arm.com
7511375Sandreas.hansson@arm.com    /** True if the entry is uncacheable */
7611375Sandreas.hansson@arm.com    bool _isUncacheable;
7711375Sandreas.hansson@arm.com
7811375Sandreas.hansson@arm.com  public:
7913859Sodanrc@yahoo.com.br    /**
8013859Sodanrc@yahoo.com.br     * A queue entry is holding packets that will be serviced as soon as
8113859Sodanrc@yahoo.com.br     * resources are available. Since multiple references to the same
8213859Sodanrc@yahoo.com.br     * address can arrive while a packet is not serviced, each packet is
8313859Sodanrc@yahoo.com.br     * stored in a target containing its availability, order and other info,
8413859Sodanrc@yahoo.com.br     * and the queue entry stores these similar targets in a list.
8513859Sodanrc@yahoo.com.br     */
8613859Sodanrc@yahoo.com.br    class Target {
8713859Sodanrc@yahoo.com.br      public:
8813859Sodanrc@yahoo.com.br        const Tick recvTime;  //!< Time when request was received (for stats)
8913859Sodanrc@yahoo.com.br        const Tick readyTime; //!< Time when request is ready to be serviced
9013859Sodanrc@yahoo.com.br        const Counter order;  //!< Global order (for memory consistency mgmt)
9113859Sodanrc@yahoo.com.br        const PacketPtr pkt;  //!< Pending request packet.
9213859Sodanrc@yahoo.com.br
9313859Sodanrc@yahoo.com.br        /**
9413859Sodanrc@yahoo.com.br         * Default constructor. Assigns the current tick as the arrival time
9513859Sodanrc@yahoo.com.br         * of the packet.
9613859Sodanrc@yahoo.com.br         *
9713859Sodanrc@yahoo.com.br         * @param _pkt The pending request packet.
9813859Sodanrc@yahoo.com.br         * @param ready_time The tick at which the packet will be serviceable.
9913859Sodanrc@yahoo.com.br         * @param _order Global order.
10013859Sodanrc@yahoo.com.br         */
10113859Sodanrc@yahoo.com.br        Target(PacketPtr _pkt, Tick ready_time, Counter _order)
10213859Sodanrc@yahoo.com.br            : recvTime(curTick()), readyTime(ready_time), order(_order),
10313859Sodanrc@yahoo.com.br              pkt(_pkt)
10413859Sodanrc@yahoo.com.br        {}
10513859Sodanrc@yahoo.com.br    };
10611375Sandreas.hansson@arm.com
10711375Sandreas.hansson@arm.com    /** True if the entry has been sent downstream. */
10811375Sandreas.hansson@arm.com    bool inService;
10911375Sandreas.hansson@arm.com
11011375Sandreas.hansson@arm.com    /** Order number assigned to disambiguate writes and misses. */
11111375Sandreas.hansson@arm.com    Counter order;
11211375Sandreas.hansson@arm.com
11311375Sandreas.hansson@arm.com    /** Block aligned address. */
11411375Sandreas.hansson@arm.com    Addr blkAddr;
11511375Sandreas.hansson@arm.com
11611375Sandreas.hansson@arm.com    /** Block size of the cache. */
11711375Sandreas.hansson@arm.com    unsigned blkSize;
11811375Sandreas.hansson@arm.com
11911375Sandreas.hansson@arm.com    /** True if the entry targets the secure memory space. */
12011375Sandreas.hansson@arm.com    bool isSecure;
12111375Sandreas.hansson@arm.com
12213861Sodanrc@yahoo.com.br    QueueEntry()
12313861Sodanrc@yahoo.com.br        : readyTime(0), _isUncacheable(false),
12413861Sodanrc@yahoo.com.br          inService(false), order(0), blkAddr(0), blkSize(0), isSecure(false)
12511375Sandreas.hansson@arm.com    {}
12611375Sandreas.hansson@arm.com
12711375Sandreas.hansson@arm.com    bool isUncacheable() const { return _isUncacheable; }
12811375Sandreas.hansson@arm.com
12911375Sandreas.hansson@arm.com    /**
13013861Sodanrc@yahoo.com.br     * Check if entry corresponds to the one being looked for.
13113861Sodanrc@yahoo.com.br     *
13213861Sodanrc@yahoo.com.br     * @param addr Address to match against.
13313861Sodanrc@yahoo.com.br     * @param is_secure Whether the target should be in secure space or not.
13413861Sodanrc@yahoo.com.br     * @return True if entry matches given information.
13513861Sodanrc@yahoo.com.br     */
13613861Sodanrc@yahoo.com.br    virtual bool matchBlockAddr(const Addr addr, const bool is_secure)
13713861Sodanrc@yahoo.com.br                                                            const = 0;
13813861Sodanrc@yahoo.com.br
13913861Sodanrc@yahoo.com.br    /**
14013861Sodanrc@yahoo.com.br     * Check if entry contains a packet that corresponds to the one being
14113861Sodanrc@yahoo.com.br     * looked for.
14213861Sodanrc@yahoo.com.br     *
14313861Sodanrc@yahoo.com.br     * @param pkt The packet to search for.
14413861Sodanrc@yahoo.com.br     * @return True if any of its targets' packets matches the given one.
14513861Sodanrc@yahoo.com.br     */
14613861Sodanrc@yahoo.com.br    virtual bool matchBlockAddr(const PacketPtr pkt) const = 0;
14713861Sodanrc@yahoo.com.br
14813861Sodanrc@yahoo.com.br    /**
14913861Sodanrc@yahoo.com.br     * Check if given entry's packets conflict with this' entries packets.
15013861Sodanrc@yahoo.com.br     *
15113861Sodanrc@yahoo.com.br     * @param entry Other entry to compare against.
15213861Sodanrc@yahoo.com.br     * @return True if entry matches given information.
15313861Sodanrc@yahoo.com.br     */
15413861Sodanrc@yahoo.com.br    virtual bool conflictAddr(const QueueEntry* entry) const = 0;
15513861Sodanrc@yahoo.com.br
15613861Sodanrc@yahoo.com.br    /**
15711375Sandreas.hansson@arm.com     * Send this queue entry as a downstream packet, with the exact
15811375Sandreas.hansson@arm.com     * behaviour depending on the specific entry type.
15911375Sandreas.hansson@arm.com     */
16012724Snikos.nikoleris@arm.com    virtual bool sendPacket(BaseCache &cache) = 0;
16111375Sandreas.hansson@arm.com
16213859Sodanrc@yahoo.com.br    /**
16313859Sodanrc@yahoo.com.br     * Returns a pointer to the first target.
16413859Sodanrc@yahoo.com.br     *
16513859Sodanrc@yahoo.com.br     * @return A pointer to the first target.
16613859Sodanrc@yahoo.com.br     */
16713859Sodanrc@yahoo.com.br    virtual Target* getTarget() = 0;
16811375Sandreas.hansson@arm.com};
16911375Sandreas.hansson@arm.com
17011375Sandreas.hansson@arm.com#endif // __MEM_CACHE_QUEUE_ENTRY_HH__
171