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