request.hh revision 9332
12381SN/A/*
29332Sdam.sunwoo@arm.com * Copyright (c) 2012 ARM Limited
39332Sdam.sunwoo@arm.com * All rights reserved
49332Sdam.sunwoo@arm.com *
59332Sdam.sunwoo@arm.com * The license below extends only to copyright in the software and shall
69332Sdam.sunwoo@arm.com * not be construed as granting a license to any other intellectual
79332Sdam.sunwoo@arm.com * property including but not limited to intellectual property relating
89332Sdam.sunwoo@arm.com * to a hardware implementation of the functionality of the software
99332Sdam.sunwoo@arm.com * licensed hereunder.  You may use the software subject to the license
109332Sdam.sunwoo@arm.com * terms below provided that you ensure that this notice is replicated
119332Sdam.sunwoo@arm.com * unmodified and in its entirety in all distributions of the software,
129332Sdam.sunwoo@arm.com * modified or unmodified, in source code or in binary form.
139332Sdam.sunwoo@arm.com *
142381SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
152381SN/A * All rights reserved.
162381SN/A *
172381SN/A * Redistribution and use in source and binary forms, with or without
182381SN/A * modification, are permitted provided that the following conditions are
192381SN/A * met: redistributions of source code must retain the above copyright
202381SN/A * notice, this list of conditions and the following disclaimer;
212381SN/A * redistributions in binary form must reproduce the above copyright
222381SN/A * notice, this list of conditions and the following disclaimer in the
232381SN/A * documentation and/or other materials provided with the distribution;
242381SN/A * neither the name of the copyright holders nor the names of its
252381SN/A * contributors may be used to endorse or promote products derived from
262381SN/A * this software without specific prior written permission.
272381SN/A *
282381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665Ssaidi@eecs.umich.edu *
402665Ssaidi@eecs.umich.edu * Authors: Ron Dreslinski
412665Ssaidi@eecs.umich.edu *          Steve Reinhardt
422665Ssaidi@eecs.umich.edu *          Ali Saidi
432381SN/A */
442381SN/A
452381SN/A/**
462982Sstever@eecs.umich.edu * @file
472982Sstever@eecs.umich.edu * Declaration of a request, the overall memory request consisting of
482381SN/A the parts of the request that are persistent throughout the transaction.
492381SN/A */
502381SN/A
512381SN/A#ifndef __MEM_REQUEST_HH__
522381SN/A#define __MEM_REQUEST_HH__
532381SN/A
545735Snate@binkert.org#include <cassert>
558833Sdam.sunwoo@arm.com#include <climits>
565735Snate@binkert.org
575735Snate@binkert.org#include "base/flags.hh"
585744Sgblack@eecs.umich.edu#include "base/misc.hh"
596214Snate@binkert.org#include "base/types.hh"
604167Sbinkertn@umich.edu#include "sim/core.hh"
612394SN/A
629332Sdam.sunwoo@arm.com/**
639332Sdam.sunwoo@arm.com * Special TaskIds that are used for per-context-switch stats dumps
649332Sdam.sunwoo@arm.com * and Cache Occupancy. Having too many tasks seems to be a problem
659332Sdam.sunwoo@arm.com * with vector stats. 1024 seems to be a reasonable number that
669332Sdam.sunwoo@arm.com * doesn't cause a problem with stats and is large enough to realistic
679332Sdam.sunwoo@arm.com * benchmarks (Linux/Android boot, BBench, etc.)
689332Sdam.sunwoo@arm.com */
699332Sdam.sunwoo@arm.com
709332Sdam.sunwoo@arm.comnamespace ContextSwitchTaskId {
719332Sdam.sunwoo@arm.com    enum TaskId {
729332Sdam.sunwoo@arm.com        MaxNormalTaskId = 1021, /* Maximum number of normal tasks */
739332Sdam.sunwoo@arm.com        Prefetcher = 1022, /* For cache lines brought in by prefetcher */
749332Sdam.sunwoo@arm.com        DMA = 1023, /* Mostly Table Walker */
759332Sdam.sunwoo@arm.com        Unknown = 1024,
769332Sdam.sunwoo@arm.com        NumTaskId
779332Sdam.sunwoo@arm.com    };
789332Sdam.sunwoo@arm.com}
799332Sdam.sunwoo@arm.com
802394SN/Aclass Request;
812394SN/A
822394SN/Atypedef Request* RequestPtr;
838832SAli.Saidi@ARM.comtypedef uint16_t MasterID;
842394SN/A
859044SAli.Saidi@ARM.comclass Request
862381SN/A{
875735Snate@binkert.org  public:
885735Snate@binkert.org    typedef uint32_t FlagsType;
895735Snate@binkert.org    typedef ::Flags<FlagsType> Flags;
905735Snate@binkert.org
915735Snate@binkert.org    /** ASI information for this request if it exists. */
925735Snate@binkert.org    static const FlagsType ASI_BITS                    = 0x000000FF;
936133Ssteve.reinhardt@amd.com    /** The request was an instruction fetch. */
946133Ssteve.reinhardt@amd.com    static const FlagsType INST_FETCH                  = 0x00000100;
955735Snate@binkert.org    /** The virtual address is also the physical address. */
965735Snate@binkert.org    static const FlagsType PHYSICAL                    = 0x00000200;
975735Snate@binkert.org    /** The request is an ALPHA VPTE pal access (hw_ld). */
985735Snate@binkert.org    static const FlagsType VPTE                        = 0x00000400;
995735Snate@binkert.org    /** Use the alternate mode bits in ALPHA. */
1005735Snate@binkert.org    static const FlagsType ALTMODE                     = 0x00000800;
1015735Snate@binkert.org    /** The request is to an uncacheable address. */
1025735Snate@binkert.org    static const FlagsType UNCACHEABLE                 = 0x00001000;
1036133Ssteve.reinhardt@amd.com    /** This request is to a memory mapped register. */
1048105Sgblack@eecs.umich.edu    static const FlagsType MMAPPED_IPR                  = 0x00002000;
1057612SGene.Wu@arm.com    /** This request is a clear exclusive. */
1067705Sgblack@eecs.umich.edu    static const FlagsType CLEAR_LL                    = 0x00004000;
1076133Ssteve.reinhardt@amd.com
1085890Sgblack@eecs.umich.edu    /** The request should not cause a memory access. */
1096133Ssteve.reinhardt@amd.com    static const FlagsType NO_ACCESS                   = 0x00080000;
1106103Sgblack@eecs.umich.edu    /** This request will lock or unlock the accessed memory. When used with
1116103Sgblack@eecs.umich.edu     * a load, the access locks the particular chunk of memory. When used
1126103Sgblack@eecs.umich.edu     * with a store, it unlocks. The rule is that locked accesses have to be
1136103Sgblack@eecs.umich.edu     * made up of a locked load, some operation on the data, and then a locked
1146103Sgblack@eecs.umich.edu     * store.
1156103Sgblack@eecs.umich.edu     */
1166133Ssteve.reinhardt@amd.com    static const FlagsType LOCKED                      = 0x00100000;
1176133Ssteve.reinhardt@amd.com    /** The request is a Load locked/store conditional. */
1186133Ssteve.reinhardt@amd.com    static const FlagsType LLSC                        = 0x00200000;
1195735Snate@binkert.org    /** This request is for a memory swap. */
1206133Ssteve.reinhardt@amd.com    static const FlagsType MEM_SWAP                    = 0x00400000;
1216133Ssteve.reinhardt@amd.com    static const FlagsType MEM_SWAP_COND               = 0x00800000;
1226133Ssteve.reinhardt@amd.com
1236106Ssteve.reinhardt@amd.com    /** The request is a prefetch. */
1246106Ssteve.reinhardt@amd.com    static const FlagsType PREFETCH                    = 0x01000000;
1256133Ssteve.reinhardt@amd.com    /** The request should be prefetched into the exclusive state. */
1266133Ssteve.reinhardt@amd.com    static const FlagsType PF_EXCLUSIVE                = 0x02000000;
1276133Ssteve.reinhardt@amd.com    /** The request should be marked as LRU. */
1286133Ssteve.reinhardt@amd.com    static const FlagsType EVICT_NEXT                  = 0x04000000;
1295735Snate@binkert.org
1306104Ssteve.reinhardt@amd.com    /** These flags are *not* cleared when a Request object is reused
1316104Ssteve.reinhardt@amd.com       (assigned a new address). */
1326105Ssteve.reinhardt@amd.com    static const FlagsType STICKY_FLAGS = INST_FETCH;
1336104Ssteve.reinhardt@amd.com
1348832SAli.Saidi@ARM.com    /** Request Ids that are statically allocated
1358832SAli.Saidi@ARM.com     * @{*/
1368832SAli.Saidi@ARM.com    /** This request id is used for writeback requests by the caches */
1378832SAli.Saidi@ARM.com    static const MasterID wbMasterId = 0;
1388832SAli.Saidi@ARM.com    /** This request id is used for functional requests that don't come from a
1398832SAli.Saidi@ARM.com     * particular device
1408832SAli.Saidi@ARM.com     */
1418832SAli.Saidi@ARM.com    static const MasterID funcMasterId = 1;
1428832SAli.Saidi@ARM.com    /** This request id is used for message signaled interrupts */
1438832SAli.Saidi@ARM.com    static const MasterID intMasterId = 2;
1448833Sdam.sunwoo@arm.com    /** Invalid request id for assertion checking only. It is invalid behavior
1458833Sdam.sunwoo@arm.com     * to ever send this id as part of a request.
1468833Sdam.sunwoo@arm.com     * @todo C++1x replace with numeric_limits when constexpr is added  */
1478833Sdam.sunwoo@arm.com    static const MasterID invldMasterId = USHRT_MAX;
1488832SAli.Saidi@ARM.com    /** @} */
1498832SAli.Saidi@ARM.com
1509332Sdam.sunwoo@arm.com    /** Invalid or unknown Pid. Possible when operating system is not present
1519332Sdam.sunwoo@arm.com     *  or has not assigned a pid yet */
1529332Sdam.sunwoo@arm.com    static const uint32_t invldPid = UINT_MAX;
1539332Sdam.sunwoo@arm.com
1545735Snate@binkert.org  private:
1556104Ssteve.reinhardt@amd.com    typedef uint8_t PrivateFlagsType;
1566104Ssteve.reinhardt@amd.com    typedef ::Flags<PrivateFlagsType> PrivateFlags;
1575735Snate@binkert.org
1585735Snate@binkert.org    /** Whether or not the size is valid. */
1596104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_SIZE           = 0x00000001;
1605735Snate@binkert.org    /** Whether or not paddr is valid (has been written yet). */
1616104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_PADDR          = 0x00000002;
1625735Snate@binkert.org    /** Whether or not the vaddr & asid are valid. */
1636104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_VADDR          = 0x00000004;
1645735Snate@binkert.org    /** Whether or not the pc is valid. */
1656104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_PC             = 0x00000010;
1665735Snate@binkert.org    /** Whether or not the context ID is valid. */
1676104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_CONTEXT_ID     = 0x00000020;
1686104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_THREAD_ID      = 0x00000040;
1695735Snate@binkert.org    /** Whether or not the sc result is valid. */
1706104Ssteve.reinhardt@amd.com    static const PrivateFlagsType VALID_EXTRA_DATA     = 0x00000080;
1716104Ssteve.reinhardt@amd.com
1726104Ssteve.reinhardt@amd.com    /** These flags are *not* cleared when a Request object is reused
1736104Ssteve.reinhardt@amd.com       (assigned a new address). */
1746104Ssteve.reinhardt@amd.com    static const PrivateFlagsType STICKY_PRIVATE_FLAGS =
1756104Ssteve.reinhardt@amd.com        VALID_CONTEXT_ID | VALID_THREAD_ID;
1765735Snate@binkert.org
1772663Sstever@eecs.umich.edu  private:
1782663Sstever@eecs.umich.edu    /**
1792663Sstever@eecs.umich.edu     * The physical address of the request. Valid only if validPaddr
1805735Snate@binkert.org     * is set.
1815735Snate@binkert.org     */
1826427Ssteve.reinhardt@amd.com    Addr _paddr;
1832532SN/A
1842663Sstever@eecs.umich.edu    /**
1852663Sstever@eecs.umich.edu     * The size of the request. This field must be set when vaddr or
1862663Sstever@eecs.umich.edu     * paddr is written via setVirt() or setPhys(), so it is always
1875735Snate@binkert.org     * valid as long as one of the address fields is valid.
1885735Snate@binkert.org     */
1896427Ssteve.reinhardt@amd.com    int _size;
1902395SN/A
1918832SAli.Saidi@ARM.com    /** The requestor ID which is unique in the system for all ports
1928832SAli.Saidi@ARM.com     * that are capable of issuing a transaction
1938832SAli.Saidi@ARM.com     */
1948832SAli.Saidi@ARM.com    MasterID _masterId;
1958832SAli.Saidi@ARM.com
1962532SN/A    /** Flag structure for the request. */
1976427Ssteve.reinhardt@amd.com    Flags _flags;
1982384SN/A
1996104Ssteve.reinhardt@amd.com    /** Private flags for field validity checking. */
2006104Ssteve.reinhardt@amd.com    PrivateFlags privateFlags;
2016104Ssteve.reinhardt@amd.com
2022663Sstever@eecs.umich.edu    /**
2032663Sstever@eecs.umich.edu     * The time this request was started. Used to calculate
2047823Ssteve.reinhardt@amd.com     * latencies. This field is set to curTick() any time paddr or vaddr
2055735Snate@binkert.org     * is written.
2065735Snate@binkert.org     */
2076223Snate@binkert.org    Tick _time;
2082384SN/A
2092384SN/A    /** The address space ID. */
2106427Ssteve.reinhardt@amd.com    int _asid;
2113806Ssaidi@eecs.umich.edu
2122663Sstever@eecs.umich.edu    /** The virtual address of the request. */
2136427Ssteve.reinhardt@amd.com    Addr _vaddr;
2142384SN/A
2155735Snate@binkert.org    /**
2165735Snate@binkert.org     * Extra data for the request, such as the return value of
2174040Ssaidi@eecs.umich.edu     * store conditional or the compare value for a CAS. */
2186427Ssteve.reinhardt@amd.com    uint64_t _extraData;
2192384SN/A
2205714Shsul@eecs.umich.edu    /** The context ID (for statistics, typically). */
2215714Shsul@eecs.umich.edu    int _contextId;
2225714Shsul@eecs.umich.edu    /** The thread ID (id within this CPU) */
2235714Shsul@eecs.umich.edu    int _threadId;
2242384SN/A
2252381SN/A    /** program counter of initiating access; for tracing/debugging */
2266427Ssteve.reinhardt@amd.com    Addr _pc;
2272663Sstever@eecs.umich.edu
2282532SN/A  public:
2296427Ssteve.reinhardt@amd.com    /** Minimal constructor.  No fields are initialized.
2306427Ssteve.reinhardt@amd.com     *  (Note that _flags and privateFlags are cleared by Flags
2316427Ssteve.reinhardt@amd.com     *  default constructor.)
2326427Ssteve.reinhardt@amd.com     */
2332663Sstever@eecs.umich.edu    Request()
2342663Sstever@eecs.umich.edu    {}
2352532SN/A
2362663Sstever@eecs.umich.edu    /**
2372663Sstever@eecs.umich.edu     * Constructor for physical (e.g. device) requests.  Initializes
2387823Ssteve.reinhardt@amd.com     * just physical address, size, flags, and timestamp (to curTick()).
2395735Snate@binkert.org     * These fields are adequate to perform a request.
2405735Snate@binkert.org     */
2418832SAli.Saidi@ARM.com    Request(Addr paddr, int size, Flags flags, MasterID mid)
2425735Snate@binkert.org    {
2438832SAli.Saidi@ARM.com        setPhys(paddr, size, flags, mid);
2445735Snate@binkert.org    }
2452532SN/A
2468832SAli.Saidi@ARM.com    Request(Addr paddr, int size, Flags flags, MasterID mid, Tick time)
2476223Snate@binkert.org    {
2488832SAli.Saidi@ARM.com        setPhys(paddr, size, flags, mid, time);
2496223Snate@binkert.org    }
2506223Snate@binkert.org
2518832SAli.Saidi@ARM.com    Request(Addr paddr, int size, Flags flags, MasterID mid, Tick time, Addr pc)
2526899SBrad.Beckmann@amd.com    {
2538832SAli.Saidi@ARM.com        setPhys(paddr, size, flags, mid, time);
2546899SBrad.Beckmann@amd.com        privateFlags.set(VALID_PC);
2556899SBrad.Beckmann@amd.com        _pc = pc;
2566899SBrad.Beckmann@amd.com    }
2576899SBrad.Beckmann@amd.com
2588832SAli.Saidi@ARM.com    Request(int asid, Addr vaddr, int size, Flags flags, MasterID mid, Addr pc,
2596221Snate@binkert.org            int cid, ThreadID tid)
2602669Sktlim@umich.edu    {
2618832SAli.Saidi@ARM.com        setVirt(asid, vaddr, size, flags, mid, pc);
2625735Snate@binkert.org        setThreadContext(cid, tid);
2632669Sktlim@umich.edu    }
2642669Sktlim@umich.edu
2659044SAli.Saidi@ARM.com    ~Request() {}
2664610Ssaidi@eecs.umich.edu
2672663Sstever@eecs.umich.edu    /**
2685735Snate@binkert.org     * Set up CPU and thread numbers.
2695735Snate@binkert.org     */
2705735Snate@binkert.org    void
2716221Snate@binkert.org    setThreadContext(int context_id, ThreadID tid)
2722663Sstever@eecs.umich.edu    {
2735735Snate@binkert.org        _contextId = context_id;
2746221Snate@binkert.org        _threadId = tid;
2756104Ssteve.reinhardt@amd.com        privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID);
2762663Sstever@eecs.umich.edu    }
2772532SN/A
2782663Sstever@eecs.umich.edu    /**
2792663Sstever@eecs.umich.edu     * Set up a physical (e.g. device) request in a previously
2805735Snate@binkert.org     * allocated Request object.
2815735Snate@binkert.org     */
2825735Snate@binkert.org    void
2838832SAli.Saidi@ARM.com    setPhys(Addr paddr, int size, Flags flags, MasterID mid, Tick time)
2842663Sstever@eecs.umich.edu    {
2856427Ssteve.reinhardt@amd.com        assert(size >= 0);
2866427Ssteve.reinhardt@amd.com        _paddr = paddr;
2876427Ssteve.reinhardt@amd.com        _size = size;
2886223Snate@binkert.org        _time = time;
2898832SAli.Saidi@ARM.com        _masterId = mid;
2906427Ssteve.reinhardt@amd.com        _flags.clear(~STICKY_FLAGS);
2916427Ssteve.reinhardt@amd.com        _flags.set(flags);
2926104Ssteve.reinhardt@amd.com        privateFlags.clear(~STICKY_PRIVATE_FLAGS);
2936104Ssteve.reinhardt@amd.com        privateFlags.set(VALID_PADDR|VALID_SIZE);
2942663Sstever@eecs.umich.edu    }
2952532SN/A
2966223Snate@binkert.org    void
2978832SAli.Saidi@ARM.com    setPhys(Addr paddr, int size, Flags flags, MasterID mid)
2986223Snate@binkert.org    {
2998832SAli.Saidi@ARM.com        setPhys(paddr, size, flags, mid, curTick());
3006223Snate@binkert.org    }
3016223Snate@binkert.org
3022663Sstever@eecs.umich.edu    /**
3032663Sstever@eecs.umich.edu     * Set up a virtual (e.g., CPU) request in a previously
3045735Snate@binkert.org     * allocated Request object.
3055735Snate@binkert.org     */
3065735Snate@binkert.org    void
3078832SAli.Saidi@ARM.com    setVirt(int asid, Addr vaddr, int size, Flags flags, MasterID mid, Addr pc)
3082663Sstever@eecs.umich.edu    {
3096427Ssteve.reinhardt@amd.com        assert(size >= 0);
3106427Ssteve.reinhardt@amd.com        _asid = asid;
3116427Ssteve.reinhardt@amd.com        _vaddr = vaddr;
3126427Ssteve.reinhardt@amd.com        _size = size;
3138832SAli.Saidi@ARM.com        _masterId = mid;
3146427Ssteve.reinhardt@amd.com        _pc = pc;
3157823Ssteve.reinhardt@amd.com        _time = curTick();
3165735Snate@binkert.org
3176427Ssteve.reinhardt@amd.com        _flags.clear(~STICKY_FLAGS);
3186427Ssteve.reinhardt@amd.com        _flags.set(flags);
3196104Ssteve.reinhardt@amd.com        privateFlags.clear(~STICKY_PRIVATE_FLAGS);
3206104Ssteve.reinhardt@amd.com        privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC);
3212663Sstever@eecs.umich.edu    }
3222532SN/A
3235735Snate@binkert.org    /**
3245735Snate@binkert.org     * Set just the physical address.  This should only be used to
3252663Sstever@eecs.umich.edu     * record the result of a translation, and thus the vaddr must be
3262663Sstever@eecs.umich.edu     * valid before this method is called.  Otherwise, use setPhys()
3272663Sstever@eecs.umich.edu     * to guarantee that the size and flags are also set.
3282663Sstever@eecs.umich.edu     */
3295735Snate@binkert.org    void
3306427Ssteve.reinhardt@amd.com    setPaddr(Addr paddr)
3312663Sstever@eecs.umich.edu    {
3326104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_VADDR));
3336427Ssteve.reinhardt@amd.com        _paddr = paddr;
3346104Ssteve.reinhardt@amd.com        privateFlags.set(VALID_PADDR);
3352663Sstever@eecs.umich.edu    }
3362532SN/A
3375735Snate@binkert.org    /**
3385744Sgblack@eecs.umich.edu     * Generate two requests as if this request had been split into two
3395744Sgblack@eecs.umich.edu     * pieces. The original request can't have been translated already.
3405744Sgblack@eecs.umich.edu     */
3415744Sgblack@eecs.umich.edu    void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2)
3425744Sgblack@eecs.umich.edu    {
3436104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_VADDR));
3446104Ssteve.reinhardt@amd.com        assert(privateFlags.noneSet(VALID_PADDR));
3456427Ssteve.reinhardt@amd.com        assert(split_addr > _vaddr && split_addr < _vaddr + _size);
3465744Sgblack@eecs.umich.edu        req1 = new Request;
3475744Sgblack@eecs.umich.edu        *req1 = *this;
3485744Sgblack@eecs.umich.edu        req2 = new Request;
3495744Sgblack@eecs.umich.edu        *req2 = *this;
3506427Ssteve.reinhardt@amd.com        req1->_size = split_addr - _vaddr;
3516427Ssteve.reinhardt@amd.com        req2->_vaddr = split_addr;
3526427Ssteve.reinhardt@amd.com        req2->_size = _size - req1->_size;
3535744Sgblack@eecs.umich.edu    }
3545744Sgblack@eecs.umich.edu
3555744Sgblack@eecs.umich.edu    /**
3565735Snate@binkert.org     * Accessor for paddr.
3575735Snate@binkert.org     */
3586104Ssteve.reinhardt@amd.com    bool
3596104Ssteve.reinhardt@amd.com    hasPaddr()
3606104Ssteve.reinhardt@amd.com    {
3616104Ssteve.reinhardt@amd.com        return privateFlags.isSet(VALID_PADDR);
3626104Ssteve.reinhardt@amd.com    }
3636104Ssteve.reinhardt@amd.com
3645735Snate@binkert.org    Addr
3655735Snate@binkert.org    getPaddr()
3665735Snate@binkert.org    {
3676104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_PADDR));
3686427Ssteve.reinhardt@amd.com        return _paddr;
3695735Snate@binkert.org    }
3702663Sstever@eecs.umich.edu
3715735Snate@binkert.org    /**
3725735Snate@binkert.org     *  Accessor for size.
3735735Snate@binkert.org     */
3746104Ssteve.reinhardt@amd.com    bool
3756104Ssteve.reinhardt@amd.com    hasSize()
3766104Ssteve.reinhardt@amd.com    {
3776104Ssteve.reinhardt@amd.com        return privateFlags.isSet(VALID_SIZE);
3786104Ssteve.reinhardt@amd.com    }
3796104Ssteve.reinhardt@amd.com
3805735Snate@binkert.org    int
3815735Snate@binkert.org    getSize()
3825735Snate@binkert.org    {
3836104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_SIZE));
3846427Ssteve.reinhardt@amd.com        return _size;
3855735Snate@binkert.org    }
3865735Snate@binkert.org
3872663Sstever@eecs.umich.edu    /** Accessor for time. */
3885735Snate@binkert.org    Tick
3896223Snate@binkert.org    time() const
3905735Snate@binkert.org    {
3916104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
3926223Snate@binkert.org        return _time;
3936223Snate@binkert.org    }
3946223Snate@binkert.org
3956223Snate@binkert.org    void
3966223Snate@binkert.org    time(Tick time)
3976223Snate@binkert.org    {
3986223Snate@binkert.org        assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
3996223Snate@binkert.org        _time = time;
4005735Snate@binkert.org    }
4015735Snate@binkert.org
4022663Sstever@eecs.umich.edu    /** Accessor for flags. */
4035735Snate@binkert.org    Flags
4045735Snate@binkert.org    getFlags()
4055735Snate@binkert.org    {
4066104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
4076427Ssteve.reinhardt@amd.com        return _flags;
4085735Snate@binkert.org    }
4095735Snate@binkert.org
4106428Ssteve.reinhardt@amd.com    /** Note that unlike other accessors, this function sets *specific
4116428Ssteve.reinhardt@amd.com       flags* (ORs them in); it does not assign its argument to the
4126428Ssteve.reinhardt@amd.com       _flags field.  Thus this method should rightly be called
4136428Ssteve.reinhardt@amd.com       setFlags() and not just flags(). */
4145735Snate@binkert.org    void
4156427Ssteve.reinhardt@amd.com    setFlags(Flags flags)
4165735Snate@binkert.org    {
4176104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
4186427Ssteve.reinhardt@amd.com        _flags.set(flags);
4195735Snate@binkert.org    }
4205735Snate@binkert.org
4212663Sstever@eecs.umich.edu    /** Accessor function for vaddr.*/
4225735Snate@binkert.org    Addr
4235735Snate@binkert.org    getVaddr()
4245735Snate@binkert.org    {
4256104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_VADDR));
4266427Ssteve.reinhardt@amd.com        return _vaddr;
4275735Snate@binkert.org    }
4282663Sstever@eecs.umich.edu
4298832SAli.Saidi@ARM.com    /** Accesssor for the requestor id. */
4308832SAli.Saidi@ARM.com    MasterID
4318832SAli.Saidi@ARM.com    masterId()
4328832SAli.Saidi@ARM.com    {
4338832SAli.Saidi@ARM.com        return _masterId;
4348832SAli.Saidi@ARM.com    }
4358832SAli.Saidi@ARM.com
4362663Sstever@eecs.umich.edu    /** Accessor function for asid.*/
4375735Snate@binkert.org    int
4385735Snate@binkert.org    getAsid()
4395735Snate@binkert.org    {
4406104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_VADDR));
4416427Ssteve.reinhardt@amd.com        return _asid;
4425735Snate@binkert.org    }
4432663Sstever@eecs.umich.edu
4448551Sdaniel.johnson@arm.com    /** Accessor function for asid.*/
4458551Sdaniel.johnson@arm.com    void
4468551Sdaniel.johnson@arm.com    setAsid(int asid)
4478551Sdaniel.johnson@arm.com    {
4488551Sdaniel.johnson@arm.com        _asid = asid;
4498551Sdaniel.johnson@arm.com    }
4508551Sdaniel.johnson@arm.com
4513804Ssaidi@eecs.umich.edu    /** Accessor function for asi.*/
4525735Snate@binkert.org    uint8_t
4535735Snate@binkert.org    getAsi()
4545735Snate@binkert.org    {
4556104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_VADDR));
4566427Ssteve.reinhardt@amd.com        return _flags & ASI_BITS;
4575735Snate@binkert.org    }
4583804Ssaidi@eecs.umich.edu
4592679Sktlim@umich.edu    /** Accessor function to check if sc result is valid. */
4605735Snate@binkert.org    bool
4615735Snate@binkert.org    extraDataValid()
4625735Snate@binkert.org    {
4636104Ssteve.reinhardt@amd.com        return privateFlags.isSet(VALID_EXTRA_DATA);
4645735Snate@binkert.org    }
4655735Snate@binkert.org
4662663Sstever@eecs.umich.edu    /** Accessor function for store conditional return value.*/
4675735Snate@binkert.org    uint64_t
4685735Snate@binkert.org    getExtraData() const
4695735Snate@binkert.org    {
4706104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_EXTRA_DATA));
4716427Ssteve.reinhardt@amd.com        return _extraData;
4725735Snate@binkert.org    }
4735735Snate@binkert.org
4742663Sstever@eecs.umich.edu    /** Accessor function for store conditional return value.*/
4755735Snate@binkert.org    void
4766427Ssteve.reinhardt@amd.com    setExtraData(uint64_t extraData)
4775735Snate@binkert.org    {
4786427Ssteve.reinhardt@amd.com        _extraData = extraData;
4796104Ssteve.reinhardt@amd.com        privateFlags.set(VALID_EXTRA_DATA);
4805735Snate@binkert.org    }
4812663Sstever@eecs.umich.edu
4826010Ssteve.reinhardt@amd.com    bool
4836010Ssteve.reinhardt@amd.com    hasContextId() const
4846010Ssteve.reinhardt@amd.com    {
4856104Ssteve.reinhardt@amd.com        return privateFlags.isSet(VALID_CONTEXT_ID);
4866010Ssteve.reinhardt@amd.com    }
4876010Ssteve.reinhardt@amd.com
4885714Shsul@eecs.umich.edu    /** Accessor function for context ID.*/
4895735Snate@binkert.org    int
4905735Snate@binkert.org    contextId() const
4915735Snate@binkert.org    {
4926104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_CONTEXT_ID));
4935735Snate@binkert.org        return _contextId;
4945735Snate@binkert.org    }
4955735Snate@binkert.org
4965714Shsul@eecs.umich.edu    /** Accessor function for thread ID. */
4975735Snate@binkert.org    int
4985735Snate@binkert.org    threadId() const
4995735Snate@binkert.org    {
5006104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_THREAD_ID));
5015735Snate@binkert.org        return _threadId;
5025735Snate@binkert.org    }
5032663Sstever@eecs.umich.edu
5045875Ssteve.reinhardt@amd.com    bool
5055875Ssteve.reinhardt@amd.com    hasPC() const
5065875Ssteve.reinhardt@amd.com    {
5076104Ssteve.reinhardt@amd.com        return privateFlags.isSet(VALID_PC);
5085875Ssteve.reinhardt@amd.com    }
5095875Ssteve.reinhardt@amd.com
5106010Ssteve.reinhardt@amd.com    /** Accessor function for pc.*/
5115735Snate@binkert.org    Addr
5125735Snate@binkert.org    getPC() const
5135735Snate@binkert.org    {
5146104Ssteve.reinhardt@amd.com        assert(privateFlags.isSet(VALID_PC));
5156427Ssteve.reinhardt@amd.com        return _pc;
5165735Snate@binkert.org    }
5172532SN/A
5186428Ssteve.reinhardt@amd.com    /** Accessor functions for flags.  Note that these are for testing
5196428Ssteve.reinhardt@amd.com       only; setting flags should be done via setFlags(). */
5206427Ssteve.reinhardt@amd.com    bool isUncacheable() const { return _flags.isSet(UNCACHEABLE); }
5216427Ssteve.reinhardt@amd.com    bool isInstFetch() const { return _flags.isSet(INST_FETCH); }
5226427Ssteve.reinhardt@amd.com    bool isPrefetch() const { return _flags.isSet(PREFETCH); }
5236427Ssteve.reinhardt@amd.com    bool isLLSC() const { return _flags.isSet(LLSC); }
5246427Ssteve.reinhardt@amd.com    bool isLocked() const { return _flags.isSet(LOCKED); }
5256427Ssteve.reinhardt@amd.com    bool isSwap() const { return _flags.isSet(MEM_SWAP|MEM_SWAP_COND); }
5266427Ssteve.reinhardt@amd.com    bool isCondSwap() const { return _flags.isSet(MEM_SWAP_COND); }
5278105Sgblack@eecs.umich.edu    bool isMmappedIpr() const { return _flags.isSet(MMAPPED_IPR); }
5287705Sgblack@eecs.umich.edu    bool isClearLL() const { return _flags.isSet(CLEAR_LL); }
5292384SN/A};
5302381SN/A
5312381SN/A#endif // __MEM_REQUEST_HH__
532