request.hh revision 5875:d82be3235ab4
1955SN/A/*
2955SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
31762SN/A * All rights reserved.
4955SN/A *
5955SN/A * Redistribution and use in source and binary forms, with or without
6955SN/A * modification, are permitted provided that the following conditions are
7955SN/A * met: redistributions of source code must retain the above copyright
8955SN/A * notice, this list of conditions and the following disclaimer;
9955SN/A * redistributions in binary form must reproduce the above copyright
10955SN/A * notice, this list of conditions and the following disclaimer in the
11955SN/A * documentation and/or other materials provided with the distribution;
12955SN/A * neither the name of the copyright holders nor the names of its
13955SN/A * contributors may be used to endorse or promote products derived from
14955SN/A * this software without specific prior written permission.
15955SN/A *
16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27955SN/A *
282665Ssaidi@eecs.umich.edu * Authors: Ron Dreslinski
294762Snate@binkert.org *          Steve Reinhardt
30955SN/A *          Ali Saidi
315522Snate@binkert.org */
326143Snate@binkert.org
3312371Sgabeblack@google.com/**
344762Snate@binkert.org * @file
355522Snate@binkert.org * Declaration of a request, the overall memory request consisting of
36955SN/A the parts of the request that are persistent throughout the transaction.
375522Snate@binkert.org */
3811974Sgabeblack@google.com
39955SN/A#ifndef __MEM_REQUEST_HH__
405522Snate@binkert.org#define __MEM_REQUEST_HH__
414202Sbinkertn@umich.edu
425742Snate@binkert.org#include <cassert>
43955SN/A
444381Sbinkertn@umich.edu#include "base/fast_alloc.hh"
454381Sbinkertn@umich.edu#include "base/flags.hh"
4612246Sgabeblack@google.com#include "base/misc.hh"
4712246Sgabeblack@google.com#include "sim/host.hh"
488334Snate@binkert.org#include "sim/core.hh"
49955SN/A
50955SN/Aclass Request;
514202Sbinkertn@umich.edu
52955SN/Atypedef Request* RequestPtr;
534382Sbinkertn@umich.edu
544382Sbinkertn@umich.educlass Request : public FastAlloc
554382Sbinkertn@umich.edu{
566654Snate@binkert.org    friend class Packet;
575517Snate@binkert.org
588614Sgblack@eecs.umich.edu  public:
597674Snate@binkert.org    typedef uint32_t FlagsType;
606143Snate@binkert.org    typedef ::Flags<FlagsType> Flags;
616143Snate@binkert.org
626143Snate@binkert.org    /** ASI information for this request if it exists. */
6312302Sgabeblack@google.com    static const FlagsType ASI_BITS                    = 0x000000FF;
6412302Sgabeblack@google.com    /** The request is a Load locked/store conditional. */
6512302Sgabeblack@google.com    static const FlagsType LOCKED                      = 0x00000100;
6612371Sgabeblack@google.com    /** The virtual address is also the physical address. */
6712371Sgabeblack@google.com    static const FlagsType PHYSICAL                    = 0x00000200;
6812371Sgabeblack@google.com    /** The request is an ALPHA VPTE pal access (hw_ld). */
6912371Sgabeblack@google.com    static const FlagsType VPTE                        = 0x00000400;
7012371Sgabeblack@google.com    /** Use the alternate mode bits in ALPHA. */
7112371Sgabeblack@google.com    static const FlagsType ALTMODE                     = 0x00000800;
7212371Sgabeblack@google.com    /** The request is to an uncacheable address. */
7312371Sgabeblack@google.com    static const FlagsType UNCACHEABLE                 = 0x00001000;
7412371Sgabeblack@google.com    /** The request should not cause a page fault. */
7512371Sgabeblack@google.com    static const FlagsType NO_FAULT                    = 0x00002000;
7612371Sgabeblack@google.com    /** The request should be prefetched into the exclusive state. */
7712371Sgabeblack@google.com    static const FlagsType PF_EXCLUSIVE                = 0x00010000;
7812371Sgabeblack@google.com    /** The request should be marked as LRU. */
7912371Sgabeblack@google.com    static const FlagsType EVICT_NEXT                  = 0x00020000;
8012371Sgabeblack@google.com    /** The request should ignore unaligned access faults */
8112371Sgabeblack@google.com    static const FlagsType NO_ALIGN_FAULT              = 0x00040000;
8212371Sgabeblack@google.com    /** The request was an instruction read. */
8312371Sgabeblack@google.com    static const FlagsType INST_READ                   = 0x00080000;
8412371Sgabeblack@google.com    /** This request is for a memory swap. */
8512371Sgabeblack@google.com    static const FlagsType MEM_SWAP                    = 0x00100000;
8612371Sgabeblack@google.com    static const FlagsType MEM_SWAP_COND               = 0x00200000;
8712371Sgabeblack@google.com    /** The request should ignore unaligned access faults */
8812371Sgabeblack@google.com    static const FlagsType NO_HALF_WORD_ALIGN_FAULT    = 0x00400000;
8912371Sgabeblack@google.com    /** This request is to a memory mapped register. */
9012371Sgabeblack@google.com    static const FlagsType MMAPED_IPR                  = 0x00800000;
9112371Sgabeblack@google.com
9212371Sgabeblack@google.com  private:
9312371Sgabeblack@google.com    static const FlagsType PUBLIC_FLAGS                = 0x00FF3FFF;
9412371Sgabeblack@google.com    static const FlagsType PRIVATE_FLAGS               = 0xFF000000;
9512371Sgabeblack@google.com
9612371Sgabeblack@google.com    /** Whether or not the size is valid. */
9712371Sgabeblack@google.com    static const FlagsType VALID_SIZE                  = 0x01000000;
9812371Sgabeblack@google.com    /** Whether or not paddr is valid (has been written yet). */
9912371Sgabeblack@google.com    static const FlagsType VALID_PADDR                 = 0x02000000;
10012371Sgabeblack@google.com    /** Whether or not the vaddr & asid are valid. */
10112371Sgabeblack@google.com    static const FlagsType VALID_VADDR                 = 0x04000000;
10212371Sgabeblack@google.com    /** Whether or not the pc is valid. */
10312371Sgabeblack@google.com    static const FlagsType VALID_PC                    = 0x10000000;
10412371Sgabeblack@google.com    /** Whether or not the context ID is valid. */
10512371Sgabeblack@google.com    static const FlagsType VALID_CONTEXT_ID            = 0x20000000;
10612371Sgabeblack@google.com    static const FlagsType VALID_THREAD_ID             = 0x40000000;
10712371Sgabeblack@google.com    /** Whether or not the sc result is valid. */
10812371Sgabeblack@google.com    static const FlagsType VALID_EXTRA_DATA            = 0x80000000;
10912371Sgabeblack@google.com
11012371Sgabeblack@google.com  private:
11112371Sgabeblack@google.com    /**
11212371Sgabeblack@google.com     * The physical address of the request. Valid only if validPaddr
11312302Sgabeblack@google.com     * is set.
11412371Sgabeblack@google.com     */
11512302Sgabeblack@google.com    Addr paddr;
11612371Sgabeblack@google.com
11712302Sgabeblack@google.com    /**
11812302Sgabeblack@google.com     * The size of the request. This field must be set when vaddr or
11912371Sgabeblack@google.com     * paddr is written via setVirt() or setPhys(), so it is always
12012371Sgabeblack@google.com     * valid as long as one of the address fields is valid.
12112371Sgabeblack@google.com     */
12212371Sgabeblack@google.com    int size;
12312302Sgabeblack@google.com
12412371Sgabeblack@google.com    /** Flag structure for the request. */
12512371Sgabeblack@google.com    Flags flags;
12612371Sgabeblack@google.com
12712371Sgabeblack@google.com    /**
12811983Sgabeblack@google.com     * The time this request was started. Used to calculate
1296143Snate@binkert.org     * latencies. This field is set to curTick any time paddr or vaddr
1308233Snate@binkert.org     * is written.
13112302Sgabeblack@google.com     */
1326143Snate@binkert.org    Tick time;
1336143Snate@binkert.org
13412302Sgabeblack@google.com    /** The address space ID. */
1354762Snate@binkert.org    int asid;
1366143Snate@binkert.org
1378233Snate@binkert.org    /** The virtual address of the request. */
1388233Snate@binkert.org    Addr vaddr;
13912302Sgabeblack@google.com
14012302Sgabeblack@google.com    /**
1416143Snate@binkert.org     * Extra data for the request, such as the return value of
14212362Sgabeblack@google.com     * store conditional or the compare value for a CAS. */
14312362Sgabeblack@google.com    uint64_t extraData;
14412362Sgabeblack@google.com
14512362Sgabeblack@google.com    /** The context ID (for statistics, typically). */
14612302Sgabeblack@google.com    int _contextId;
14712302Sgabeblack@google.com    /** The thread ID (id within this CPU) */
14812302Sgabeblack@google.com    int _threadId;
14912302Sgabeblack@google.com
15012302Sgabeblack@google.com    /** program counter of initiating access; for tracing/debugging */
15112363Sgabeblack@google.com    Addr pc;
15212363Sgabeblack@google.com
15312363Sgabeblack@google.com  public:
15412363Sgabeblack@google.com    /** Minimal constructor.  No fields are initialized. */
15512302Sgabeblack@google.com    Request()
15612363Sgabeblack@google.com    {}
15712363Sgabeblack@google.com
15812363Sgabeblack@google.com    /**
15912363Sgabeblack@google.com     * Constructor for physical (e.g. device) requests.  Initializes
16012363Sgabeblack@google.com     * just physical address, size, flags, and timestamp (to curTick).
1618233Snate@binkert.org     * These fields are adequate to perform a request.
1626143Snate@binkert.org     */
1636143Snate@binkert.org    Request(Addr paddr, int size, Flags flags)
1646143Snate@binkert.org    {
1656143Snate@binkert.org        setPhys(paddr, size, flags);
1666143Snate@binkert.org    }
1676143Snate@binkert.org
1686143Snate@binkert.org    Request(int asid, Addr vaddr, int size, Flags flags, Addr pc,
1696143Snate@binkert.org            int cid, int tid)
1706143Snate@binkert.org    {
1717065Snate@binkert.org        setThreadContext(cid, tid);
1726143Snate@binkert.org        setVirt(asid, vaddr, size, flags, pc);
17312362Sgabeblack@google.com    }
17412362Sgabeblack@google.com
17512362Sgabeblack@google.com    ~Request() {}  // for FastAlloc
17612362Sgabeblack@google.com
17712362Sgabeblack@google.com    /**
17812362Sgabeblack@google.com     * Set up CPU and thread numbers.
17912362Sgabeblack@google.com     */
18012362Sgabeblack@google.com    void
18112362Sgabeblack@google.com    setThreadContext(int context_id, int thread_id)
18212362Sgabeblack@google.com    {
18312362Sgabeblack@google.com        _contextId = context_id;
18412362Sgabeblack@google.com        _threadId = thread_id;
1858233Snate@binkert.org        flags.set(VALID_CONTEXT_ID|VALID_THREAD_ID);
1868233Snate@binkert.org    }
1878233Snate@binkert.org
1888233Snate@binkert.org    /**
1898233Snate@binkert.org     * Set up a physical (e.g. device) request in a previously
1908233Snate@binkert.org     * allocated Request object.
1918233Snate@binkert.org     */
1928233Snate@binkert.org    void
1938233Snate@binkert.org    setPhys(Addr _paddr, int _size, Flags _flags)
1948233Snate@binkert.org    {
1958233Snate@binkert.org        assert(_size >= 0);
1968233Snate@binkert.org        paddr = _paddr;
1978233Snate@binkert.org        size = _size;
1988233Snate@binkert.org        time = curTick;
1998233Snate@binkert.org
2008233Snate@binkert.org        flags.set(VALID_PADDR|VALID_SIZE);
2018233Snate@binkert.org        flags.clear(VALID_VADDR|VALID_PC|VALID_EXTRA_DATA|MMAPED_IPR);
2028233Snate@binkert.org        flags.update(_flags, PUBLIC_FLAGS);
2038233Snate@binkert.org    }
2048233Snate@binkert.org
2058233Snate@binkert.org    /**
2066143Snate@binkert.org     * Set up a virtual (e.g., CPU) request in a previously
2076143Snate@binkert.org     * allocated Request object.
2086143Snate@binkert.org     */
2096143Snate@binkert.org    void
2106143Snate@binkert.org    setVirt(int _asid, Addr _vaddr, int _size, Flags _flags, Addr _pc)
2116143Snate@binkert.org    {
2129982Satgutier@umich.edu        assert(_size >= 0);
2136143Snate@binkert.org        asid = _asid;
21412302Sgabeblack@google.com        vaddr = _vaddr;
21512302Sgabeblack@google.com        size = _size;
21612302Sgabeblack@google.com        pc = _pc;
21712302Sgabeblack@google.com        time = curTick;
21812302Sgabeblack@google.com
21912302Sgabeblack@google.com        flags.set(VALID_VADDR|VALID_SIZE|VALID_PC);
22012302Sgabeblack@google.com        flags.clear(VALID_PADDR|VALID_EXTRA_DATA|MMAPED_IPR);
22112302Sgabeblack@google.com        flags.update(_flags, PUBLIC_FLAGS);
22211983Sgabeblack@google.com    }
22311983Sgabeblack@google.com
22411983Sgabeblack@google.com    /**
22512302Sgabeblack@google.com     * Set just the physical address.  This should only be used to
22612302Sgabeblack@google.com     * record the result of a translation, and thus the vaddr must be
22712302Sgabeblack@google.com     * valid before this method is called.  Otherwise, use setPhys()
22812302Sgabeblack@google.com     * to guarantee that the size and flags are also set.
22912302Sgabeblack@google.com     */
23012302Sgabeblack@google.com    void
23111983Sgabeblack@google.com    setPaddr(Addr _paddr)
2326143Snate@binkert.org    {
23312305Sgabeblack@google.com        assert(flags.isSet(VALID_VADDR));
23412302Sgabeblack@google.com        paddr = _paddr;
23512302Sgabeblack@google.com        flags.set(VALID_PADDR);
23612302Sgabeblack@google.com    }
2376143Snate@binkert.org
2386143Snate@binkert.org    /**
2396143Snate@binkert.org     * Generate two requests as if this request had been split into two
2405522Snate@binkert.org     * pieces. The original request can't have been translated already.
2416143Snate@binkert.org     */
2426143Snate@binkert.org    void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2)
2436143Snate@binkert.org    {
2449982Satgutier@umich.edu        assert(flags.isSet(VALID_VADDR));
24512302Sgabeblack@google.com        assert(flags.noneSet(VALID_PADDR));
24612302Sgabeblack@google.com        assert(split_addr > vaddr && split_addr < vaddr + size);
24712302Sgabeblack@google.com        req1 = new Request;
2486143Snate@binkert.org        *req1 = *this;
2496143Snate@binkert.org        req2 = new Request;
2506143Snate@binkert.org        *req2 = *this;
2516143Snate@binkert.org        req1->size = split_addr - vaddr;
2525522Snate@binkert.org        req2->vaddr = split_addr;
2535522Snate@binkert.org        req2->size = size - req1->size;
2545522Snate@binkert.org    }
2555522Snate@binkert.org
2565604Snate@binkert.org    /**
2575604Snate@binkert.org     * Accessor for paddr.
2586143Snate@binkert.org     */
2596143Snate@binkert.org    Addr
2604762Snate@binkert.org    getPaddr()
2614762Snate@binkert.org    {
2626143Snate@binkert.org        assert(flags.isSet(VALID_PADDR));
2636727Ssteve.reinhardt@amd.com        return paddr;
2646727Ssteve.reinhardt@amd.com    }
2656727Ssteve.reinhardt@amd.com
2664762Snate@binkert.org    /**
2676143Snate@binkert.org     *  Accessor for size.
2686143Snate@binkert.org     */
2696143Snate@binkert.org    int
2706143Snate@binkert.org    getSize()
2716727Ssteve.reinhardt@amd.com    {
2726143Snate@binkert.org        assert(flags.isSet(VALID_SIZE));
2737674Snate@binkert.org        return size;
2747674Snate@binkert.org    }
2755604Snate@binkert.org
2766143Snate@binkert.org    /** Accessor for time. */
2776143Snate@binkert.org    Tick
2786143Snate@binkert.org    getTime()
2794762Snate@binkert.org    {
2806143Snate@binkert.org        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
2814762Snate@binkert.org        return time;
2824762Snate@binkert.org    }
2834762Snate@binkert.org
2846143Snate@binkert.org    void
2856143Snate@binkert.org    setTime(Tick when)
2864762Snate@binkert.org    {
28712302Sgabeblack@google.com        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
28812302Sgabeblack@google.com        time = when;
2898233Snate@binkert.org    }
29012302Sgabeblack@google.com
2916143Snate@binkert.org    /** Accessor for flags. */
2926143Snate@binkert.org    Flags
2934762Snate@binkert.org    getFlags()
2946143Snate@binkert.org    {
2954762Snate@binkert.org        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
2969396Sandreas.hansson@arm.com        return flags & PUBLIC_FLAGS;
2979396Sandreas.hansson@arm.com    }
2989396Sandreas.hansson@arm.com
29912302Sgabeblack@google.com    Flags
30012302Sgabeblack@google.com    anyFlags(Flags _flags)
30112302Sgabeblack@google.com    {
3029396Sandreas.hansson@arm.com        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
3039396Sandreas.hansson@arm.com        assert(_flags.noneSet(~PUBLIC_FLAGS));
3049396Sandreas.hansson@arm.com        return flags.isSet(_flags);
3059396Sandreas.hansson@arm.com    }
3069396Sandreas.hansson@arm.com
3079396Sandreas.hansson@arm.com    Flags
3089396Sandreas.hansson@arm.com    allFlags(Flags _flags)
3099930Sandreas.hansson@arm.com    {
3109930Sandreas.hansson@arm.com        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
3119396Sandreas.hansson@arm.com        assert(_flags.noneSet(~PUBLIC_FLAGS));
3128235Snate@binkert.org        return flags.allSet(_flags);
3138235Snate@binkert.org    }
3146143Snate@binkert.org
3158235Snate@binkert.org    /** Accessor for flags. */
3169003SAli.Saidi@ARM.com    void
3178235Snate@binkert.org    setFlags(Flags _flags)
3188235Snate@binkert.org    {
31912302Sgabeblack@google.com        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
3208235Snate@binkert.org        assert(_flags.noneSet(~PUBLIC_FLAGS));
32112302Sgabeblack@google.com        flags.set(_flags);
3228235Snate@binkert.org    }
3238235Snate@binkert.org
32412302Sgabeblack@google.com    void
3258235Snate@binkert.org    clearFlags(Flags _flags)
3268235Snate@binkert.org    {
3278235Snate@binkert.org        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
3288235Snate@binkert.org        assert(_flags.noneSet(~PUBLIC_FLAGS));
3299003SAli.Saidi@ARM.com        flags.clear(_flags);
33012313Sgabeblack@google.com    }
33112313Sgabeblack@google.com
33212313Sgabeblack@google.com    void
33312313Sgabeblack@google.com    clearFlags()
33412313Sgabeblack@google.com    {
33512315Sgabeblack@google.com        assert(flags.isSet(VALID_PADDR|VALID_VADDR));
33612371Sgabeblack@google.com        flags.clear(PUBLIC_FLAGS);
33712371Sgabeblack@google.com    }
33812371Sgabeblack@google.com
33912315Sgabeblack@google.com    /** Accessor function for vaddr.*/
34012315Sgabeblack@google.com    Addr
34112371Sgabeblack@google.com    getVaddr()
3425584Snate@binkert.org    {
3434382Sbinkertn@umich.edu        assert(flags.isSet(VALID_VADDR));
3444202Sbinkertn@umich.edu        return vaddr;
3454382Sbinkertn@umich.edu    }
3464382Sbinkertn@umich.edu
3479396Sandreas.hansson@arm.com    /** Accessor function for asid.*/
3485584Snate@binkert.org    int
34912313Sgabeblack@google.com    getAsid()
3504382Sbinkertn@umich.edu    {
3514382Sbinkertn@umich.edu        assert(flags.isSet(VALID_VADDR));
3524382Sbinkertn@umich.edu        return asid;
3538232Snate@binkert.org    }
3545192Ssaidi@eecs.umich.edu
3558232Snate@binkert.org    /** Accessor function for asi.*/
3568232Snate@binkert.org    uint8_t
3578232Snate@binkert.org    getAsi()
3585192Ssaidi@eecs.umich.edu    {
3598232Snate@binkert.org        assert(flags.isSet(VALID_VADDR));
3605192Ssaidi@eecs.umich.edu        return flags & ASI_BITS;
3615799Snate@binkert.org    }
3628232Snate@binkert.org
3635192Ssaidi@eecs.umich.edu    /** Accessor function for asi.*/
3645192Ssaidi@eecs.umich.edu    void
3655192Ssaidi@eecs.umich.edu    setAsi(uint8_t a)
3668232Snate@binkert.org    {
3675192Ssaidi@eecs.umich.edu        assert(flags.isSet(VALID_VADDR));
3688232Snate@binkert.org        flags.update(a, ASI_BITS);
3695192Ssaidi@eecs.umich.edu    }
3705192Ssaidi@eecs.umich.edu
3715192Ssaidi@eecs.umich.edu    /** Accessor function for asi.*/
3725192Ssaidi@eecs.umich.edu    bool
3734382Sbinkertn@umich.edu    isMmapedIpr()
3744382Sbinkertn@umich.edu    {
3754382Sbinkertn@umich.edu        assert(flags.isSet(VALID_PADDR));
3762667Sstever@eecs.umich.edu        return flags.isSet(MMAPED_IPR);
3772667Sstever@eecs.umich.edu    }
3782667Sstever@eecs.umich.edu
3792667Sstever@eecs.umich.edu    /** Accessor function for asi.*/
3802667Sstever@eecs.umich.edu    void
3812667Sstever@eecs.umich.edu    setMmapedIpr(bool r)
3825742Snate@binkert.org    {
3835742Snate@binkert.org        assert(VALID_VADDR);
3845742Snate@binkert.org        flags.set(MMAPED_IPR);
3855793Snate@binkert.org    }
3868334Snate@binkert.org
3875793Snate@binkert.org    /** Accessor function to check if sc result is valid. */
3885793Snate@binkert.org    bool
3895793Snate@binkert.org    extraDataValid()
3904382Sbinkertn@umich.edu    {
3914762Snate@binkert.org        return flags.isSet(VALID_EXTRA_DATA);
3925344Sstever@gmail.com    }
3934382Sbinkertn@umich.edu
3945341Sstever@gmail.com    /** Accessor function for store conditional return value.*/
3955742Snate@binkert.org    uint64_t
3965742Snate@binkert.org    getExtraData() const
3975742Snate@binkert.org    {
3985742Snate@binkert.org        assert(flags.isSet(VALID_EXTRA_DATA));
3995742Snate@binkert.org        return extraData;
4004762Snate@binkert.org    }
4015742Snate@binkert.org
4025742Snate@binkert.org    /** Accessor function for store conditional return value.*/
40311984Sgabeblack@google.com    void
4047722Sgblack@eecs.umich.edu    setExtraData(uint64_t _extraData)
4055742Snate@binkert.org    {
4065742Snate@binkert.org        extraData = _extraData;
4075742Snate@binkert.org        flags.set(VALID_EXTRA_DATA);
4089930Sandreas.hansson@arm.com    }
4099930Sandreas.hansson@arm.com
4109930Sandreas.hansson@arm.com    /** Accessor function for context ID.*/
4119930Sandreas.hansson@arm.com    int
4129930Sandreas.hansson@arm.com    contextId() const
4135742Snate@binkert.org    {
4148242Sbradley.danofsky@amd.com        assert(flags.isSet(VALID_CONTEXT_ID));
4158242Sbradley.danofsky@amd.com        return _contextId;
4168242Sbradley.danofsky@amd.com    }
4178242Sbradley.danofsky@amd.com
4185341Sstever@gmail.com    /** Accessor function for thread ID. */
4195742Snate@binkert.org    int
4207722Sgblack@eecs.umich.edu    threadId() const
4214773Snate@binkert.org    {
4226108Snate@binkert.org        assert(flags.isSet(VALID_THREAD_ID));
4231858SN/A        return _threadId;
4241085SN/A    }
4256658Snate@binkert.org
4266658Snate@binkert.org    /** Accessor function for pc.*/
4277673Snate@binkert.org    bool
4286658Snate@binkert.org    hasPC() const
4296658Snate@binkert.org    {
43011308Santhony.gutierrez@amd.com        return flags.isSet(VALID_PC);
4316658Snate@binkert.org    }
43211308Santhony.gutierrez@amd.com
4336658Snate@binkert.org    Addr
4346658Snate@binkert.org    getPC() const
4357673Snate@binkert.org    {
4367673Snate@binkert.org        assert(flags.isSet(VALID_PC));
4377673Snate@binkert.org        return pc;
4387673Snate@binkert.org    }
4397673Snate@binkert.org
4407673Snate@binkert.org    /** Accessor Function to Check Cacheability. */
4417673Snate@binkert.org    bool isUncacheable() const { return flags.isSet(UNCACHEABLE); }
44210467Sandreas.hansson@arm.com    bool isInstRead() const { return flags.isSet(INST_READ); }
4436658Snate@binkert.org    bool isLocked() const { return flags.isSet(LOCKED); }
4447673Snate@binkert.org    bool isSwap() const { return flags.isSet(MEM_SWAP|MEM_SWAP_COND); }
44510467Sandreas.hansson@arm.com    bool isCondSwap() const { return flags.isSet(MEM_SWAP_COND); }
44610467Sandreas.hansson@arm.com
44710467Sandreas.hansson@arm.com    bool
44810467Sandreas.hansson@arm.com    isMisaligned() const
44910467Sandreas.hansson@arm.com    {
45010467Sandreas.hansson@arm.com        if (flags.isSet(NO_ALIGN_FAULT))
45110467Sandreas.hansson@arm.com            return false;
45210467Sandreas.hansson@arm.com
45310467Sandreas.hansson@arm.com        if ((vaddr & 0x1))
45410467Sandreas.hansson@arm.com            return true;
45510467Sandreas.hansson@arm.com
4567673Snate@binkert.org        if (flags.isSet(NO_HALF_WORD_ALIGN_FAULT))
4577673Snate@binkert.org            return false;
4587673Snate@binkert.org
4597673Snate@binkert.org        if ((vaddr & 0x2))
4607673Snate@binkert.org            return true;
4619048SAli.Saidi@ARM.com
4627673Snate@binkert.org        return false;
4637673Snate@binkert.org    }
4647673Snate@binkert.org};
4657673Snate@binkert.org
4666658Snate@binkert.org#endif // __MEM_REQUEST_HH__
4677756SAli.Saidi@ARM.com