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