2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
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.
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.
28 * Authors: Ron Dreslinski
35 * Declaration of a request, the overall memory request consisting of
36 the parts of the request that are persistent throughout the transaction.
39 #ifndef __MEM_REQUEST_HH__
40 #define __MEM_REQUEST_HH__
42 #include "base/fast_alloc.hh"
43 #include "sim/host.hh"
44 #include "sim/core.hh"
50 typedef Request* RequestPtr;
53 /** ASI information for this request if it exsits. */
54 const uint32_t ASI_BITS = 0x000FF;
55 /** The request is a Load locked/store conditional. */
56 const uint32_t LOCKED = 0x00100;
57 /** The virtual address is also the physical address. */
58 const uint32_t PHYSICAL = 0x00200;
59 /** The request is an ALPHA VPTE pal access (hw_ld). */
60 const uint32_t VPTE = 0x00400;
61 /** Use the alternate mode bits in ALPHA. */
62 const uint32_t ALTMODE = 0x00800;
63 /** The request is to an uncacheable address. */
64 const uint32_t UNCACHEABLE = 0x01000;
65 /** The request should not cause a page fault. */
66 const uint32_t NO_FAULT = 0x02000;
67 /** The request should be prefetched into the exclusive state. */
68 const uint32_t PF_EXCLUSIVE = 0x10000;
69 /** The request should be marked as LRU. */
70 const uint32_t EVICT_NEXT = 0x20000;
71 /** The request should ignore unaligned access faults */
72 const uint32_t NO_ALIGN_FAULT = 0x40000;
73 /** The request was an instruction read. */
74 const uint32_t INST_READ = 0x80000;
75 /** This request is for a memory swap. */
76 const uint32_t MEM_SWAP = 0x100000;
77 const uint32_t MEM_SWAP_COND = 0x200000;
80 class Request : public FastAlloc
84 * The physical address of the request. Valid only if validPaddr
89 * The size of the request. This field must be set when vaddr or
90 * paddr is written via setVirt() or setPhys(), so it is always
91 * valid as long as one of the address fields is valid. */
94 /** Flag structure for the request. */
98 * The time this request was started. Used to calculate
99 * latencies. This field is set to curTick any time paddr or vaddr
103 /** The address space ID. */
106 /** This request is to a memory mapped register. */
109 /** The virtual address of the request. */
112 /** Extra data for the request, such as the return value of
113 * store conditional or the compare value for a CAS. */
116 /** The cpu number (for statistics, typically). */
118 /** The requesting thread id (for statistics, typically). */
121 /** program counter of initiating access; for tracing/debugging */
124 /** Whether or not paddr is valid (has been written yet). */
126 /** Whether or not the asid & vaddr are valid. */
128 /** Whether or not the sc result is valid. */
130 /** Whether or not the cpu number & thread ID are valid. */
131 bool validCpuAndThreadNums;
132 /** Whether or not the pc is valid. */
136 /** Minimal constructor. No fields are initialized. */
138 : validPaddr(false), validAsidVaddr(false),
139 validExData(false), validCpuAndThreadNums(false), validPC(false)
143 * Constructor for physical (e.g. device) requests. Initializes
144 * just physical address, size, flags, and timestamp (to curTick).
145 * These fields are adequate to perform a request. */
146 Request(Addr _paddr, int _size, int _flags)
147 : validCpuAndThreadNums(false)
148 { setPhys(_paddr, _size, _flags); }
150 Request(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc,
151 int _cpuNum, int _threadNum)
153 setThreadContext(_cpuNum, _threadNum);
154 setVirt(_asid, _vaddr, _size, _flags, _pc);
157 ~Request() {} // for FastAlloc
160 * Set up CPU and thread numbers. */
161 void setThreadContext(int _cpuNum, int _threadNum)
164 threadNum = _threadNum;
165 validCpuAndThreadNums = true;
169 * Set up a physical (e.g. device) request in a previously
170 * allocated Request object. */
171 void setPhys(Addr _paddr, int _size, int _flags)
178 validAsidVaddr = false;
185 * Set up a virtual (e.g., CPU) request in a previously
186 * allocated Request object. */
187 void setVirt(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc)
196 validAsidVaddr = true;
202 /** Set just the physical address. This should only be used to
203 * record the result of a translation, and thus the vaddr must be
204 * valid before this method is called. Otherwise, use setPhys()
205 * to guarantee that the size and flags are also set.
207 void setPaddr(Addr _paddr)
209 assert(validAsidVaddr);
214 /** Accessor for paddr. */
215 Addr getPaddr() { assert(validPaddr); return paddr; }
217 /** Accessor for size. */
218 int getSize() { assert(validPaddr || validAsidVaddr); return size; }
219 /** Accessor for time. */
220 Tick getTime() { assert(validPaddr || validAsidVaddr); return time; }
222 /** Accessor for flags. */
223 uint32_t getFlags() { assert(validPaddr || validAsidVaddr); return flags; }
224 /** Accessor for paddr. */
225 void setFlags(uint32_t _flags)
226 { assert(validPaddr || validAsidVaddr); flags = _flags; }
228 /** Accessor function for vaddr.*/
229 Addr getVaddr() { assert(validAsidVaddr); return vaddr; }
231 /** Accessor function for asid.*/
232 int getAsid() { assert(validAsidVaddr); return asid; }
234 /** Accessor function for asi.*/
235 uint8_t getAsi() { assert(validAsidVaddr); return flags & ASI_BITS; }
237 /** Accessor function for asi.*/
238 void setAsi(uint8_t a)
239 { assert(validAsidVaddr); flags = (flags & ~ASI_BITS) | a; }
241 /** Accessor function for asi.*/
242 bool isMmapedIpr() { assert(validPaddr); return mmapedIpr; }
244 /** Accessor function for asi.*/
245 void setMmapedIpr(bool r) { assert(validAsidVaddr); mmapedIpr = r; }
247 /** Accessor function to check if sc result is valid. */
248 bool extraDataValid() { return validExData; }
249 /** Accessor function for store conditional return value.*/
250 uint64_t getExtraData() { assert(validExData); return extraData; }
251 /** Accessor function for store conditional return value.*/
252 void setExtraData(uint64_t _extraData)
253 { extraData = _extraData; validExData = true; }
255 /** Accessor function for cpu number.*/
256 int getCpuNum() { assert(validCpuAndThreadNums); return cpuNum; }
257 /** Accessor function for thread number.*/
258 int getThreadNum() { assert(validCpuAndThreadNums); return threadNum; }
260 /** Accessor function for pc.*/
261 Addr getPC() { assert(validPC); return pc; }
263 /** Accessor Function to Check Cacheability. */
264 bool isUncacheable() { return (getFlags() & UNCACHEABLE) != 0; }
266 bool isInstRead() { return (getFlags() & INST_READ) != 0; }
268 bool isLocked() { return (getFlags() & LOCKED) != 0; }
270 bool isSwap() { return (getFlags() & MEM_SWAP ||
271 getFlags() & MEM_SWAP_COND); }
273 bool isCondSwap() { return (getFlags() & MEM_SWAP_COND) != 0; }
279 #endif // __MEM_REQUEST_HH__