Deleted Added
sdiff udiff text old ( 6103:549511187a5c ) new ( 6104:ca0915f8d86d )
full compact
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;

--- 39 unchanged lines hidden (view full) ---

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 is a Load locked/store conditional. */
63 static const FlagsType LLSC = 0x00000100;

--- 27 unchanged lines hidden (view full) ---

91 /** This request is for a memory swap. */
92 static const FlagsType MEM_SWAP = 0x00100000;
93 static const FlagsType MEM_SWAP_COND = 0x00200000;
94 /** The request should ignore unaligned access faults */
95 static const FlagsType NO_HALF_WORD_ALIGN_FAULT = 0x00400000;
96 /** This request is to a memory mapped register. */
97 static const FlagsType MMAPED_IPR = 0x00800000;
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_READ;
102
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
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. */

--- 28 unchanged lines hidden (view full) ---

182 Request(Addr paddr, int size, Flags flags)
183 {
184 setPhys(paddr, size, flags);
185 }
186
187 Request(int asid, Addr vaddr, int size, Flags flags, Addr pc,
188 int cid, int tid)
189 {
190 setVirt(asid, vaddr, size, flags, pc);
191 setThreadContext(cid, tid);
192 }
193
194 ~Request() {} // for FastAlloc
195
196 /**
197 * Set up CPU and thread numbers.
198 */
199 void
200 setThreadContext(int context_id, int thread_id)
201 {
202 _contextId = context_id;
203 _threadId = thread_id;
204 privateFlags.set(VALID_CONTEXT_ID|VALID_THREAD_ID);
205 }
206
207 /**
208 * Set up a physical (e.g. device) request in a previously
209 * allocated Request object.
210 */
211 void
212 setPhys(Addr _paddr, int _size, Flags _flags)
213 {
214 assert(_size >= 0);
215 paddr = _paddr;
216 size = _size;
217 time = curTick;
218
219 flags.clear(~STICKY_FLAGS);
220 flags.set(_flags);
221 privateFlags.clear(~STICKY_PRIVATE_FLAGS);
222 privateFlags.set(VALID_PADDR|VALID_SIZE);
223 }
224
225 /**
226 * Set up a virtual (e.g., CPU) request in a previously
227 * allocated Request object.
228 */
229 void
230 setVirt(int _asid, Addr _vaddr, int _size, Flags _flags, Addr _pc)
231 {
232 assert(_size >= 0);
233 asid = _asid;
234 vaddr = _vaddr;
235 size = _size;
236 flags = _flags;
237 pc = _pc;
238 time = curTick;
239
240 flags.clear(~STICKY_FLAGS);
241 flags.set(_flags);
242 privateFlags.clear(~STICKY_PRIVATE_FLAGS);
243 privateFlags.set(VALID_VADDR|VALID_SIZE|VALID_PC);
244 }
245
246 /**
247 * Set just the physical address. This should only be used to
248 * record the result of a translation, and thus the vaddr must be
249 * valid before this method is called. Otherwise, use setPhys()
250 * to guarantee that the size and flags are also set.
251 */
252 void
253 setPaddr(Addr _paddr)
254 {
255 assert(privateFlags.isSet(VALID_VADDR));
256 paddr = _paddr;
257 privateFlags.set(VALID_PADDR);
258 }
259
260 /**
261 * Generate two requests as if this request had been split into two
262 * pieces. The original request can't have been translated already.
263 */
264 void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2)
265 {
266 assert(privateFlags.isSet(VALID_VADDR));
267 assert(privateFlags.noneSet(VALID_PADDR));
268 assert(split_addr > vaddr && split_addr < vaddr + size);
269 req1 = new Request;
270 *req1 = *this;
271 req2 = new Request;
272 *req2 = *this;
273 req1->size = split_addr - vaddr;
274 req2->vaddr = split_addr;
275 req2->size = size - req1->size;
276 }
277
278 /**
279 * Accessor for paddr.
280 */
281 bool
282 hasPaddr()
283 {
284 return privateFlags.isSet(VALID_PADDR);
285 }
286
287 Addr
288 getPaddr()
289 {
290 assert(privateFlags.isSet(VALID_PADDR));
291 return paddr;
292 }
293
294 /**
295 * Accessor for size.
296 */
297 bool
298 hasSize()
299 {
300 return privateFlags.isSet(VALID_SIZE);
301 }
302
303 int
304 getSize()
305 {
306 assert(privateFlags.isSet(VALID_SIZE));
307 return size;
308 }
309
310 /** Accessor for time. */
311 Tick
312 getTime()
313 {
314 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
315 return time;
316 }
317
318 /** Accessor for flags. */
319 Flags
320 getFlags()
321 {
322 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
323 return flags;
324 }
325
326 void
327 setFlags(Flags _flags)
328 {
329 assert(privateFlags.isSet(VALID_PADDR|VALID_VADDR));
330 flags.set(_flags);
331 }
332
333 /** Accessor function for vaddr.*/
334 Addr
335 getVaddr()
336 {
337 assert(privateFlags.isSet(VALID_VADDR));
338 return vaddr;
339 }
340
341 /** Accessor function for asid.*/
342 int
343 getAsid()
344 {
345 assert(privateFlags.isSet(VALID_VADDR));
346 return asid;
347 }
348
349 /** Accessor function for asi.*/
350 uint8_t
351 getAsi()
352 {
353 assert(privateFlags.isSet(VALID_VADDR));
354 return flags & ASI_BITS;
355 }
356
357 /** Accessor function for MMAPED_IPR flag. */
358 bool
359 isMmapedIpr()
360 {
361 assert(privateFlags.isSet(VALID_PADDR));
362 return flags.isSet(MMAPED_IPR);
363 }
364
365 void
366 setMmapedIpr(bool r)
367 {
368 assert(VALID_VADDR);
369 flags.set(MMAPED_IPR);
370 }
371
372 /** Accessor function to check if sc result is valid. */
373 bool
374 extraDataValid()
375 {
376 return privateFlags.isSet(VALID_EXTRA_DATA);
377 }
378
379 /** Accessor function for store conditional return value.*/
380 uint64_t
381 getExtraData() const
382 {
383 assert(privateFlags.isSet(VALID_EXTRA_DATA));
384 return extraData;
385 }
386
387 /** Accessor function for store conditional return value.*/
388 void
389 setExtraData(uint64_t _extraData)
390 {
391 extraData = _extraData;
392 privateFlags.set(VALID_EXTRA_DATA);
393 }
394
395 bool
396 hasContextId() const
397 {
398 return privateFlags.isSet(VALID_CONTEXT_ID);
399 }
400
401 /** Accessor function for context ID.*/
402 int
403 contextId() const
404 {
405 assert(privateFlags.isSet(VALID_CONTEXT_ID));
406 return _contextId;
407 }
408
409 /** Accessor function for thread ID. */
410 int
411 threadId() const
412 {
413 assert(privateFlags.isSet(VALID_THREAD_ID));
414 return _threadId;
415 }
416
417 bool
418 hasPC() const
419 {
420 return privateFlags.isSet(VALID_PC);
421 }
422
423 /** Accessor function for pc.*/
424 Addr
425 getPC() const
426 {
427 assert(privateFlags.isSet(VALID_PC));
428 return pc;
429 }
430
431 /** Accessor Function to Check Cacheability. */
432 bool isUncacheable() const { return flags.isSet(UNCACHEABLE); }
433 bool isInstRead() const { return flags.isSet(INST_READ); }
434 bool isLLSC() const { return flags.isSet(LLSC); }
435 bool isLocked() const { return flags.isSet(LOCKED); }

--- 23 unchanged lines hidden ---