request.hh (6428:9e35cdc95e81) | request.hh (6739:48d10ba361c9) |
---|---|
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 44#include "base/fast_alloc.hh" 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; 53 54class Request : public FastAlloc 55{ 56 public: 57 typedef uint32_t FlagsType; 58 typedef ::Flags<FlagsType> Flags; 59 60 /** ASI information for this request if it exists. */ 61 static const FlagsType ASI_BITS = 0x000000FF; 62 /** The request was an instruction fetch. */ 63 static const FlagsType INST_FETCH = 0x00000100; 64 /** The virtual address is also the physical address. */ 65 static const FlagsType PHYSICAL = 0x00000200; 66 /** The request is an ALPHA VPTE pal access (hw_ld). */ 67 static const FlagsType VPTE = 0x00000400; 68 /** Use the alternate mode bits in ALPHA. */ 69 static const FlagsType ALTMODE = 0x00000800; 70 /** The request is to an uncacheable address. */ 71 static const FlagsType UNCACHEABLE = 0x00001000; 72 /** This request is to a memory mapped register. */ 73 static const FlagsType MMAPED_IPR = 0x00002000; 74 | 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 44#include "base/fast_alloc.hh" 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; 53 54class Request : public FastAlloc 55{ 56 public: 57 typedef uint32_t FlagsType; 58 typedef ::Flags<FlagsType> Flags; 59 60 /** ASI information for this request if it exists. */ 61 static const FlagsType ASI_BITS = 0x000000FF; 62 /** The request was an instruction fetch. */ 63 static const FlagsType INST_FETCH = 0x00000100; 64 /** The virtual address is also the physical address. */ 65 static const FlagsType PHYSICAL = 0x00000200; 66 /** The request is an ALPHA VPTE pal access (hw_ld). */ 67 static const FlagsType VPTE = 0x00000400; 68 /** Use the alternate mode bits in ALPHA. */ 69 static const FlagsType ALTMODE = 0x00000800; 70 /** The request is to an uncacheable address. */ 71 static const FlagsType UNCACHEABLE = 0x00001000; 72 /** This request is to a memory mapped register. */ 73 static const FlagsType MMAPED_IPR = 0x00002000; 74 |
75 /** The request should not cause a page fault. */ 76 static const FlagsType NO_FAULT = 0x00010000; | |
77 /** The request should ignore unaligned access faults */ 78 static const FlagsType NO_ALIGN_FAULT = 0x00020000; 79 /** The request should ignore unaligned access faults */ 80 static const FlagsType NO_HALF_WORD_ALIGN_FAULT = 0x00040000; 81 /** The request should not cause a memory access. */ 82 static const FlagsType NO_ACCESS = 0x00080000; 83 /** This request will lock or unlock the accessed memory. When used with 84 * a load, the access locks the particular chunk of memory. When used 85 * with a store, it unlocks. The rule is that locked accesses have to be 86 * made up of a locked load, some operation on the data, and then a locked 87 * store. 88 */ 89 static const FlagsType LOCKED = 0x00100000; 90 /** The request is a Load locked/store conditional. */ 91 static const FlagsType LLSC = 0x00200000; 92 /** This request is for a memory swap. */ 93 static const FlagsType MEM_SWAP = 0x00400000; 94 static const FlagsType MEM_SWAP_COND = 0x00800000; 95 96 /** The request is a prefetch. */ 97 static const FlagsType PREFETCH = 0x01000000; 98 /** The request should be prefetched into the exclusive state. */ 99 static const FlagsType PF_EXCLUSIVE = 0x02000000; 100 /** The request should be marked as LRU. */ 101 static const FlagsType EVICT_NEXT = 0x04000000; 102 103 /** These flags are *not* cleared when a Request object is reused 104 (assigned a new address). */ 105 static const FlagsType STICKY_FLAGS = INST_FETCH; 106 107 private: 108 typedef uint8_t PrivateFlagsType; 109 typedef ::Flags<PrivateFlagsType> PrivateFlags; 110 111 /** Whether or not the size is valid. */ 112 static const PrivateFlagsType VALID_SIZE = 0x00000001; 113 /** Whether or not paddr is valid (has been written yet). */ 114 static const PrivateFlagsType VALID_PADDR = 0x00000002; 115 /** Whether or not the vaddr & asid are valid. */ 116 static const PrivateFlagsType VALID_VADDR = 0x00000004; 117 /** Whether or not the pc is valid. */ 118 static const PrivateFlagsType VALID_PC = 0x00000010; 119 /** Whether or not the context ID is valid. */ 120 static const PrivateFlagsType VALID_CONTEXT_ID = 0x00000020; 121 static const PrivateFlagsType VALID_THREAD_ID = 0x00000040; 122 /** Whether or not the sc result is valid. */ 123 static const PrivateFlagsType VALID_EXTRA_DATA = 0x00000080; 124 125 /** These flags are *not* cleared when a Request object is reused 126 (assigned a new address). */ 127 static const PrivateFlagsType STICKY_PRIVATE_FLAGS = 128 VALID_CONTEXT_ID | VALID_THREAD_ID; 129 130 private: 131 /** 132 * The physical address of the request. Valid only if validPaddr 133 * is set. 134 */ 135 Addr _paddr; 136 137 /** 138 * The size of the request. This field must be set when vaddr or 139 * paddr is written via setVirt() or setPhys(), so it is always 140 * valid as long as one of the address fields is valid. 141 */ 142 int _size; 143 144 /** Flag structure for the request. */ 145 Flags _flags; 146 147 /** Private flags for field validity checking. */ 148 PrivateFlags privateFlags; 149 150 /** 151 * The time this request was started. Used to calculate 152 * latencies. This field is set to curTick any time paddr or vaddr 153 * is written. 154 */ 155 Tick _time; 156 157 /** The address space ID. */ 158 int _asid; 159 160 /** The virtual address of the request. */ 161 Addr _vaddr; 162 163 /** 164 * Extra data for the request, such as the return value of 165 * store conditional or the compare value for a CAS. */ 166 uint64_t _extraData; 167 168 /** The context ID (for statistics, typically). */ 169 int _contextId; 170 /** The thread ID (id within this CPU) */ 171 int _threadId; 172 173 /** program counter of initiating access; for tracing/debugging */ 174 Addr _pc; 175 176 public: 177 /** Minimal constructor. No fields are initialized. 178 * (Note that _flags and privateFlags are cleared by Flags 179 * default constructor.) 180 */ 181 Request() 182 {} 183 184 /** 185 * Constructor for physical (e.g. device) requests. Initializes 186 * just physical address, size, flags, and timestamp (to curTick). 187 * These fields are adequate to perform a request. 188 */ 189 Request(Addr paddr, int size, Flags flags) 190 { 191 setPhys(paddr, size, flags); 192 } 193 194 Request(Addr paddr, int size, Flags flags, Tick time) 195 { 196 setPhys(paddr, size, flags, time); 197 } 198 199 Request(int asid, Addr vaddr, int size, Flags flags, Addr pc, 200 int cid, ThreadID tid) 201 { 202 setVirt(asid, vaddr, size, flags, pc); 203 setThreadContext(cid, tid); 204 } 205 206 ~Request() {} // for FastAlloc 207 208 /** 209 * Set up CPU and thread numbers. 210 */ 211 void 212 setThreadContext(int context_id, ThreadID tid) 213 { 214 _contextId = context_id; 215 _threadId = tid; 216 privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID); 217 } 218 219 /** 220 * Set up a physical (e.g. device) request in a previously 221 * allocated Request object. 222 */ 223 void 224 setPhys(Addr paddr, int size, Flags flags, Tick time) 225 { 226 assert(size >= 0); 227 _paddr = paddr; 228 _size = size; 229 _time = time; 230 231 _flags.clear(~STICKY_FLAGS); 232 _flags.set(flags); 233 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 234 privateFlags.set(VALID_PADDR|VALID_SIZE); 235 } 236 237 void 238 setPhys(Addr paddr, int size, Flags flags) 239 { 240 setPhys(paddr, size, flags, curTick); 241 } 242 243 /** 244 * Set up a virtual (e.g., CPU) request in a previously 245 * allocated Request object. 246 */ 247 void 248 setVirt(int asid, Addr vaddr, int size, Flags flags, Addr pc) 249 { 250 assert(size >= 0); 251 _asid = asid; 252 _vaddr = vaddr; 253 _size = size; 254 _pc = pc; 255 _time = curTick; 256 257 _flags.clear(~STICKY_FLAGS); 258 _flags.set(flags); 259 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 260 privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC); 261 } 262 263 /** 264 * Set just the physical address. This should only be used to 265 * record the result of a translation, and thus the vaddr must be 266 * valid before this method is called. Otherwise, use setPhys() 267 * to guarantee that the size and flags are also set. 268 */ 269 void 270 setPaddr(Addr paddr) 271 { 272 assert(privateFlags.isSet(VALID_VADDR)); 273 _paddr = paddr; 274 privateFlags.set(VALID_PADDR); 275 } 276 277 /** 278 * Generate two requests as if this request had been split into two 279 * pieces. The original request can't have been translated already. 280 */ 281 void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2) 282 { 283 assert(privateFlags.isSet(VALID_VADDR)); 284 assert(privateFlags.noneSet(VALID_PADDR)); 285 assert(split_addr > _vaddr && split_addr < _vaddr + _size); 286 req1 = new Request; 287 *req1 = *this; 288 req2 = new Request; 289 *req2 = *this; 290 req1->_size = split_addr - _vaddr; 291 req2->_vaddr = split_addr; 292 req2->_size = _size - req1->_size; 293 } 294 295 /** 296 * Accessor for paddr. 297 */ 298 bool 299 hasPaddr() 300 { 301 return privateFlags.isSet(VALID_PADDR); 302 } 303 304 Addr 305 getPaddr() 306 { 307 assert(privateFlags.isSet(VALID_PADDR)); 308 return _paddr; 309 } 310 311 /** 312 * Accessor for size. 313 */ 314 bool 315 hasSize() 316 { 317 return privateFlags.isSet(VALID_SIZE); 318 } 319 320 int 321 getSize() 322 { 323 assert(privateFlags.isSet(VALID_SIZE)); 324 return _size; 325 } 326 327 /** Accessor for time. */ 328 Tick 329 time() const 330 { 331 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 332 return _time; 333 } 334 335 void 336 time(Tick time) 337 { 338 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 339 _time = time; 340 } 341 342 /** Accessor for flags. */ 343 Flags 344 getFlags() 345 { 346 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 347 return _flags; 348 } 349 350 /** Note that unlike other accessors, this function sets *specific 351 flags* (ORs them in); it does not assign its argument to the 352 _flags field. Thus this method should rightly be called 353 setFlags() and not just flags(). */ 354 void 355 setFlags(Flags flags) 356 { 357 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 358 _flags.set(flags); 359 } 360 361 /** Accessor function for vaddr.*/ 362 Addr 363 getVaddr() 364 { 365 assert(privateFlags.isSet(VALID_VADDR)); 366 return _vaddr; 367 } 368 369 /** Accessor function for asid.*/ 370 int 371 getAsid() 372 { 373 assert(privateFlags.isSet(VALID_VADDR)); 374 return _asid; 375 } 376 377 /** Accessor function for asi.*/ 378 uint8_t 379 getAsi() 380 { 381 assert(privateFlags.isSet(VALID_VADDR)); 382 return _flags & ASI_BITS; 383 } 384 385 /** Accessor function to check if sc result is valid. */ 386 bool 387 extraDataValid() 388 { 389 return privateFlags.isSet(VALID_EXTRA_DATA); 390 } 391 392 /** Accessor function for store conditional return value.*/ 393 uint64_t 394 getExtraData() const 395 { 396 assert(privateFlags.isSet(VALID_EXTRA_DATA)); 397 return _extraData; 398 } 399 400 /** Accessor function for store conditional return value.*/ 401 void 402 setExtraData(uint64_t extraData) 403 { 404 _extraData = extraData; 405 privateFlags.set(VALID_EXTRA_DATA); 406 } 407 408 bool 409 hasContextId() const 410 { 411 return privateFlags.isSet(VALID_CONTEXT_ID); 412 } 413 414 /** Accessor function for context ID.*/ 415 int 416 contextId() const 417 { 418 assert(privateFlags.isSet(VALID_CONTEXT_ID)); 419 return _contextId; 420 } 421 422 /** Accessor function for thread ID. */ 423 int 424 threadId() const 425 { 426 assert(privateFlags.isSet(VALID_THREAD_ID)); 427 return _threadId; 428 } 429 430 bool 431 hasPC() const 432 { 433 return privateFlags.isSet(VALID_PC); 434 } 435 436 /** Accessor function for pc.*/ 437 Addr 438 getPC() const 439 { 440 assert(privateFlags.isSet(VALID_PC)); 441 return _pc; 442 } 443 444 /** Accessor functions for flags. Note that these are for testing 445 only; setting flags should be done via setFlags(). */ 446 bool isUncacheable() const { return _flags.isSet(UNCACHEABLE); } 447 bool isInstFetch() const { return _flags.isSet(INST_FETCH); } 448 bool isPrefetch() const { return _flags.isSet(PREFETCH); } 449 bool isLLSC() const { return _flags.isSet(LLSC); } 450 bool isLocked() const { return _flags.isSet(LOCKED); } 451 bool isSwap() const { return _flags.isSet(MEM_SWAP|MEM_SWAP_COND); } 452 bool isCondSwap() const { return _flags.isSet(MEM_SWAP_COND); } 453 bool isMmapedIpr() const { return _flags.isSet(MMAPED_IPR); } 454 455 bool 456 isMisaligned() const 457 { 458 if (_flags.isSet(NO_ALIGN_FAULT)) 459 return false; 460 461 if ((_vaddr & 0x1)) 462 return true; 463 464 if (_flags.isSet(NO_HALF_WORD_ALIGN_FAULT)) 465 return false; 466 467 if ((_vaddr & 0x2)) 468 return true; 469 470 return false; 471 } 472}; 473 474#endif // __MEM_REQUEST_HH__ | 75 /** The request should ignore unaligned access faults */ 76 static const FlagsType NO_ALIGN_FAULT = 0x00020000; 77 /** The request should ignore unaligned access faults */ 78 static const FlagsType NO_HALF_WORD_ALIGN_FAULT = 0x00040000; 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 private: 106 typedef uint8_t PrivateFlagsType; 107 typedef ::Flags<PrivateFlagsType> PrivateFlags; 108 109 /** Whether or not the size is valid. */ 110 static const PrivateFlagsType VALID_SIZE = 0x00000001; 111 /** Whether or not paddr is valid (has been written yet). */ 112 static const PrivateFlagsType VALID_PADDR = 0x00000002; 113 /** Whether or not the vaddr & asid are valid. */ 114 static const PrivateFlagsType VALID_VADDR = 0x00000004; 115 /** Whether or not the pc is valid. */ 116 static const PrivateFlagsType VALID_PC = 0x00000010; 117 /** Whether or not the context ID is valid. */ 118 static const PrivateFlagsType VALID_CONTEXT_ID = 0x00000020; 119 static const PrivateFlagsType VALID_THREAD_ID = 0x00000040; 120 /** Whether or not the sc result is valid. */ 121 static const PrivateFlagsType VALID_EXTRA_DATA = 0x00000080; 122 123 /** These flags are *not* cleared when a Request object is reused 124 (assigned a new address). */ 125 static const PrivateFlagsType STICKY_PRIVATE_FLAGS = 126 VALID_CONTEXT_ID | VALID_THREAD_ID; 127 128 private: 129 /** 130 * The physical address of the request. Valid only if validPaddr 131 * is set. 132 */ 133 Addr _paddr; 134 135 /** 136 * The size of the request. This field must be set when vaddr or 137 * paddr is written via setVirt() or setPhys(), so it is always 138 * valid as long as one of the address fields is valid. 139 */ 140 int _size; 141 142 /** Flag structure for the request. */ 143 Flags _flags; 144 145 /** Private flags for field validity checking. */ 146 PrivateFlags privateFlags; 147 148 /** 149 * The time this request was started. Used to calculate 150 * latencies. This field is set to curTick any time paddr or vaddr 151 * is written. 152 */ 153 Tick _time; 154 155 /** The address space ID. */ 156 int _asid; 157 158 /** The virtual address of the request. */ 159 Addr _vaddr; 160 161 /** 162 * Extra data for the request, such as the return value of 163 * store conditional or the compare value for a CAS. */ 164 uint64_t _extraData; 165 166 /** The context ID (for statistics, typically). */ 167 int _contextId; 168 /** The thread ID (id within this CPU) */ 169 int _threadId; 170 171 /** program counter of initiating access; for tracing/debugging */ 172 Addr _pc; 173 174 public: 175 /** Minimal constructor. No fields are initialized. 176 * (Note that _flags and privateFlags are cleared by Flags 177 * default constructor.) 178 */ 179 Request() 180 {} 181 182 /** 183 * Constructor for physical (e.g. device) requests. Initializes 184 * just physical address, size, flags, and timestamp (to curTick). 185 * These fields are adequate to perform a request. 186 */ 187 Request(Addr paddr, int size, Flags flags) 188 { 189 setPhys(paddr, size, flags); 190 } 191 192 Request(Addr paddr, int size, Flags flags, Tick time) 193 { 194 setPhys(paddr, size, flags, time); 195 } 196 197 Request(int asid, Addr vaddr, int size, Flags flags, Addr pc, 198 int cid, ThreadID tid) 199 { 200 setVirt(asid, vaddr, size, flags, pc); 201 setThreadContext(cid, tid); 202 } 203 204 ~Request() {} // for FastAlloc 205 206 /** 207 * Set up CPU and thread numbers. 208 */ 209 void 210 setThreadContext(int context_id, ThreadID tid) 211 { 212 _contextId = context_id; 213 _threadId = tid; 214 privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID); 215 } 216 217 /** 218 * Set up a physical (e.g. device) request in a previously 219 * allocated Request object. 220 */ 221 void 222 setPhys(Addr paddr, int size, Flags flags, Tick time) 223 { 224 assert(size >= 0); 225 _paddr = paddr; 226 _size = size; 227 _time = time; 228 229 _flags.clear(~STICKY_FLAGS); 230 _flags.set(flags); 231 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 232 privateFlags.set(VALID_PADDR|VALID_SIZE); 233 } 234 235 void 236 setPhys(Addr paddr, int size, Flags flags) 237 { 238 setPhys(paddr, size, flags, curTick); 239 } 240 241 /** 242 * Set up a virtual (e.g., CPU) request in a previously 243 * allocated Request object. 244 */ 245 void 246 setVirt(int asid, Addr vaddr, int size, Flags flags, Addr pc) 247 { 248 assert(size >= 0); 249 _asid = asid; 250 _vaddr = vaddr; 251 _size = size; 252 _pc = pc; 253 _time = curTick; 254 255 _flags.clear(~STICKY_FLAGS); 256 _flags.set(flags); 257 privateFlags.clear(~STICKY_PRIVATE_FLAGS); 258 privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC); 259 } 260 261 /** 262 * Set just the physical address. This should only be used to 263 * record the result of a translation, and thus the vaddr must be 264 * valid before this method is called. Otherwise, use setPhys() 265 * to guarantee that the size and flags are also set. 266 */ 267 void 268 setPaddr(Addr paddr) 269 { 270 assert(privateFlags.isSet(VALID_VADDR)); 271 _paddr = paddr; 272 privateFlags.set(VALID_PADDR); 273 } 274 275 /** 276 * Generate two requests as if this request had been split into two 277 * pieces. The original request can't have been translated already. 278 */ 279 void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2) 280 { 281 assert(privateFlags.isSet(VALID_VADDR)); 282 assert(privateFlags.noneSet(VALID_PADDR)); 283 assert(split_addr > _vaddr && split_addr < _vaddr + _size); 284 req1 = new Request; 285 *req1 = *this; 286 req2 = new Request; 287 *req2 = *this; 288 req1->_size = split_addr - _vaddr; 289 req2->_vaddr = split_addr; 290 req2->_size = _size - req1->_size; 291 } 292 293 /** 294 * Accessor for paddr. 295 */ 296 bool 297 hasPaddr() 298 { 299 return privateFlags.isSet(VALID_PADDR); 300 } 301 302 Addr 303 getPaddr() 304 { 305 assert(privateFlags.isSet(VALID_PADDR)); 306 return _paddr; 307 } 308 309 /** 310 * Accessor for size. 311 */ 312 bool 313 hasSize() 314 { 315 return privateFlags.isSet(VALID_SIZE); 316 } 317 318 int 319 getSize() 320 { 321 assert(privateFlags.isSet(VALID_SIZE)); 322 return _size; 323 } 324 325 /** Accessor for time. */ 326 Tick 327 time() const 328 { 329 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 330 return _time; 331 } 332 333 void 334 time(Tick time) 335 { 336 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 337 _time = time; 338 } 339 340 /** Accessor for flags. */ 341 Flags 342 getFlags() 343 { 344 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 345 return _flags; 346 } 347 348 /** Note that unlike other accessors, this function sets *specific 349 flags* (ORs them in); it does not assign its argument to the 350 _flags field. Thus this method should rightly be called 351 setFlags() and not just flags(). */ 352 void 353 setFlags(Flags flags) 354 { 355 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR)); 356 _flags.set(flags); 357 } 358 359 /** Accessor function for vaddr.*/ 360 Addr 361 getVaddr() 362 { 363 assert(privateFlags.isSet(VALID_VADDR)); 364 return _vaddr; 365 } 366 367 /** Accessor function for asid.*/ 368 int 369 getAsid() 370 { 371 assert(privateFlags.isSet(VALID_VADDR)); 372 return _asid; 373 } 374 375 /** Accessor function for asi.*/ 376 uint8_t 377 getAsi() 378 { 379 assert(privateFlags.isSet(VALID_VADDR)); 380 return _flags & ASI_BITS; 381 } 382 383 /** Accessor function to check if sc result is valid. */ 384 bool 385 extraDataValid() 386 { 387 return privateFlags.isSet(VALID_EXTRA_DATA); 388 } 389 390 /** Accessor function for store conditional return value.*/ 391 uint64_t 392 getExtraData() const 393 { 394 assert(privateFlags.isSet(VALID_EXTRA_DATA)); 395 return _extraData; 396 } 397 398 /** Accessor function for store conditional return value.*/ 399 void 400 setExtraData(uint64_t extraData) 401 { 402 _extraData = extraData; 403 privateFlags.set(VALID_EXTRA_DATA); 404 } 405 406 bool 407 hasContextId() const 408 { 409 return privateFlags.isSet(VALID_CONTEXT_ID); 410 } 411 412 /** Accessor function for context ID.*/ 413 int 414 contextId() const 415 { 416 assert(privateFlags.isSet(VALID_CONTEXT_ID)); 417 return _contextId; 418 } 419 420 /** Accessor function for thread ID. */ 421 int 422 threadId() const 423 { 424 assert(privateFlags.isSet(VALID_THREAD_ID)); 425 return _threadId; 426 } 427 428 bool 429 hasPC() const 430 { 431 return privateFlags.isSet(VALID_PC); 432 } 433 434 /** Accessor function for pc.*/ 435 Addr 436 getPC() const 437 { 438 assert(privateFlags.isSet(VALID_PC)); 439 return _pc; 440 } 441 442 /** Accessor functions for flags. Note that these are for testing 443 only; setting flags should be done via setFlags(). */ 444 bool isUncacheable() const { return _flags.isSet(UNCACHEABLE); } 445 bool isInstFetch() const { return _flags.isSet(INST_FETCH); } 446 bool isPrefetch() const { return _flags.isSet(PREFETCH); } 447 bool isLLSC() const { return _flags.isSet(LLSC); } 448 bool isLocked() const { return _flags.isSet(LOCKED); } 449 bool isSwap() const { return _flags.isSet(MEM_SWAP|MEM_SWAP_COND); } 450 bool isCondSwap() const { return _flags.isSet(MEM_SWAP_COND); } 451 bool isMmapedIpr() const { return _flags.isSet(MMAPED_IPR); } 452 453 bool 454 isMisaligned() const 455 { 456 if (_flags.isSet(NO_ALIGN_FAULT)) 457 return false; 458 459 if ((_vaddr & 0x1)) 460 return true; 461 462 if (_flags.isSet(NO_HALF_WORD_ALIGN_FAULT)) 463 return false; 464 465 if ((_vaddr & 0x2)) 466 return true; 467 468 return false; 469 } 470}; 471 472#endif // __MEM_REQUEST_HH__ |