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