1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ron Dreslinski 29 * Steve Reinhardt 30 * Ali Saidi 31 */ 32 33/** 34 * @file 35 * Declaration of a request, the overall memory request consisting of 36 the parts of the request that are persistent throughout the transaction. 37 */ 38 39#ifndef __MEM_REQUEST_HH__ 40#define __MEM_REQUEST_HH__ 41 42#include <cassert> 43#include <climits> 44
| 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ron Dreslinski 29 * Steve Reinhardt 30 * Ali Saidi 31 */ 32 33/** 34 * @file 35 * Declaration of a request, the overall memory request consisting of 36 the parts of the request that are persistent throughout the transaction. 37 */ 38 39#ifndef __MEM_REQUEST_HH__ 40#define __MEM_REQUEST_HH__ 41 42#include <cassert> 43#include <climits> 44
|
45#include "base/fast_alloc.hh"
| |
46#include "base/flags.hh" 47#include "base/misc.hh" 48#include "base/types.hh" 49#include "sim/core.hh" 50 51class Request; 52 53typedef Request* RequestPtr; 54typedef uint16_t MasterID; 55
| 45#include "base/flags.hh" 46#include "base/misc.hh" 47#include "base/types.hh" 48#include "sim/core.hh" 49 50class Request; 51 52typedef Request* RequestPtr; 53typedef uint16_t MasterID; 54
|
56class Request : public FastAlloc
| 55class Request
|
57{ 58 public: 59 typedef uint32_t FlagsType; 60 typedef ::Flags<FlagsType> Flags; 61 62 /** ASI information for this request if it exists. */ 63 static const FlagsType ASI_BITS = 0x000000FF; 64 /** The request was an instruction fetch. */ 65 static const FlagsType INST_FETCH = 0x00000100; 66 /** The virtual address is also the physical address. */ 67 static const FlagsType PHYSICAL = 0x00000200; 68 /** The request is an ALPHA VPTE pal access (hw_ld). */ 69 static const FlagsType VPTE = 0x00000400; 70 /** Use the alternate mode bits in ALPHA. */ 71 static const FlagsType ALTMODE = 0x00000800; 72 /** The request is to an uncacheable address. */ 73 static const FlagsType UNCACHEABLE = 0x00001000; 74 /** This request is to a memory mapped register. */ 75 static const FlagsType MMAPPED_IPR = 0x00002000; 76 /** This request is a clear exclusive. */ 77 static const FlagsType CLEAR_LL = 0x00004000; 78 79 /** The request should not cause a memory access. */ 80 static const FlagsType NO_ACCESS = 0x00080000; 81 /** This request will lock or unlock the accessed memory. When used with 82 * a load, the access locks the particular chunk of memory. When used 83 * with a store, it unlocks. The rule is that locked accesses have to be 84 * made up of a locked load, some operation on the data, and then a locked 85 * store. 86 */ 87 static const FlagsType LOCKED = 0x00100000; 88 /** The request is a Load locked/store conditional. */ 89 static const FlagsType LLSC = 0x00200000; 90 /** This request is for a memory swap. */ 91 static const FlagsType MEM_SWAP = 0x00400000; 92 static const FlagsType MEM_SWAP_COND = 0x00800000; 93 94 /** The request is a prefetch. */ 95 static const FlagsType PREFETCH = 0x01000000; 96 /** The request should be prefetched into the exclusive state. */ 97 static const FlagsType PF_EXCLUSIVE = 0x02000000; 98 /** The request should be marked as LRU. */ 99 static const FlagsType EVICT_NEXT = 0x04000000; 100 101 /** These flags are *not* cleared when a Request object is reused 102 (assigned a new address). */ 103 static const FlagsType STICKY_FLAGS = INST_FETCH; 104 105 /** Request Ids that are statically allocated 106 * @{*/ 107 /** This request id is used for writeback requests by the caches */ 108 static const MasterID wbMasterId = 0; 109 /** This request id is used for functional requests that don't come from a 110 * particular device 111 */ 112 static const MasterID funcMasterId = 1; 113 /** This request id is used for message signaled interrupts */ 114 static const MasterID intMasterId = 2; 115 /** Invalid request id for assertion checking only. It is invalid behavior 116 * to ever send this id as part of a request. 117 * @todo C++1x replace with numeric_limits when constexpr is added */ 118 static const MasterID invldMasterId = USHRT_MAX; 119 /** @} */ 120 121 private: 122 typedef uint8_t PrivateFlagsType; 123 typedef ::Flags<PrivateFlagsType> PrivateFlags; 124 125 /** Whether or not the size is valid. */ 126 static const PrivateFlagsType VALID_SIZE = 0x00000001; 127 /** Whether or not paddr is valid (has been written yet). */ 128 static const PrivateFlagsType VALID_PADDR = 0x00000002; 129 /** Whether or not the vaddr & asid are valid. */ 130 static const PrivateFlagsType VALID_VADDR = 0x00000004; 131 /** Whether or not the pc is valid. */ 132 static const PrivateFlagsType VALID_PC = 0x00000010; 133 /** Whether or not the context ID is valid. */ 134 static const PrivateFlagsType VALID_CONTEXT_ID = 0x00000020; 135 static const PrivateFlagsType VALID_THREAD_ID = 0x00000040; 136 /** Whether or not the sc result is valid. */ 137 static const PrivateFlagsType VALID_EXTRA_DATA = 0x00000080; 138 139 /** These flags are *not* cleared when a Request object is reused 140 (assigned a new address). */ 141 static const PrivateFlagsType STICKY_PRIVATE_FLAGS = 142 VALID_CONTEXT_ID | VALID_THREAD_ID; 143 144 private: 145 /** 146 * The physical address of the request. Valid only if validPaddr 147 * is set. 148 */ 149 Addr _paddr; 150 151 /** 152 * The size of the request. This field must be set when vaddr or 153 * paddr is written via setVirt() or setPhys(), so it is always 154 * valid as long as one of the address fields is valid. 155 */ 156 int _size; 157 158 /** The requestor ID which is unique in the system for all ports 159 * that are capable of issuing a transaction 160 */ 161 MasterID _masterId; 162 163 /** Flag structure for the request. */ 164 Flags _flags; 165 166 /** Private flags for field validity checking. */ 167 PrivateFlags privateFlags; 168 169 /** 170 * The time this request was started. Used to calculate 171 * latencies. This field is set to curTick() any time paddr or vaddr 172 * is written. 173 */ 174 Tick _time; 175 176 /** The address space ID. */ 177 int _asid; 178 179 /** The virtual address of the request. */ 180 Addr _vaddr; 181 182 /** 183 * Extra data for the request, such as the return value of 184 * store conditional or the compare value for a CAS. */ 185 uint64_t _extraData; 186 187 /** The context ID (for statistics, typically). */ 188 int _contextId; 189 /** The thread ID (id within this CPU) */ 190 int _threadId; 191 192 /** program counter of initiating access; for tracing/debugging */ 193 Addr _pc; 194 195 public: 196 /** Minimal constructor. No fields are initialized. 197 * (Note that _flags and privateFlags are cleared by Flags 198 * default constructor.) 199 */ 200 Request() 201 {} 202 203 /** 204 * Constructor for physical (e.g. device) requests. Initializes 205 * just physical address, size, flags, and timestamp (to curTick()). 206 * These fields are adequate to perform a request. 207 */ 208 Request(Addr paddr, int size, Flags flags, MasterID mid) 209 { 210 setPhys(paddr, size, flags, mid); 211 } 212 213 Request(Addr paddr, int size, Flags flags, MasterID mid, Tick time) 214 { 215 setPhys(paddr, size, flags, mid, time); 216 } 217 218 Request(Addr paddr, int size, Flags flags, MasterID mid, Tick time, Addr pc) 219 { 220 setPhys(paddr, size, flags, mid, time); 221 privateFlags.set(VALID_PC); 222 _pc = pc; 223 } 224 225 Request(int asid, Addr vaddr, int size, Flags flags, MasterID mid, Addr pc, 226 int cid, ThreadID tid) 227 { 228 setVirt(asid, vaddr, size, flags, mid, pc); 229 setThreadContext(cid, tid); 230 } 231
| 56{ 57 public: 58 typedef uint32_t FlagsType; 59 typedef ::Flags<FlagsType> Flags; 60 61 /** ASI information for this request if it exists. */ 62 static const FlagsType ASI_BITS = 0x000000FF; 63 /** The request was an instruction fetch. */ 64 static const FlagsType INST_FETCH = 0x00000100; 65 /** The virtual address is also the physical address. */ 66 static const FlagsType PHYSICAL = 0x00000200; 67 /** The request is an ALPHA VPTE pal access (hw_ld). */ 68 static const FlagsType VPTE = 0x00000400; 69 /** Use the alternate mode bits in ALPHA. */ 70 static const FlagsType ALTMODE = 0x00000800; 71 /** The request is to an uncacheable address. */ 72 static const FlagsType UNCACHEABLE = 0x00001000; 73 /** This request is to a memory mapped register. */ 74 static const FlagsType MMAPPED_IPR = 0x00002000; 75 /** This request is a clear exclusive. */ 76 static const FlagsType CLEAR_LL = 0x00004000; 77 78 /** The request should not cause a memory access. */ 79 static const FlagsType NO_ACCESS = 0x00080000; 80 /** This request will lock or unlock the accessed memory. When used with 81 * a load, the access locks the particular chunk of memory. When used 82 * with a store, it unlocks. The rule is that locked accesses have to be 83 * made up of a locked load, some operation on the data, and then a locked 84 * store. 85 */ 86 static const FlagsType LOCKED = 0x00100000; 87 /** The request is a Load locked/store conditional. */ 88 static const FlagsType LLSC = 0x00200000; 89 /** This request is for a memory swap. */ 90 static const FlagsType MEM_SWAP = 0x00400000; 91 static const FlagsType MEM_SWAP_COND = 0x00800000; 92 93 /** The request is a prefetch. */ 94 static const FlagsType PREFETCH = 0x01000000; 95 /** The request should be prefetched into the exclusive state. */ 96 static const FlagsType PF_EXCLUSIVE = 0x02000000; 97 /** The request should be marked as LRU. */ 98 static const FlagsType EVICT_NEXT = 0x04000000; 99 100 /** These flags are *not* cleared when a Request object is reused 101 (assigned a new address). */ 102 static const FlagsType STICKY_FLAGS = INST_FETCH; 103 104 /** Request Ids that are statically allocated 105 * @{*/ 106 /** This request id is used for writeback requests by the caches */ 107 static const MasterID wbMasterId = 0; 108 /** This request id is used for functional requests that don't come from a 109 * particular device 110 */ 111 static const MasterID funcMasterId = 1; 112 /** This request id is used for message signaled interrupts */ 113 static const MasterID intMasterId = 2; 114 /** Invalid request id for assertion checking only. It is invalid behavior 115 * to ever send this id as part of a request. 116 * @todo C++1x replace with numeric_limits when constexpr is added */ 117 static const MasterID invldMasterId = USHRT_MAX; 118 /** @} */ 119 120 private: 121 typedef uint8_t PrivateFlagsType; 122 typedef ::Flags<PrivateFlagsType> PrivateFlags; 123 124 /** Whether or not the size is valid. */ 125 static const PrivateFlagsType VALID_SIZE = 0x00000001; 126 /** Whether or not paddr is valid (has been written yet). */ 127 static const PrivateFlagsType VALID_PADDR = 0x00000002; 128 /** Whether or not the vaddr & asid are valid. */ 129 static const PrivateFlagsType VALID_VADDR = 0x00000004; 130 /** Whether or not the pc is valid. */ 131 static const PrivateFlagsType VALID_PC = 0x00000010; 132 /** Whether or not the context ID is valid. */ 133 static const PrivateFlagsType VALID_CONTEXT_ID = 0x00000020; 134 static const PrivateFlagsType VALID_THREAD_ID = 0x00000040; 135 /** Whether or not the sc result is valid. */ 136 static const PrivateFlagsType VALID_EXTRA_DATA = 0x00000080; 137 138 /** These flags are *not* cleared when a Request object is reused 139 (assigned a new address). */ 140 static const PrivateFlagsType STICKY_PRIVATE_FLAGS = 141 VALID_CONTEXT_ID | VALID_THREAD_ID; 142 143 private: 144 /** 145 * The physical address of the request. Valid only if validPaddr 146 * is set. 147 */ 148 Addr _paddr; 149 150 /** 151 * The size of the request. This field must be set when vaddr or 152 * paddr is written via setVirt() or setPhys(), so it is always 153 * valid as long as one of the address fields is valid. 154 */ 155 int _size; 156 157 /** The requestor ID which is unique in the system for all ports 158 * that are capable of issuing a transaction 159 */ 160 MasterID _masterId; 161 162 /** Flag structure for the request. */ 163 Flags _flags; 164 165 /** Private flags for field validity checking. */ 166 PrivateFlags privateFlags; 167 168 /** 169 * The time this request was started. Used to calculate 170 * latencies. This field is set to curTick() any time paddr or vaddr 171 * is written. 172 */ 173 Tick _time; 174 175 /** The address space ID. */ 176 int _asid; 177 178 /** The virtual address of the request. */ 179 Addr _vaddr; 180 181 /** 182 * Extra data for the request, such as the return value of 183 * store conditional or the compare value for a CAS. */ 184 uint64_t _extraData; 185 186 /** The context ID (for statistics, typically). */ 187 int _contextId; 188 /** The thread ID (id within this CPU) */ 189 int _threadId; 190 191 /** program counter of initiating access; for tracing/debugging */ 192 Addr _pc; 193 194 public: 195 /** Minimal constructor. No fields are initialized. 196 * (Note that _flags and privateFlags are cleared by Flags 197 * default constructor.) 198 */ 199 Request() 200 {} 201 202 /** 203 * Constructor for physical (e.g. device) requests. Initializes 204 * just physical address, size, flags, and timestamp (to curTick()). 205 * These fields are adequate to perform a request. 206 */ 207 Request(Addr paddr, int size, Flags flags, MasterID mid) 208 { 209 setPhys(paddr, size, flags, mid); 210 } 211 212 Request(Addr paddr, int size, Flags flags, MasterID mid, Tick time) 213 { 214 setPhys(paddr, size, flags, mid, time); 215 } 216 217 Request(Addr paddr, int size, Flags flags, MasterID mid, Tick time, Addr pc) 218 { 219 setPhys(paddr, size, flags, mid, time); 220 privateFlags.set(VALID_PC); 221 _pc = pc; 222 } 223 224 Request(int asid, Addr vaddr, int size, Flags flags, MasterID mid, Addr pc, 225 int cid, ThreadID tid) 226 { 227 setVirt(asid, vaddr, size, flags, mid, pc); 228 setThreadContext(cid, tid); 229 } 230
|
232 ~Request() {} // for FastAlloc
| 231 ~Request() {}
|
233 234 /** 235 * Set up CPU and thread numbers. 236 */ 237 void 238 setThreadContext(int context_id, ThreadID tid) 239 { 240 _contextId = context_id; 241 _threadId = tid; 242 privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID); 243 } 244 245 /** 246 * Set up a physical (e.g. device) request in a previously 247 * allocated Request object. 248 */ 249 void 250 setPhys(Addr paddr, int size, Flags flags, MasterID mid, Tick time) 251 { 252 assert(size >= 0); 253 _paddr = paddr; 254 _size = size; 255 _time = time; 256 _masterId = mid; 257 _flags.clear(~STICKY_FLAGS); 258 _flags.set(flags); 259 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 260 privateFlags.set(VALID_PADDR|VALID_SIZE); 261 } 262 263 void 264 setPhys(Addr paddr, int size, Flags flags, MasterID mid) 265 { 266 setPhys(paddr, size, flags, mid, curTick()); 267 } 268 269 /** 270 * Set up a virtual (e.g., CPU) request in a previously 271 * allocated Request object. 272 */ 273 void 274 setVirt(int asid, Addr vaddr, int size, Flags flags, MasterID mid, Addr pc) 275 { 276 assert(size >= 0); 277 _asid = asid; 278 _vaddr = vaddr; 279 _size = size; 280 _masterId = mid; 281 _pc = pc; 282 _time = curTick(); 283 284 _flags.clear(~STICKY_FLAGS); 285 _flags.set(flags); 286 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 287 privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC); 288 } 289 290 /** 291 * Set just the physical address. This should only be used to 292 * record the result of a translation, and thus the vaddr must be 293 * valid before this method is called. Otherwise, use setPhys() 294 * to guarantee that the size and flags are also set. 295 */ 296 void 297 setPaddr(Addr paddr) 298 { 299 assert(privateFlags.isSet(VALID_VADDR)); 300 _paddr = paddr; 301 privateFlags.set(VALID_PADDR); 302 } 303 304 /** 305 * Generate two requests as if this request had been split into two 306 * pieces. The original request can't have been translated already. 307 */ 308 void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2) 309 { 310 assert(privateFlags.isSet(VALID_VADDR)); 311 assert(privateFlags.noneSet(VALID_PADDR)); 312 assert(split_addr > _vaddr && split_addr < _vaddr + _size); 313 req1 = new Request; 314 *req1 = *this; 315 req2 = new Request; 316 *req2 = *this; 317 req1->_size = split_addr - _vaddr; 318 req2->_vaddr = split_addr; 319 req2->_size = _size - req1->_size; 320 } 321 322 /** 323 * Accessor for paddr. 324 */ 325 bool 326 hasPaddr() 327 { 328 return privateFlags.isSet(VALID_PADDR); 329 } 330 331 Addr 332 getPaddr() 333 { 334 assert(privateFlags.isSet(VALID_PADDR)); 335 return _paddr; 336 } 337 338 /** 339 * Accessor for size. 340 */ 341 bool 342 hasSize() 343 { 344 return privateFlags.isSet(VALID_SIZE); 345 } 346 347 int 348 getSize() 349 { 350 assert(privateFlags.isSet(VALID_SIZE)); 351 return _size; 352 } 353 354 /** Accessor for time. */ 355 Tick 356 time() const 357 { 358 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 359 return _time; 360 } 361 362 void 363 time(Tick time) 364 { 365 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 366 _time = time; 367 } 368 369 /** Accessor for flags. */ 370 Flags 371 getFlags() 372 { 373 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 374 return _flags; 375 } 376 377 /** Note that unlike other accessors, this function sets *specific 378 flags* (ORs them in); it does not assign its argument to the 379 _flags field. Thus this method should rightly be called 380 setFlags() and not just flags(). */ 381 void 382 setFlags(Flags flags) 383 { 384 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 385 _flags.set(flags); 386 } 387 388 /** Accessor function for vaddr.*/ 389 Addr 390 getVaddr() 391 { 392 assert(privateFlags.isSet(VALID_VADDR)); 393 return _vaddr; 394 } 395 396 /** Accesssor for the requestor id. */ 397 MasterID 398 masterId() 399 { 400 return _masterId; 401 } 402 403 /** Accessor function for asid.*/ 404 int 405 getAsid() 406 { 407 assert(privateFlags.isSet(VALID_VADDR)); 408 return _asid; 409 } 410 411 /** Accessor function for asid.*/ 412 void 413 setAsid(int asid) 414 { 415 _asid = asid; 416 } 417 418 /** Accessor function for asi.*/ 419 uint8_t 420 getAsi() 421 { 422 assert(privateFlags.isSet(VALID_VADDR)); 423 return _flags & ASI_BITS; 424 } 425 426 /** Accessor function to check if sc result is valid. */ 427 bool 428 extraDataValid() 429 { 430 return privateFlags.isSet(VALID_EXTRA_DATA); 431 } 432 433 /** Accessor function for store conditional return value.*/ 434 uint64_t 435 getExtraData() const 436 { 437 assert(privateFlags.isSet(VALID_EXTRA_DATA)); 438 return _extraData; 439 } 440 441 /** Accessor function for store conditional return value.*/ 442 void 443 setExtraData(uint64_t extraData) 444 { 445 _extraData = extraData; 446 privateFlags.set(VALID_EXTRA_DATA); 447 } 448 449 bool 450 hasContextId() const 451 { 452 return privateFlags.isSet(VALID_CONTEXT_ID); 453 } 454 455 /** Accessor function for context ID.*/ 456 int 457 contextId() const 458 { 459 assert(privateFlags.isSet(VALID_CONTEXT_ID)); 460 return _contextId; 461 } 462 463 /** Accessor function for thread ID. */ 464 int 465 threadId() const 466 { 467 assert(privateFlags.isSet(VALID_THREAD_ID)); 468 return _threadId; 469 } 470 471 bool 472 hasPC() const 473 { 474 return privateFlags.isSet(VALID_PC); 475 } 476 477 /** Accessor function for pc.*/ 478 Addr 479 getPC() const 480 { 481 assert(privateFlags.isSet(VALID_PC)); 482 return _pc; 483 } 484 485 /** Accessor functions for flags. Note that these are for testing 486 only; setting flags should be done via setFlags(). */ 487 bool isUncacheable() const { return _flags.isSet(UNCACHEABLE); } 488 bool isInstFetch() const { return _flags.isSet(INST_FETCH); } 489 bool isPrefetch() const { return _flags.isSet(PREFETCH); } 490 bool isLLSC() const { return _flags.isSet(LLSC); } 491 bool isLocked() const { return _flags.isSet(LOCKED); } 492 bool isSwap() const { return _flags.isSet(MEM_SWAP|MEM_SWAP_COND); } 493 bool isCondSwap() const { return _flags.isSet(MEM_SWAP_COND); } 494 bool isMmappedIpr() const { return _flags.isSet(MMAPPED_IPR); } 495 bool isClearLL() const { return _flags.isSet(CLEAR_LL); } 496}; 497 498#endif // __MEM_REQUEST_HH__
| 232 233 /** 234 * Set up CPU and thread numbers. 235 */ 236 void 237 setThreadContext(int context_id, ThreadID tid) 238 { 239 _contextId = context_id; 240 _threadId = tid; 241 privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID); 242 } 243 244 /** 245 * Set up a physical (e.g. device) request in a previously 246 * allocated Request object. 247 */ 248 void 249 setPhys(Addr paddr, int size, Flags flags, MasterID mid, Tick time) 250 { 251 assert(size >= 0); 252 _paddr = paddr; 253 _size = size; 254 _time = time; 255 _masterId = mid; 256 _flags.clear(~STICKY_FLAGS); 257 _flags.set(flags); 258 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 259 privateFlags.set(VALID_PADDR|VALID_SIZE); 260 } 261 262 void 263 setPhys(Addr paddr, int size, Flags flags, MasterID mid) 264 { 265 setPhys(paddr, size, flags, mid, curTick()); 266 } 267 268 /** 269 * Set up a virtual (e.g., CPU) request in a previously 270 * allocated Request object. 271 */ 272 void 273 setVirt(int asid, Addr vaddr, int size, Flags flags, MasterID mid, Addr pc) 274 { 275 assert(size >= 0); 276 _asid = asid; 277 _vaddr = vaddr; 278 _size = size; 279 _masterId = mid; 280 _pc = pc; 281 _time = curTick(); 282 283 _flags.clear(~STICKY_FLAGS); 284 _flags.set(flags); 285 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 286 privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC); 287 } 288 289 /** 290 * Set just the physical address. This should only be used to 291 * record the result of a translation, and thus the vaddr must be 292 * valid before this method is called. Otherwise, use setPhys() 293 * to guarantee that the size and flags are also set. 294 */ 295 void 296 setPaddr(Addr paddr) 297 { 298 assert(privateFlags.isSet(VALID_VADDR)); 299 _paddr = paddr; 300 privateFlags.set(VALID_PADDR); 301 } 302 303 /** 304 * Generate two requests as if this request had been split into two 305 * pieces. The original request can't have been translated already. 306 */ 307 void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2) 308 { 309 assert(privateFlags.isSet(VALID_VADDR)); 310 assert(privateFlags.noneSet(VALID_PADDR)); 311 assert(split_addr > _vaddr && split_addr < _vaddr + _size); 312 req1 = new Request; 313 *req1 = *this; 314 req2 = new Request; 315 *req2 = *this; 316 req1->_size = split_addr - _vaddr; 317 req2->_vaddr = split_addr; 318 req2->_size = _size - req1->_size; 319 } 320 321 /** 322 * Accessor for paddr. 323 */ 324 bool 325 hasPaddr() 326 { 327 return privateFlags.isSet(VALID_PADDR); 328 } 329 330 Addr 331 getPaddr() 332 { 333 assert(privateFlags.isSet(VALID_PADDR)); 334 return _paddr; 335 } 336 337 /** 338 * Accessor for size. 339 */ 340 bool 341 hasSize() 342 { 343 return privateFlags.isSet(VALID_SIZE); 344 } 345 346 int 347 getSize() 348 { 349 assert(privateFlags.isSet(VALID_SIZE)); 350 return _size; 351 } 352 353 /** Accessor for time. */ 354 Tick 355 time() const 356 { 357 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 358 return _time; 359 } 360 361 void 362 time(Tick time) 363 { 364 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 365 _time = time; 366 } 367 368 /** Accessor for flags. */ 369 Flags 370 getFlags() 371 { 372 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 373 return _flags; 374 } 375 376 /** Note that unlike other accessors, this function sets *specific 377 flags* (ORs them in); it does not assign its argument to the 378 _flags field. Thus this method should rightly be called 379 setFlags() and not just flags(). */ 380 void 381 setFlags(Flags flags) 382 { 383 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 384 _flags.set(flags); 385 } 386 387 /** Accessor function for vaddr.*/ 388 Addr 389 getVaddr() 390 { 391 assert(privateFlags.isSet(VALID_VADDR)); 392 return _vaddr; 393 } 394 395 /** Accesssor for the requestor id. */ 396 MasterID 397 masterId() 398 { 399 return _masterId; 400 } 401 402 /** Accessor function for asid.*/ 403 int 404 getAsid() 405 { 406 assert(privateFlags.isSet(VALID_VADDR)); 407 return _asid; 408 } 409 410 /** Accessor function for asid.*/ 411 void 412 setAsid(int asid) 413 { 414 _asid = asid; 415 } 416 417 /** Accessor function for asi.*/ 418 uint8_t 419 getAsi() 420 { 421 assert(privateFlags.isSet(VALID_VADDR)); 422 return _flags & ASI_BITS; 423 } 424 425 /** Accessor function to check if sc result is valid. */ 426 bool 427 extraDataValid() 428 { 429 return privateFlags.isSet(VALID_EXTRA_DATA); 430 } 431 432 /** Accessor function for store conditional return value.*/ 433 uint64_t 434 getExtraData() const 435 { 436 assert(privateFlags.isSet(VALID_EXTRA_DATA)); 437 return _extraData; 438 } 439 440 /** Accessor function for store conditional return value.*/ 441 void 442 setExtraData(uint64_t extraData) 443 { 444 _extraData = extraData; 445 privateFlags.set(VALID_EXTRA_DATA); 446 } 447 448 bool 449 hasContextId() const 450 { 451 return privateFlags.isSet(VALID_CONTEXT_ID); 452 } 453 454 /** Accessor function for context ID.*/ 455 int 456 contextId() const 457 { 458 assert(privateFlags.isSet(VALID_CONTEXT_ID)); 459 return _contextId; 460 } 461 462 /** Accessor function for thread ID. */ 463 int 464 threadId() const 465 { 466 assert(privateFlags.isSet(VALID_THREAD_ID)); 467 return _threadId; 468 } 469 470 bool 471 hasPC() const 472 { 473 return privateFlags.isSet(VALID_PC); 474 } 475 476 /** Accessor function for pc.*/ 477 Addr 478 getPC() const 479 { 480 assert(privateFlags.isSet(VALID_PC)); 481 return _pc; 482 } 483 484 /** Accessor functions for flags. Note that these are for testing 485 only; setting flags should be done via setFlags(). */ 486 bool isUncacheable() const { return _flags.isSet(UNCACHEABLE); } 487 bool isInstFetch() const { return _flags.isSet(INST_FETCH); } 488 bool isPrefetch() const { return _flags.isSet(PREFETCH); } 489 bool isLLSC() const { return _flags.isSet(LLSC); } 490 bool isLocked() const { return _flags.isSet(LOCKED); } 491 bool isSwap() const { return _flags.isSet(MEM_SWAP|MEM_SWAP_COND); } 492 bool isCondSwap() const { return _flags.isSet(MEM_SWAP_COND); } 493 bool isMmappedIpr() const { return _flags.isSet(MMAPPED_IPR); } 494 bool isClearLL() const { return _flags.isSet(CLEAR_LL); } 495}; 496 497#endif // __MEM_REQUEST_HH__
|