request.hh (3170:37fd1e73f836) request.hh (3804:fa7a01dddc7a)
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 "sim/host.hh"
43#include "sim/root.hh"
44
45#include <cassert>
46
47class Request;
48
49typedef Request* RequestPtr;
50
51
52/** The request is a Load locked/store conditional. */
53const unsigned LOCKED = 0x001;
54/** The virtual address is also the physical address. */
55const unsigned PHYSICAL = 0x002;
56/** The request is an ALPHA VPTE pal access (hw_ld). */
57const unsigned VPTE = 0x004;
58/** Use the alternate mode bits in ALPHA. */
59const unsigned ALTMODE = 0x008;
60/** The request is to an uncacheable address. */
61const unsigned UNCACHEABLE = 0x010;
62/** The request should not cause a page fault. */
63const unsigned NO_FAULT = 0x020;
64/** The request should be prefetched into the exclusive state. */
65const unsigned PF_EXCLUSIVE = 0x100;
66/** The request should be marked as LRU. */
67const unsigned EVICT_NEXT = 0x200;
68/** The request should ignore unaligned access faults */
69const unsigned NO_ALIGN_FAULT = 0x400;
70/** The request was an instruction read. */
71const unsigned INST_READ = 0x800;
72
73class Request
74{
75 private:
76 /**
77 * The physical address of the request. Valid only if validPaddr
78 * is set. */
79 Addr paddr;
80
81 /**
82 * The size of the request. This field must be set when vaddr or
83 * paddr is written via setVirt() or setPhys(), so it is always
84 * valid as long as one of the address fields is valid. */
85 int size;
86
87 /** Flag structure for the request. */
88 uint32_t flags;
89
90 /**
91 * The time this request was started. Used to calculate
92 * latencies. This field is set to curTick any time paddr or vaddr
93 * is written. */
94 Tick time;
95
96 /** The address space ID. */
97 int asid;
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 "sim/host.hh"
43#include "sim/root.hh"
44
45#include <cassert>
46
47class Request;
48
49typedef Request* RequestPtr;
50
51
52/** The request is a Load locked/store conditional. */
53const unsigned LOCKED = 0x001;
54/** The virtual address is also the physical address. */
55const unsigned PHYSICAL = 0x002;
56/** The request is an ALPHA VPTE pal access (hw_ld). */
57const unsigned VPTE = 0x004;
58/** Use the alternate mode bits in ALPHA. */
59const unsigned ALTMODE = 0x008;
60/** The request is to an uncacheable address. */
61const unsigned UNCACHEABLE = 0x010;
62/** The request should not cause a page fault. */
63const unsigned NO_FAULT = 0x020;
64/** The request should be prefetched into the exclusive state. */
65const unsigned PF_EXCLUSIVE = 0x100;
66/** The request should be marked as LRU. */
67const unsigned EVICT_NEXT = 0x200;
68/** The request should ignore unaligned access faults */
69const unsigned NO_ALIGN_FAULT = 0x400;
70/** The request was an instruction read. */
71const unsigned INST_READ = 0x800;
72
73class Request
74{
75 private:
76 /**
77 * The physical address of the request. Valid only if validPaddr
78 * is set. */
79 Addr paddr;
80
81 /**
82 * The size of the request. This field must be set when vaddr or
83 * paddr is written via setVirt() or setPhys(), so it is always
84 * valid as long as one of the address fields is valid. */
85 int size;
86
87 /** Flag structure for the request. */
88 uint32_t flags;
89
90 /**
91 * The time this request was started. Used to calculate
92 * latencies. This field is set to curTick any time paddr or vaddr
93 * is written. */
94 Tick time;
95
96 /** The address space ID. */
97 int asid;
98 /** The ASI is any -- SPARC ONLY */
99 int asi;
100 /** This request is to a memory mapped register. */
101 bool mmapedReg;
102
98 /** The virtual address of the request. */
99 Addr vaddr;
100
101 /** The return value of store conditional. */
102 uint64_t scResult;
103
104 /** The cpu number (for statistics, typically). */
105 int cpuNum;
106 /** The requesting thread id (for statistics, typically). */
107 int threadNum;
108
109 /** program counter of initiating access; for tracing/debugging */
110 Addr pc;
111
112 /** Whether or not paddr is valid (has been written yet). */
113 bool validPaddr;
114 /** Whether or not the asid & vaddr are valid. */
115 bool validAsidVaddr;
116 /** Whether or not the sc result is valid. */
117 bool validScResult;
118 /** Whether or not the cpu number & thread ID are valid. */
119 bool validCpuAndThreadNums;
120 /** Whether or not the pc is valid. */
121 bool validPC;
122
123 public:
124 /** Minimal constructor. No fields are initialized. */
125 Request()
126 : validPaddr(false), validAsidVaddr(false),
127 validScResult(false), validCpuAndThreadNums(false), validPC(false)
128 {}
129
130 /**
131 * Constructor for physical (e.g. device) requests. Initializes
132 * just physical address, size, flags, and timestamp (to curTick).
133 * These fields are adequate to perform a request. */
134 Request(Addr _paddr, int _size, int _flags)
135 : validCpuAndThreadNums(false)
136 { setPhys(_paddr, _size, _flags); }
137
138 Request(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc,
139 int _cpuNum, int _threadNum)
140 {
141 setThreadContext(_cpuNum, _threadNum);
142 setVirt(_asid, _vaddr, _size, _flags, _pc);
143 }
144
145 /**
146 * Set up CPU and thread numbers. */
147 void setThreadContext(int _cpuNum, int _threadNum)
148 {
149 cpuNum = _cpuNum;
150 threadNum = _threadNum;
151 validCpuAndThreadNums = true;
152 }
153
154 /**
155 * Set up a physical (e.g. device) request in a previously
156 * allocated Request object. */
157 void setPhys(Addr _paddr, int _size, int _flags)
158 {
159 paddr = _paddr;
160 size = _size;
161 flags = _flags;
162 time = curTick;
163 validPaddr = true;
164 validAsidVaddr = false;
165 validPC = false;
166 validScResult = false;
167 }
168
169 /**
170 * Set up a virtual (e.g., CPU) request in a previously
171 * allocated Request object. */
172 void setVirt(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc)
173 {
174 asid = _asid;
175 vaddr = _vaddr;
176 size = _size;
177 flags = _flags;
178 pc = _pc;
179 time = curTick;
180 validPaddr = false;
181 validAsidVaddr = true;
182 validPC = true;
183 validScResult = false;
184 }
185
186 /** Set just the physical address. This should only be used to
187 * record the result of a translation, and thus the vaddr must be
188 * valid before this method is called. Otherwise, use setPhys()
189 * to guarantee that the size and flags are also set.
190 */
191 void setPaddr(Addr _paddr)
192 {
193 assert(validAsidVaddr);
194 paddr = _paddr;
195 validPaddr = true;
196 }
197
198 /** Accessor for paddr. */
199 Addr getPaddr() { assert(validPaddr); return paddr; }
200
201 /** Accessor for size. */
202 int getSize() { assert(validPaddr || validAsidVaddr); return size; }
203 /** Accessor for time. */
204 Tick getTime() { assert(validPaddr || validAsidVaddr); return time; }
205
206 /** Accessor for flags. */
207 uint32_t getFlags() { assert(validPaddr || validAsidVaddr); return flags; }
208 /** Accessor for paddr. */
209 void setFlags(uint32_t _flags)
210 { assert(validPaddr || validAsidVaddr); flags = _flags; }
211
212 /** Accessor function for vaddr.*/
213 Addr getVaddr() { assert(validAsidVaddr); return vaddr; }
214
215 /** Accessor function for asid.*/
216 int getAsid() { assert(validAsidVaddr); return asid; }
217
103 /** The virtual address of the request. */
104 Addr vaddr;
105
106 /** The return value of store conditional. */
107 uint64_t scResult;
108
109 /** The cpu number (for statistics, typically). */
110 int cpuNum;
111 /** The requesting thread id (for statistics, typically). */
112 int threadNum;
113
114 /** program counter of initiating access; for tracing/debugging */
115 Addr pc;
116
117 /** Whether or not paddr is valid (has been written yet). */
118 bool validPaddr;
119 /** Whether or not the asid & vaddr are valid. */
120 bool validAsidVaddr;
121 /** Whether or not the sc result is valid. */
122 bool validScResult;
123 /** Whether or not the cpu number & thread ID are valid. */
124 bool validCpuAndThreadNums;
125 /** Whether or not the pc is valid. */
126 bool validPC;
127
128 public:
129 /** Minimal constructor. No fields are initialized. */
130 Request()
131 : validPaddr(false), validAsidVaddr(false),
132 validScResult(false), validCpuAndThreadNums(false), validPC(false)
133 {}
134
135 /**
136 * Constructor for physical (e.g. device) requests. Initializes
137 * just physical address, size, flags, and timestamp (to curTick).
138 * These fields are adequate to perform a request. */
139 Request(Addr _paddr, int _size, int _flags)
140 : validCpuAndThreadNums(false)
141 { setPhys(_paddr, _size, _flags); }
142
143 Request(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc,
144 int _cpuNum, int _threadNum)
145 {
146 setThreadContext(_cpuNum, _threadNum);
147 setVirt(_asid, _vaddr, _size, _flags, _pc);
148 }
149
150 /**
151 * Set up CPU and thread numbers. */
152 void setThreadContext(int _cpuNum, int _threadNum)
153 {
154 cpuNum = _cpuNum;
155 threadNum = _threadNum;
156 validCpuAndThreadNums = true;
157 }
158
159 /**
160 * Set up a physical (e.g. device) request in a previously
161 * allocated Request object. */
162 void setPhys(Addr _paddr, int _size, int _flags)
163 {
164 paddr = _paddr;
165 size = _size;
166 flags = _flags;
167 time = curTick;
168 validPaddr = true;
169 validAsidVaddr = false;
170 validPC = false;
171 validScResult = false;
172 }
173
174 /**
175 * Set up a virtual (e.g., CPU) request in a previously
176 * allocated Request object. */
177 void setVirt(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc)
178 {
179 asid = _asid;
180 vaddr = _vaddr;
181 size = _size;
182 flags = _flags;
183 pc = _pc;
184 time = curTick;
185 validPaddr = false;
186 validAsidVaddr = true;
187 validPC = true;
188 validScResult = false;
189 }
190
191 /** Set just the physical address. This should only be used to
192 * record the result of a translation, and thus the vaddr must be
193 * valid before this method is called. Otherwise, use setPhys()
194 * to guarantee that the size and flags are also set.
195 */
196 void setPaddr(Addr _paddr)
197 {
198 assert(validAsidVaddr);
199 paddr = _paddr;
200 validPaddr = true;
201 }
202
203 /** Accessor for paddr. */
204 Addr getPaddr() { assert(validPaddr); return paddr; }
205
206 /** Accessor for size. */
207 int getSize() { assert(validPaddr || validAsidVaddr); return size; }
208 /** Accessor for time. */
209 Tick getTime() { assert(validPaddr || validAsidVaddr); return time; }
210
211 /** Accessor for flags. */
212 uint32_t getFlags() { assert(validPaddr || validAsidVaddr); return flags; }
213 /** Accessor for paddr. */
214 void setFlags(uint32_t _flags)
215 { assert(validPaddr || validAsidVaddr); flags = _flags; }
216
217 /** Accessor function for vaddr.*/
218 Addr getVaddr() { assert(validAsidVaddr); return vaddr; }
219
220 /** Accessor function for asid.*/
221 int getAsid() { assert(validAsidVaddr); return asid; }
222
223 /** Accessor function for asi.*/
224 int getAsi() { assert(validAsidVaddr); return asi; }
225 /** Accessor function for asi.*/
226 void setAsi(int a) { assert(validAsidVaddr); asi = a; }
227
228 /** Accessor function for asi.*/
229 bool getMmapedReg() { assert(validPaddr); return mmapedReg; }
230 /** Accessor function for asi.*/
231 void setMmapedReg(bool r) { assert(validPaddr); mmapedReg = r; }
232
218 /** Accessor function to check if sc result is valid. */
219 bool scResultValid() { return validScResult; }
220 /** Accessor function for store conditional return value.*/
221 uint64_t getScResult() { assert(validScResult); return scResult; }
222 /** Accessor function for store conditional return value.*/
223 void setScResult(uint64_t _scResult)
224 { scResult = _scResult; validScResult = true; }
225
226 /** Accessor function for cpu number.*/
227 int getCpuNum() { assert(validCpuAndThreadNums); return cpuNum; }
228 /** Accessor function for thread number.*/
229 int getThreadNum() { assert(validCpuAndThreadNums); return threadNum; }
230
231 /** Accessor function for pc.*/
232 Addr getPC() { assert(validPC); return pc; }
233
234 /** Accessor Function to Check Cacheability. */
235 bool isUncacheable() { return (getFlags() & UNCACHEABLE) != 0; }
236
237 bool isInstRead() { return (getFlags() & INST_READ) != 0; }
238
239 bool isLocked() { return (getFlags() & LOCKED) != 0; }
240
241 friend class Packet;
242};
243
244#endif // __MEM_REQUEST_HH__
233 /** Accessor function to check if sc result is valid. */
234 bool scResultValid() { return validScResult; }
235 /** Accessor function for store conditional return value.*/
236 uint64_t getScResult() { assert(validScResult); return scResult; }
237 /** Accessor function for store conditional return value.*/
238 void setScResult(uint64_t _scResult)
239 { scResult = _scResult; validScResult = true; }
240
241 /** Accessor function for cpu number.*/
242 int getCpuNum() { assert(validCpuAndThreadNums); return cpuNum; }
243 /** Accessor function for thread number.*/
244 int getThreadNum() { assert(validCpuAndThreadNums); return threadNum; }
245
246 /** Accessor function for pc.*/
247 Addr getPC() { assert(validPC); return pc; }
248
249 /** Accessor Function to Check Cacheability. */
250 bool isUncacheable() { return (getFlags() & UNCACHEABLE) != 0; }
251
252 bool isInstRead() { return (getFlags() & INST_READ) != 0; }
253
254 bool isLocked() { return (getFlags() & LOCKED) != 0; }
255
256 friend class Packet;
257};
258
259#endif // __MEM_REQUEST_HH__