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