request.hh revision 10760
12381SN/A/* 210020Smatt.horsnell@ARM.com * Copyright (c) 2012-2013 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; 899912Sandreas@sandberg.pp.se typedef uint8_t ArchFlagsType; 905735Snate@binkert.org typedef ::Flags<FlagsType> Flags; 915735Snate@binkert.org 929912Sandreas@sandberg.pp.se /** 939912Sandreas@sandberg.pp.se * Architecture specific flags. 949912Sandreas@sandberg.pp.se * 959912Sandreas@sandberg.pp.se * These bits int the flag field are reserved for 969912Sandreas@sandberg.pp.se * architecture-specific code. For example, SPARC uses them to 979912Sandreas@sandberg.pp.se * represent ASIs. 989912Sandreas@sandberg.pp.se */ 999912Sandreas@sandberg.pp.se static const FlagsType ARCH_BITS = 0x000000FF; 1006133Ssteve.reinhardt@amd.com /** The request was an instruction fetch. */ 1016133Ssteve.reinhardt@amd.com static const FlagsType INST_FETCH = 0x00000100; 1025735Snate@binkert.org /** The virtual address is also the physical address. */ 1035735Snate@binkert.org static const FlagsType PHYSICAL = 0x00000200; 1045735Snate@binkert.org /** The request is an ALPHA VPTE pal access (hw_ld). */ 1055735Snate@binkert.org static const FlagsType VPTE = 0x00000400; 1065735Snate@binkert.org /** Use the alternate mode bits in ALPHA. */ 1075735Snate@binkert.org static const FlagsType ALTMODE = 0x00000800; 1085735Snate@binkert.org /** The request is to an uncacheable address. */ 1095735Snate@binkert.org static const FlagsType UNCACHEABLE = 0x00001000; 1106133Ssteve.reinhardt@amd.com /** This request is to a memory mapped register. */ 11110755Sandreas.hansson@arm.com static const FlagsType MMAPPED_IPR = 0x00002000; 1127612SGene.Wu@arm.com /** This request is a clear exclusive. */ 1137705Sgblack@eecs.umich.edu static const FlagsType CLEAR_LL = 0x00004000; 1149950Sprakash.ramrakhyani@arm.com /** This request is made in privileged mode. */ 11510755Sandreas.hansson@arm.com static const FlagsType PRIVILEGED = 0x00008000; 1166133Ssteve.reinhardt@amd.com 11710031SAli.Saidi@ARM.com /** This is a write that is targeted and zeroing an entire cache block. 11810031SAli.Saidi@ARM.com * There is no need for a read/modify/write 11910031SAli.Saidi@ARM.com */ 12010031SAli.Saidi@ARM.com static const FlagsType CACHE_BLOCK_ZERO = 0x00010000; 12110031SAli.Saidi@ARM.com 1225890Sgblack@eecs.umich.edu /** The request should not cause a memory access. */ 1236133Ssteve.reinhardt@amd.com static const FlagsType NO_ACCESS = 0x00080000; 1246103Sgblack@eecs.umich.edu /** This request will lock or unlock the accessed memory. When used with 1256103Sgblack@eecs.umich.edu * a load, the access locks the particular chunk of memory. When used 1266103Sgblack@eecs.umich.edu * with a store, it unlocks. The rule is that locked accesses have to be 1276103Sgblack@eecs.umich.edu * made up of a locked load, some operation on the data, and then a locked 1286103Sgblack@eecs.umich.edu * store. 1296103Sgblack@eecs.umich.edu */ 13010760Ssteve.reinhardt@amd.com static const FlagsType LOCKED_RMW = 0x00100000; 1316133Ssteve.reinhardt@amd.com /** The request is a Load locked/store conditional. */ 1326133Ssteve.reinhardt@amd.com static const FlagsType LLSC = 0x00200000; 1335735Snate@binkert.org /** This request is for a memory swap. */ 1346133Ssteve.reinhardt@amd.com static const FlagsType MEM_SWAP = 0x00400000; 1356133Ssteve.reinhardt@amd.com static const FlagsType MEM_SWAP_COND = 0x00800000; 1366133Ssteve.reinhardt@amd.com 1376106Ssteve.reinhardt@amd.com /** The request is a prefetch. */ 1386106Ssteve.reinhardt@amd.com static const FlagsType PREFETCH = 0x01000000; 1396133Ssteve.reinhardt@amd.com /** The request should be prefetched into the exclusive state. */ 1406133Ssteve.reinhardt@amd.com static const FlagsType PF_EXCLUSIVE = 0x02000000; 1416133Ssteve.reinhardt@amd.com /** The request should be marked as LRU. */ 1426133Ssteve.reinhardt@amd.com static const FlagsType EVICT_NEXT = 0x04000000; 1435735Snate@binkert.org 1449911Sandreas@sandberg.pp.se /** The request should be handled by the generic IPR code (only 1459911Sandreas@sandberg.pp.se * valid together with MMAPPED_IPR) */ 1469911Sandreas@sandberg.pp.se static const FlagsType GENERIC_IPR = 0x08000000; 1479911Sandreas@sandberg.pp.se 14810028SGiacomo.Gabrielli@arm.com /** The request targets the secure memory space. */ 14910028SGiacomo.Gabrielli@arm.com static const FlagsType SECURE = 0x10000000; 15010029SGiacomo.Gabrielli@arm.com /** The request is a page table walk */ 15110029SGiacomo.Gabrielli@arm.com static const FlagsType PT_WALK = 0x20000000; 15210028SGiacomo.Gabrielli@arm.com 1536104Ssteve.reinhardt@amd.com /** These flags are *not* cleared when a Request object is reused 1546104Ssteve.reinhardt@amd.com (assigned a new address). */ 1556105Ssteve.reinhardt@amd.com static const FlagsType STICKY_FLAGS = INST_FETCH; 1566104Ssteve.reinhardt@amd.com 1578832SAli.Saidi@ARM.com /** Request Ids that are statically allocated 1588832SAli.Saidi@ARM.com * @{*/ 1598832SAli.Saidi@ARM.com /** This request id is used for writeback requests by the caches */ 1608832SAli.Saidi@ARM.com static const MasterID wbMasterId = 0; 1618832SAli.Saidi@ARM.com /** This request id is used for functional requests that don't come from a 1628832SAli.Saidi@ARM.com * particular device 1638832SAli.Saidi@ARM.com */ 1648832SAli.Saidi@ARM.com static const MasterID funcMasterId = 1; 1658832SAli.Saidi@ARM.com /** This request id is used for message signaled interrupts */ 1668832SAli.Saidi@ARM.com static const MasterID intMasterId = 2; 1678833Sdam.sunwoo@arm.com /** Invalid request id for assertion checking only. It is invalid behavior 1688833Sdam.sunwoo@arm.com * to ever send this id as part of a request. 1698833Sdam.sunwoo@arm.com * @todo C++1x replace with numeric_limits when constexpr is added */ 17010755Sandreas.hansson@arm.com static const MasterID invldMasterId = std::numeric_limits<MasterID>::max(); 1718832SAli.Saidi@ARM.com /** @} */ 1728832SAli.Saidi@ARM.com 1739332Sdam.sunwoo@arm.com /** Invalid or unknown Pid. Possible when operating system is not present 1749332Sdam.sunwoo@arm.com * or has not assigned a pid yet */ 17510755Sandreas.hansson@arm.com static const uint32_t invldPid = std::numeric_limits<uint32_t>::max(); 1769332Sdam.sunwoo@arm.com 1775735Snate@binkert.org private: 1786104Ssteve.reinhardt@amd.com typedef uint8_t PrivateFlagsType; 1796104Ssteve.reinhardt@amd.com typedef ::Flags<PrivateFlagsType> PrivateFlags; 1805735Snate@binkert.org 1815735Snate@binkert.org /** Whether or not the size is valid. */ 1826104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_SIZE = 0x00000001; 1835735Snate@binkert.org /** Whether or not paddr is valid (has been written yet). */ 1846104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_PADDR = 0x00000002; 1855735Snate@binkert.org /** Whether or not the vaddr & asid are valid. */ 1866104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_VADDR = 0x00000004; 1875735Snate@binkert.org /** Whether or not the pc is valid. */ 1886104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_PC = 0x00000010; 1895735Snate@binkert.org /** Whether or not the context ID is valid. */ 1906104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_CONTEXT_ID = 0x00000020; 1916104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_THREAD_ID = 0x00000040; 1925735Snate@binkert.org /** Whether or not the sc result is valid. */ 1936104Ssteve.reinhardt@amd.com static const PrivateFlagsType VALID_EXTRA_DATA = 0x00000080; 1946104Ssteve.reinhardt@amd.com 1956104Ssteve.reinhardt@amd.com /** These flags are *not* cleared when a Request object is reused 1966104Ssteve.reinhardt@amd.com (assigned a new address). */ 1976104Ssteve.reinhardt@amd.com static const PrivateFlagsType STICKY_PRIVATE_FLAGS = 1986104Ssteve.reinhardt@amd.com VALID_CONTEXT_ID | VALID_THREAD_ID; 1995735Snate@binkert.org 2002663Sstever@eecs.umich.edu private: 20110653Sandreas.hansson@arm.com 20210653Sandreas.hansson@arm.com /** 20310653Sandreas.hansson@arm.com * Set up a physical (e.g. device) request in a previously 20410653Sandreas.hansson@arm.com * allocated Request object. 20510653Sandreas.hansson@arm.com */ 20610653Sandreas.hansson@arm.com void 20710653Sandreas.hansson@arm.com setPhys(Addr paddr, unsigned size, Flags flags, MasterID mid, Tick time) 20810653Sandreas.hansson@arm.com { 20910653Sandreas.hansson@arm.com assert(size >= 0); 21010653Sandreas.hansson@arm.com _paddr = paddr; 21110653Sandreas.hansson@arm.com _size = size; 21210653Sandreas.hansson@arm.com _time = time; 21310653Sandreas.hansson@arm.com _masterId = mid; 21410653Sandreas.hansson@arm.com _flags.clear(~STICKY_FLAGS); 21510653Sandreas.hansson@arm.com _flags.set(flags); 21610653Sandreas.hansson@arm.com privateFlags.clear(~STICKY_PRIVATE_FLAGS); 21710653Sandreas.hansson@arm.com privateFlags.set(VALID_PADDR|VALID_SIZE); 21810653Sandreas.hansson@arm.com depth = 0; 21910653Sandreas.hansson@arm.com accessDelta = 0; 22010653Sandreas.hansson@arm.com //translateDelta = 0; 22110653Sandreas.hansson@arm.com } 22210653Sandreas.hansson@arm.com 2232663Sstever@eecs.umich.edu /** 2242663Sstever@eecs.umich.edu * The physical address of the request. Valid only if validPaddr 2255735Snate@binkert.org * is set. 2265735Snate@binkert.org */ 2276427Ssteve.reinhardt@amd.com Addr _paddr; 2282532SN/A 2292663Sstever@eecs.umich.edu /** 2302663Sstever@eecs.umich.edu * The size of the request. This field must be set when vaddr or 2312663Sstever@eecs.umich.edu * paddr is written via setVirt() or setPhys(), so it is always 2325735Snate@binkert.org * valid as long as one of the address fields is valid. 2335735Snate@binkert.org */ 23410653Sandreas.hansson@arm.com unsigned _size; 2352395SN/A 2368832SAli.Saidi@ARM.com /** The requestor ID which is unique in the system for all ports 2378832SAli.Saidi@ARM.com * that are capable of issuing a transaction 2388832SAli.Saidi@ARM.com */ 2398832SAli.Saidi@ARM.com MasterID _masterId; 2408832SAli.Saidi@ARM.com 2412532SN/A /** Flag structure for the request. */ 2426427Ssteve.reinhardt@amd.com Flags _flags; 2432384SN/A 2446104Ssteve.reinhardt@amd.com /** Private flags for field validity checking. */ 2456104Ssteve.reinhardt@amd.com PrivateFlags privateFlags; 2466104Ssteve.reinhardt@amd.com 2472663Sstever@eecs.umich.edu /** 2482663Sstever@eecs.umich.edu * The time this request was started. Used to calculate 2497823Ssteve.reinhardt@amd.com * latencies. This field is set to curTick() any time paddr or vaddr 2505735Snate@binkert.org * is written. 2515735Snate@binkert.org */ 2526223Snate@binkert.org Tick _time; 2532384SN/A 25410024Sdam.sunwoo@arm.com /** 25510024Sdam.sunwoo@arm.com * The task id associated with this request 25610024Sdam.sunwoo@arm.com */ 25710024Sdam.sunwoo@arm.com uint32_t _taskId; 25810024Sdam.sunwoo@arm.com 2592384SN/A /** The address space ID. */ 2606427Ssteve.reinhardt@amd.com int _asid; 2613806Ssaidi@eecs.umich.edu 2622663Sstever@eecs.umich.edu /** The virtual address of the request. */ 2636427Ssteve.reinhardt@amd.com Addr _vaddr; 2642384SN/A 2655735Snate@binkert.org /** 2665735Snate@binkert.org * Extra data for the request, such as the return value of 2674040Ssaidi@eecs.umich.edu * store conditional or the compare value for a CAS. */ 2686427Ssteve.reinhardt@amd.com uint64_t _extraData; 2692384SN/A 2705714Shsul@eecs.umich.edu /** The context ID (for statistics, typically). */ 2715714Shsul@eecs.umich.edu int _contextId; 2725714Shsul@eecs.umich.edu /** The thread ID (id within this CPU) */ 27310755Sandreas.hansson@arm.com ThreadID _threadId; 2742384SN/A 2752381SN/A /** program counter of initiating access; for tracing/debugging */ 2766427Ssteve.reinhardt@amd.com Addr _pc; 2772663Sstever@eecs.umich.edu 2782532SN/A public: 27910653Sandreas.hansson@arm.com 28010653Sandreas.hansson@arm.com /** 28110653Sandreas.hansson@arm.com * Minimal constructor. No fields are initialized. (Note that 28210653Sandreas.hansson@arm.com * _flags and privateFlags are cleared by Flags default 28310653Sandreas.hansson@arm.com * constructor.) 2846427Ssteve.reinhardt@amd.com */ 2852663Sstever@eecs.umich.edu Request() 28610360Sandreas.hansson@arm.com : _paddr(0), _size(0), _masterId(invldMasterId), _time(0), 28710360Sandreas.hansson@arm.com _taskId(ContextSwitchTaskId::Unknown), _asid(0), _vaddr(0), 28810360Sandreas.hansson@arm.com _extraData(0), _contextId(0), _threadId(0), _pc(0), 28910360Sandreas.hansson@arm.com translateDelta(0), accessDelta(0), depth(0) 2902663Sstever@eecs.umich.edu {} 2912532SN/A 2922663Sstever@eecs.umich.edu /** 2932663Sstever@eecs.umich.edu * Constructor for physical (e.g. device) requests. Initializes 2947823Ssteve.reinhardt@amd.com * just physical address, size, flags, and timestamp (to curTick()). 29510653Sandreas.hansson@arm.com * These fields are adequate to perform a request. 2965735Snate@binkert.org */ 29710653Sandreas.hansson@arm.com Request(Addr paddr, unsigned size, Flags flags, MasterID mid) 29810360Sandreas.hansson@arm.com : _paddr(0), _size(0), _masterId(invldMasterId), _time(0), 29910360Sandreas.hansson@arm.com _taskId(ContextSwitchTaskId::Unknown), _asid(0), _vaddr(0), 30010360Sandreas.hansson@arm.com _extraData(0), _contextId(0), _threadId(0), _pc(0), 30110360Sandreas.hansson@arm.com translateDelta(0), accessDelta(0), depth(0) 3025735Snate@binkert.org { 30310653Sandreas.hansson@arm.com setPhys(paddr, size, flags, mid, curTick()); 3045735Snate@binkert.org } 3052532SN/A 30610653Sandreas.hansson@arm.com Request(Addr paddr, unsigned size, Flags flags, MasterID mid, Tick time) 30710360Sandreas.hansson@arm.com : _paddr(0), _size(0), _masterId(invldMasterId), _time(0), 30810360Sandreas.hansson@arm.com _taskId(ContextSwitchTaskId::Unknown), _asid(0), _vaddr(0), 30910360Sandreas.hansson@arm.com _extraData(0), _contextId(0), _threadId(0), _pc(0), 31010360Sandreas.hansson@arm.com translateDelta(0), accessDelta(0), depth(0) 3116223Snate@binkert.org { 3128832SAli.Saidi@ARM.com setPhys(paddr, size, flags, mid, time); 3136223Snate@binkert.org } 3146223Snate@binkert.org 31510653Sandreas.hansson@arm.com Request(Addr paddr, unsigned size, Flags flags, MasterID mid, Tick time, 31610653Sandreas.hansson@arm.com Addr pc) 31710360Sandreas.hansson@arm.com : _paddr(0), _size(0), _masterId(invldMasterId), _time(0), 31810360Sandreas.hansson@arm.com _taskId(ContextSwitchTaskId::Unknown), _asid(0), _vaddr(0), 31910360Sandreas.hansson@arm.com _extraData(0), _contextId(0), _threadId(0), _pc(0), 32010360Sandreas.hansson@arm.com translateDelta(0), accessDelta(0), depth(0) 3216899SBrad.Beckmann@amd.com { 3228832SAli.Saidi@ARM.com setPhys(paddr, size, flags, mid, time); 3236899SBrad.Beckmann@amd.com privateFlags.set(VALID_PC); 3246899SBrad.Beckmann@amd.com _pc = pc; 3256899SBrad.Beckmann@amd.com } 3266899SBrad.Beckmann@amd.com 32710653Sandreas.hansson@arm.com Request(int asid, Addr vaddr, unsigned size, Flags flags, MasterID mid, 32810755Sandreas.hansson@arm.com Addr pc, int cid, ThreadID tid) 32910360Sandreas.hansson@arm.com : _paddr(0), _size(0), _masterId(invldMasterId), _time(0), 33010360Sandreas.hansson@arm.com _taskId(ContextSwitchTaskId::Unknown), _asid(0), _vaddr(0), 33110360Sandreas.hansson@arm.com _extraData(0), _contextId(0), _threadId(0), _pc(0), 33210360Sandreas.hansson@arm.com translateDelta(0), accessDelta(0), depth(0) 3332669Sktlim@umich.edu { 3348832SAli.Saidi@ARM.com setVirt(asid, vaddr, size, flags, mid, pc); 3355735Snate@binkert.org setThreadContext(cid, tid); 3362669Sktlim@umich.edu } 3372669Sktlim@umich.edu 3389044SAli.Saidi@ARM.com ~Request() {} 3394610Ssaidi@eecs.umich.edu 3402663Sstever@eecs.umich.edu /** 3415735Snate@binkert.org * Set up CPU and thread numbers. 3425735Snate@binkert.org */ 3435735Snate@binkert.org void 3446221Snate@binkert.org setThreadContext(int context_id, ThreadID tid) 3452663Sstever@eecs.umich.edu { 3465735Snate@binkert.org _contextId = context_id; 3476221Snate@binkert.org _threadId = tid; 3486104Ssteve.reinhardt@amd.com privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID); 3492663Sstever@eecs.umich.edu } 3502532SN/A 3512663Sstever@eecs.umich.edu /** 3522663Sstever@eecs.umich.edu * Set up a virtual (e.g., CPU) request in a previously 3535735Snate@binkert.org * allocated Request object. 3545735Snate@binkert.org */ 3555735Snate@binkert.org void 35610653Sandreas.hansson@arm.com setVirt(int asid, Addr vaddr, unsigned size, Flags flags, MasterID mid, 35710653Sandreas.hansson@arm.com Addr pc) 3582663Sstever@eecs.umich.edu { 3596427Ssteve.reinhardt@amd.com _asid = asid; 3606427Ssteve.reinhardt@amd.com _vaddr = vaddr; 3616427Ssteve.reinhardt@amd.com _size = size; 3628832SAli.Saidi@ARM.com _masterId = mid; 3636427Ssteve.reinhardt@amd.com _pc = pc; 3647823Ssteve.reinhardt@amd.com _time = curTick(); 3655735Snate@binkert.org 3666427Ssteve.reinhardt@amd.com _flags.clear(~STICKY_FLAGS); 3676427Ssteve.reinhardt@amd.com _flags.set(flags); 3686104Ssteve.reinhardt@amd.com privateFlags.clear(~STICKY_PRIVATE_FLAGS); 3696104Ssteve.reinhardt@amd.com privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC); 37010020Smatt.horsnell@ARM.com depth = 0; 37110020Smatt.horsnell@ARM.com accessDelta = 0; 37210020Smatt.horsnell@ARM.com translateDelta = 0; 3732663Sstever@eecs.umich.edu } 3742532SN/A 3755735Snate@binkert.org /** 3769760Sandreas@sandberg.pp.se * Set just the physical address. This usually used to record the 3779760Sandreas@sandberg.pp.se * result of a translation. However, when using virtualized CPUs 3789760Sandreas@sandberg.pp.se * setPhys() is sometimes called to finalize a physical address 3799760Sandreas@sandberg.pp.se * without a virtual address, so we can't check if the virtual 3809760Sandreas@sandberg.pp.se * address is valid. 3812663Sstever@eecs.umich.edu */ 3825735Snate@binkert.org void 3836427Ssteve.reinhardt@amd.com setPaddr(Addr paddr) 3842663Sstever@eecs.umich.edu { 3856427Ssteve.reinhardt@amd.com _paddr = paddr; 3866104Ssteve.reinhardt@amd.com privateFlags.set(VALID_PADDR); 3872663Sstever@eecs.umich.edu } 3882532SN/A 3895735Snate@binkert.org /** 3905744Sgblack@eecs.umich.edu * Generate two requests as if this request had been split into two 3915744Sgblack@eecs.umich.edu * pieces. The original request can't have been translated already. 3925744Sgblack@eecs.umich.edu */ 3935744Sgblack@eecs.umich.edu void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2) 3945744Sgblack@eecs.umich.edu { 3956104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_VADDR)); 3966104Ssteve.reinhardt@amd.com assert(privateFlags.noneSet(VALID_PADDR)); 3976427Ssteve.reinhardt@amd.com assert(split_addr > _vaddr && split_addr < _vaddr + _size); 39810653Sandreas.hansson@arm.com req1 = new Request(*this); 39910653Sandreas.hansson@arm.com req2 = new Request(*this); 4006427Ssteve.reinhardt@amd.com req1->_size = split_addr - _vaddr; 4016427Ssteve.reinhardt@amd.com req2->_vaddr = split_addr; 4026427Ssteve.reinhardt@amd.com req2->_size = _size - req1->_size; 4035744Sgblack@eecs.umich.edu } 4045744Sgblack@eecs.umich.edu 4055744Sgblack@eecs.umich.edu /** 4065735Snate@binkert.org * Accessor for paddr. 4075735Snate@binkert.org */ 4086104Ssteve.reinhardt@amd.com bool 40910568Sandreas.hansson@arm.com hasPaddr() const 4106104Ssteve.reinhardt@amd.com { 4116104Ssteve.reinhardt@amd.com return privateFlags.isSet(VALID_PADDR); 4126104Ssteve.reinhardt@amd.com } 4136104Ssteve.reinhardt@amd.com 4145735Snate@binkert.org Addr 41510568Sandreas.hansson@arm.com getPaddr() const 4165735Snate@binkert.org { 4176104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_PADDR)); 4186427Ssteve.reinhardt@amd.com return _paddr; 4195735Snate@binkert.org } 4202663Sstever@eecs.umich.edu 4215735Snate@binkert.org /** 42210020Smatt.horsnell@ARM.com * Time for the TLB/table walker to successfully translate this request. 42310020Smatt.horsnell@ARM.com */ 42410020Smatt.horsnell@ARM.com Tick translateDelta; 42510020Smatt.horsnell@ARM.com 42610020Smatt.horsnell@ARM.com /** 42710020Smatt.horsnell@ARM.com * Access latency to complete this memory transaction not including 42810020Smatt.horsnell@ARM.com * translation time. 42910020Smatt.horsnell@ARM.com */ 43010020Smatt.horsnell@ARM.com Tick accessDelta; 43110020Smatt.horsnell@ARM.com 43210020Smatt.horsnell@ARM.com /** 43310020Smatt.horsnell@ARM.com * Level of the cache hierachy where this request was responded to 43410020Smatt.horsnell@ARM.com * (e.g. 0 = L1; 1 = L2). 43510020Smatt.horsnell@ARM.com */ 43610568Sandreas.hansson@arm.com mutable int depth; 43710020Smatt.horsnell@ARM.com 43810020Smatt.horsnell@ARM.com /** 4395735Snate@binkert.org * Accessor for size. 4405735Snate@binkert.org */ 4416104Ssteve.reinhardt@amd.com bool 44210568Sandreas.hansson@arm.com hasSize() const 4436104Ssteve.reinhardt@amd.com { 4446104Ssteve.reinhardt@amd.com return privateFlags.isSet(VALID_SIZE); 4456104Ssteve.reinhardt@amd.com } 4466104Ssteve.reinhardt@amd.com 44710755Sandreas.hansson@arm.com unsigned 44810568Sandreas.hansson@arm.com getSize() const 4495735Snate@binkert.org { 4506104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_SIZE)); 4516427Ssteve.reinhardt@amd.com return _size; 4525735Snate@binkert.org } 4535735Snate@binkert.org 4542663Sstever@eecs.umich.edu /** Accessor for time. */ 4555735Snate@binkert.org Tick 4566223Snate@binkert.org time() const 4575735Snate@binkert.org { 4586104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 4596223Snate@binkert.org return _time; 4606223Snate@binkert.org } 4616223Snate@binkert.org 4622663Sstever@eecs.umich.edu /** Accessor for flags. */ 4635735Snate@binkert.org Flags 4645735Snate@binkert.org getFlags() 4655735Snate@binkert.org { 4666104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 4676427Ssteve.reinhardt@amd.com return _flags; 4685735Snate@binkert.org } 4695735Snate@binkert.org 4706428Ssteve.reinhardt@amd.com /** Note that unlike other accessors, this function sets *specific 4716428Ssteve.reinhardt@amd.com flags* (ORs them in); it does not assign its argument to the 4726428Ssteve.reinhardt@amd.com _flags field. Thus this method should rightly be called 4736428Ssteve.reinhardt@amd.com setFlags() and not just flags(). */ 4745735Snate@binkert.org void 4756427Ssteve.reinhardt@amd.com setFlags(Flags flags) 4765735Snate@binkert.org { 4776104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 4786427Ssteve.reinhardt@amd.com _flags.set(flags); 4795735Snate@binkert.org } 4805735Snate@binkert.org 4812663Sstever@eecs.umich.edu /** Accessor function for vaddr.*/ 48210362Smitch.hayenga@arm.com bool 48310362Smitch.hayenga@arm.com hasVaddr() const 48410362Smitch.hayenga@arm.com { 48510362Smitch.hayenga@arm.com return privateFlags.isSet(VALID_VADDR); 48610362Smitch.hayenga@arm.com } 48710362Smitch.hayenga@arm.com 4885735Snate@binkert.org Addr 48910362Smitch.hayenga@arm.com getVaddr() const 4905735Snate@binkert.org { 4916104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_VADDR)); 4926427Ssteve.reinhardt@amd.com return _vaddr; 4935735Snate@binkert.org } 4942663Sstever@eecs.umich.edu 4958832SAli.Saidi@ARM.com /** Accesssor for the requestor id. */ 4968832SAli.Saidi@ARM.com MasterID 49710568Sandreas.hansson@arm.com masterId() const 4988832SAli.Saidi@ARM.com { 4998832SAli.Saidi@ARM.com return _masterId; 5008832SAli.Saidi@ARM.com } 5018832SAli.Saidi@ARM.com 50210024Sdam.sunwoo@arm.com uint32_t 50310024Sdam.sunwoo@arm.com taskId() const 50410024Sdam.sunwoo@arm.com { 50510024Sdam.sunwoo@arm.com return _taskId; 50610024Sdam.sunwoo@arm.com } 50710024Sdam.sunwoo@arm.com 50810024Sdam.sunwoo@arm.com void 50910024Sdam.sunwoo@arm.com taskId(uint32_t id) { 51010024Sdam.sunwoo@arm.com _taskId = id; 51110024Sdam.sunwoo@arm.com } 51210024Sdam.sunwoo@arm.com 5132663Sstever@eecs.umich.edu /** Accessor function for asid.*/ 5145735Snate@binkert.org int 51510568Sandreas.hansson@arm.com getAsid() const 5165735Snate@binkert.org { 5176104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_VADDR)); 5186427Ssteve.reinhardt@amd.com return _asid; 5195735Snate@binkert.org } 5202663Sstever@eecs.umich.edu 5218551Sdaniel.johnson@arm.com /** Accessor function for asid.*/ 5228551Sdaniel.johnson@arm.com void 5238551Sdaniel.johnson@arm.com setAsid(int asid) 5248551Sdaniel.johnson@arm.com { 5258551Sdaniel.johnson@arm.com _asid = asid; 5268551Sdaniel.johnson@arm.com } 5278551Sdaniel.johnson@arm.com 5289912Sandreas@sandberg.pp.se /** Accessor function for architecture-specific flags.*/ 5299912Sandreas@sandberg.pp.se ArchFlagsType 53010568Sandreas.hansson@arm.com getArchFlags() const 5315735Snate@binkert.org { 5329912Sandreas@sandberg.pp.se assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 5339912Sandreas@sandberg.pp.se return _flags & ARCH_BITS; 5345735Snate@binkert.org } 5353804Ssaidi@eecs.umich.edu 5362679Sktlim@umich.edu /** Accessor function to check if sc result is valid. */ 5375735Snate@binkert.org bool 53810568Sandreas.hansson@arm.com extraDataValid() const 5395735Snate@binkert.org { 5406104Ssteve.reinhardt@amd.com return privateFlags.isSet(VALID_EXTRA_DATA); 5415735Snate@binkert.org } 5425735Snate@binkert.org 5432663Sstever@eecs.umich.edu /** Accessor function for store conditional return value.*/ 5445735Snate@binkert.org uint64_t 5455735Snate@binkert.org getExtraData() const 5465735Snate@binkert.org { 5476104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_EXTRA_DATA)); 5486427Ssteve.reinhardt@amd.com return _extraData; 5495735Snate@binkert.org } 5505735Snate@binkert.org 5512663Sstever@eecs.umich.edu /** Accessor function for store conditional return value.*/ 5525735Snate@binkert.org void 5536427Ssteve.reinhardt@amd.com setExtraData(uint64_t extraData) 5545735Snate@binkert.org { 5556427Ssteve.reinhardt@amd.com _extraData = extraData; 5566104Ssteve.reinhardt@amd.com privateFlags.set(VALID_EXTRA_DATA); 5575735Snate@binkert.org } 5582663Sstever@eecs.umich.edu 5596010Ssteve.reinhardt@amd.com bool 5606010Ssteve.reinhardt@amd.com hasContextId() const 5616010Ssteve.reinhardt@amd.com { 5626104Ssteve.reinhardt@amd.com return privateFlags.isSet(VALID_CONTEXT_ID); 5636010Ssteve.reinhardt@amd.com } 5646010Ssteve.reinhardt@amd.com 5655714Shsul@eecs.umich.edu /** Accessor function for context ID.*/ 5665735Snate@binkert.org int 5675735Snate@binkert.org contextId() const 5685735Snate@binkert.org { 5696104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_CONTEXT_ID)); 5705735Snate@binkert.org return _contextId; 5715735Snate@binkert.org } 5725735Snate@binkert.org 5735714Shsul@eecs.umich.edu /** Accessor function for thread ID. */ 57410755Sandreas.hansson@arm.com ThreadID 5755735Snate@binkert.org threadId() const 5765735Snate@binkert.org { 5776104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_THREAD_ID)); 5785735Snate@binkert.org return _threadId; 5795735Snate@binkert.org } 5802663Sstever@eecs.umich.edu 58110052Smitch.hayenga+gem5@gmail.com void 58210052Smitch.hayenga+gem5@gmail.com setPC(Addr pc) 58310052Smitch.hayenga+gem5@gmail.com { 58410052Smitch.hayenga+gem5@gmail.com privateFlags.set(VALID_PC); 58510052Smitch.hayenga+gem5@gmail.com _pc = pc; 58610052Smitch.hayenga+gem5@gmail.com } 58710052Smitch.hayenga+gem5@gmail.com 5885875Ssteve.reinhardt@amd.com bool 5895875Ssteve.reinhardt@amd.com hasPC() const 5905875Ssteve.reinhardt@amd.com { 5916104Ssteve.reinhardt@amd.com return privateFlags.isSet(VALID_PC); 5925875Ssteve.reinhardt@amd.com } 5935875Ssteve.reinhardt@amd.com 5946010Ssteve.reinhardt@amd.com /** Accessor function for pc.*/ 5955735Snate@binkert.org Addr 5965735Snate@binkert.org getPC() const 5975735Snate@binkert.org { 5986104Ssteve.reinhardt@amd.com assert(privateFlags.isSet(VALID_PC)); 5996427Ssteve.reinhardt@amd.com return _pc; 6005735Snate@binkert.org } 6012532SN/A 60210020Smatt.horsnell@ARM.com /** 60310020Smatt.horsnell@ARM.com * Increment/Get the depth at which this request is responded to. 60410020Smatt.horsnell@ARM.com * This currently happens when the request misses in any cache level. 60510020Smatt.horsnell@ARM.com */ 60610568Sandreas.hansson@arm.com void incAccessDepth() const { depth++; } 60710020Smatt.horsnell@ARM.com int getAccessDepth() const { return depth; } 60810020Smatt.horsnell@ARM.com 60910020Smatt.horsnell@ARM.com /** 61010020Smatt.horsnell@ARM.com * Set/Get the time taken for this request to be successfully translated. 61110020Smatt.horsnell@ARM.com */ 61210020Smatt.horsnell@ARM.com void setTranslateLatency() { translateDelta = curTick() - _time; } 61310020Smatt.horsnell@ARM.com Tick getTranslateLatency() const { return translateDelta; } 61410020Smatt.horsnell@ARM.com 61510020Smatt.horsnell@ARM.com /** 61610020Smatt.horsnell@ARM.com * Set/Get the time taken to complete this request's access, not including 61710020Smatt.horsnell@ARM.com * the time to successfully translate the request. 61810020Smatt.horsnell@ARM.com */ 61910020Smatt.horsnell@ARM.com void setAccessLatency() { accessDelta = curTick() - _time - translateDelta; } 62010020Smatt.horsnell@ARM.com Tick getAccessLatency() const { return accessDelta; } 62110020Smatt.horsnell@ARM.com 6226428Ssteve.reinhardt@amd.com /** Accessor functions for flags. Note that these are for testing 6236428Ssteve.reinhardt@amd.com only; setting flags should be done via setFlags(). */ 6246427Ssteve.reinhardt@amd.com bool isUncacheable() const { return _flags.isSet(UNCACHEABLE); } 6256427Ssteve.reinhardt@amd.com bool isInstFetch() const { return _flags.isSet(INST_FETCH); } 6266427Ssteve.reinhardt@amd.com bool isPrefetch() const { return _flags.isSet(PREFETCH); } 6276427Ssteve.reinhardt@amd.com bool isLLSC() const { return _flags.isSet(LLSC); } 6289950Sprakash.ramrakhyani@arm.com bool isPriv() const { return _flags.isSet(PRIVILEGED); } 62910760Ssteve.reinhardt@amd.com bool isLockedRMW() const { return _flags.isSet(LOCKED_RMW); } 6306427Ssteve.reinhardt@amd.com bool isSwap() const { return _flags.isSet(MEM_SWAP|MEM_SWAP_COND); } 6316427Ssteve.reinhardt@amd.com bool isCondSwap() const { return _flags.isSet(MEM_SWAP_COND); } 6328105Sgblack@eecs.umich.edu bool isMmappedIpr() const { return _flags.isSet(MMAPPED_IPR); } 6337705Sgblack@eecs.umich.edu bool isClearLL() const { return _flags.isSet(CLEAR_LL); } 63410028SGiacomo.Gabrielli@arm.com bool isSecure() const { return _flags.isSet(SECURE); } 63510029SGiacomo.Gabrielli@arm.com bool isPTWalk() const { return _flags.isSet(PT_WALK); } 6362384SN/A}; 6372381SN/A 6382381SN/A#endif // __MEM_REQUEST_HH__ 639