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 "sim/host.hh"
43 #include "sim/root.hh"
49 typedef Request* RequestPtr;
52 /** ASI information for this request if it exsits. */
53 const uint32_t ASI_BITS = 0x000FF;
54 /** The request is a Load locked/store conditional. */
55 const uint32_t LOCKED = 0x00100;
56 /** The virtual address is also the physical address. */
57 const uint32_t PHYSICAL = 0x00200;
58 /** The request is an ALPHA VPTE pal access (hw_ld). */
59 const uint32_t VPTE = 0x00400;
60 /** Use the alternate mode bits in ALPHA. */
61 const uint32_t ALTMODE = 0x00800;
62 /** The request is to an uncacheable address. */
63 const uint32_t UNCACHEABLE = 0x01000;
64 /** The request should not cause a page fault. */
65 const uint32_t NO_FAULT = 0x02000;
66 /** The request should be prefetched into the exclusive state. */
67 const uint32_t PF_EXCLUSIVE = 0x10000;
68 /** The request should be marked as LRU. */
69 const uint32_t EVICT_NEXT = 0x20000;
70 /** The request should ignore unaligned access faults */
71 const uint32_t NO_ALIGN_FAULT = 0x40000;
72 /** The request was an instruction read. */
73 const uint32_t INST_READ = 0x80000;
79 * The physical address of the request. Valid only if validPaddr
84 * The size of the request. This field must be set when vaddr or
85 * paddr is written via setVirt() or setPhys(), so it is always
86 * valid as long as one of the address fields is valid. */
89 /** Flag structure for the request. */
93 * The time this request was started. Used to calculate
94 * latencies. This field is set to curTick any time paddr or vaddr
98 /** The address space ID. */
101 /** This request is to a memory mapped register. */
104 /** The virtual address of the request. */
107 /** The return value of store conditional. */
110 /** The cpu number (for statistics, typically). */
112 /** The requesting thread id (for statistics, typically). */
115 /** program counter of initiating access; for tracing/debugging */
118 /** Whether or not paddr is valid (has been written yet). */
120 /** Whether or not the asid & vaddr are valid. */
122 /** Whether or not the sc result is valid. */
124 /** Whether or not the cpu number & thread ID are valid. */
125 bool validCpuAndThreadNums;
126 /** Whether or not the pc is valid. */
130 /** Minimal constructor. No fields are initialized. */
132 : validPaddr(false), validAsidVaddr(false),
133 validScResult(false), validCpuAndThreadNums(false), validPC(false)
137 * Constructor for physical (e.g. device) requests. Initializes
138 * just physical address, size, flags, and timestamp (to curTick).
139 * These fields are adequate to perform a request. */
140 Request(Addr _paddr, int _size, int _flags)
141 : validCpuAndThreadNums(false)
142 { setPhys(_paddr, _size, _flags); }
144 Request(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc,
145 int _cpuNum, int _threadNum)
147 setThreadContext(_cpuNum, _threadNum);
148 setVirt(_asid, _vaddr, _size, _flags, _pc);
152 * Set up CPU and thread numbers. */
153 void setThreadContext(int _cpuNum, int _threadNum)
156 threadNum = _threadNum;
157 validCpuAndThreadNums = true;
161 * Set up a physical (e.g. device) request in a previously
162 * allocated Request object. */
163 void setPhys(Addr _paddr, int _size, int _flags)
170 validAsidVaddr = false;
172 validScResult = false;
177 * Set up a virtual (e.g., CPU) request in a previously
178 * allocated Request object. */
179 void setVirt(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc)
188 validAsidVaddr = true;
190 validScResult = false;
194 /** Set just the physical address. This should only be used to
195 * record the result of a translation, and thus the vaddr must be
196 * valid before this method is called. Otherwise, use setPhys()
197 * to guarantee that the size and flags are also set.
199 void setPaddr(Addr _paddr)
201 assert(validAsidVaddr);
206 /** Accessor for paddr. */
207 Addr getPaddr() { assert(validPaddr); return paddr; }
209 /** Accessor for size. */
210 int getSize() { assert(validPaddr || validAsidVaddr); return size; }
211 /** Accessor for time. */
212 Tick getTime() { assert(validPaddr || validAsidVaddr); return time; }
214 /** Accessor for flags. */
215 uint32_t getFlags() { assert(validPaddr || validAsidVaddr); return flags; }
216 /** Accessor for paddr. */
217 void setFlags(uint32_t _flags)
218 { assert(validPaddr || validAsidVaddr); flags = _flags; }
220 /** Accessor function for vaddr.*/
221 Addr getVaddr() { assert(validAsidVaddr); return vaddr; }
223 /** Accessor function for asid.*/
224 int getAsid() { assert(validAsidVaddr); return asid; }
226 /** Accessor function for asi.*/
227 uint8_t getAsi() { assert(validAsidVaddr); return flags & ASI_BITS; }
229 /** Accessor function for asi.*/
230 void setAsi(uint8_t a)
231 { assert(validAsidVaddr); flags = (flags & ~ASI_BITS) | a; }
233 /** Accessor function for asi.*/
234 bool isMmapedIpr() { assert(validPaddr); return mmapedIpr; }
236 /** Accessor function for asi.*/
237 void setMmapedIpr(bool r) { assert(validAsidVaddr); mmapedIpr = r; }
239 /** Accessor function to check if sc result is valid. */
240 bool scResultValid() { return validScResult; }
241 /** Accessor function for store conditional return value.*/
242 uint64_t getScResult() { assert(validScResult); return scResult; }
243 /** Accessor function for store conditional return value.*/
244 void setScResult(uint64_t _scResult)
245 { scResult = _scResult; validScResult = true; }
247 /** Accessor function for cpu number.*/
248 int getCpuNum() { assert(validCpuAndThreadNums); return cpuNum; }
249 /** Accessor function for thread number.*/
250 int getThreadNum() { assert(validCpuAndThreadNums); return threadNum; }
252 /** Accessor function for pc.*/
253 Addr getPC() { assert(validPC); return pc; }
255 /** Accessor Function to Check Cacheability. */
256 bool isUncacheable() { return (getFlags() & UNCACHEABLE) != 0; }
258 bool isInstRead() { return (getFlags() & INST_READ) != 0; }
260 bool isLocked() { return (getFlags() & LOCKED) != 0; }
265 #endif // __MEM_REQUEST_HH__