Merge zizzer:/bk/newmem
[gem5.git] / src / arch / mips / faults.hh
1 /*
2 * Copyright (c) 2003-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: Korey Sewell
29 */
30
31 #ifndef __MIPS_FAULTS_HH__
32 #define __MIPS_FAULTS_HH__
33
34 #include "sim/faults.hh"
35
36 // The design of the "name" and "vect" functions is in sim/faults.hh
37
38 namespace MipsISA
39 {
40
41 typedef const Addr FaultVect;
42
43 class MipsFault : public FaultBase
44 {
45 protected:
46 virtual bool skipFaultingInstruction() {return false;}
47 virtual bool setRestartAddress() {return true;}
48 public:
49 #if FULL_SYSTEM
50 void invoke(ThreadContext * tc);
51 #endif
52 virtual FaultVect vect() = 0;
53 virtual FaultStat & countStat() = 0;
54 };
55
56 class MachineCheckFault : public MipsFault
57 {
58 private:
59 static FaultName _name;
60 static FaultVect _vect;
61 static FaultStat _count;
62 public:
63 FaultName name() {return _name;}
64 FaultVect vect() {return _vect;}
65 FaultStat & countStat() {return _count;}
66 bool isMachineCheckFault() {return true;}
67 };
68
69 class AlignmentFault : public MipsFault
70 {
71 private:
72 static FaultName _name;
73 static FaultVect _vect;
74 static FaultStat _count;
75 public:
76 FaultName name() {return _name;}
77 FaultVect vect() {return _vect;}
78 FaultStat & countStat() {return _count;}
79 bool isAlignmentFault() {return true;}
80 };
81
82 #if !FULL_SYSTEM
83 class PageTableFault : public MipsFault
84 {
85 private:
86 Addr vaddr;
87 static FaultName _name;
88 static FaultVect _vect;
89 static FaultStat _count;
90 public:
91 PageTableFault(Addr va)
92 : vaddr(va) {}
93 FaultName name() {return _name;}
94 FaultVect vect() {return _vect;}
95 FaultStat & countStat() {return _count;}
96 void invoke(ThreadContext * tc);
97 };
98
99 static inline Fault genPageTableFault(Addr va)
100 {
101 return new PageTableFault(va);
102 }
103 #endif
104
105
106 static inline Fault genMachineCheckFault()
107 {
108 return new MachineCheckFault;
109 }
110
111 static inline Fault genAlignmentFault()
112 {
113 return new AlignmentFault;
114 }
115
116 class ResetFault : public MipsFault
117 {
118 private:
119 static FaultName _name;
120 static FaultVect _vect;
121 static FaultStat _count;
122 public:
123 FaultName name() {return _name;}
124 FaultVect vect() {return _vect;}
125 FaultStat & countStat() {return _count;}
126 };
127
128 class ArithmeticFault : public MipsFault
129 {
130 protected:
131 bool skipFaultingInstruction() {return true;}
132 private:
133 static FaultName _name;
134 static FaultVect _vect;
135 static FaultStat _count;
136 public:
137 FaultName name() {return _name;}
138 FaultVect vect() {return _vect;}
139 FaultStat & countStat() {return _count;}
140 #if FULL_SYSTEM
141 void invoke(ThreadContext * tc);
142 #endif
143 };
144
145 class InterruptFault : public MipsFault
146 {
147 protected:
148 bool setRestartAddress() {return false;}
149 private:
150 static FaultName _name;
151 static FaultVect _vect;
152 static FaultStat _count;
153 public:
154 FaultName name() {return _name;}
155 FaultVect vect() {return _vect;}
156 FaultStat & countStat() {return _count;}
157 };
158
159 class NDtbMissFault : public MipsFault
160 {
161 private:
162 static FaultName _name;
163 static FaultVect _vect;
164 static FaultStat _count;
165 public:
166 FaultName name() {return _name;}
167 FaultVect vect() {return _vect;}
168 FaultStat & countStat() {return _count;}
169 };
170
171 class PDtbMissFault : public MipsFault
172 {
173 private:
174 static FaultName _name;
175 static FaultVect _vect;
176 static FaultStat _count;
177 public:
178 FaultName name() {return _name;}
179 FaultVect vect() {return _vect;}
180 FaultStat & countStat() {return _count;}
181 };
182
183 class DtbPageFault : public MipsFault
184 {
185 private:
186 static FaultName _name;
187 static FaultVect _vect;
188 static FaultStat _count;
189 public:
190 FaultName name() {return _name;}
191 FaultVect vect() {return _vect;}
192 FaultStat & countStat() {return _count;}
193 };
194
195 class DtbAcvFault : public MipsFault
196 {
197 private:
198 static FaultName _name;
199 static FaultVect _vect;
200 static FaultStat _count;
201 public:
202 FaultName name() {return _name;}
203 FaultVect vect() {return _vect;}
204 FaultStat & countStat() {return _count;}
205 };
206
207 class ItbMissFault : public MipsFault
208 {
209 private:
210 static FaultName _name;
211 static FaultVect _vect;
212 static FaultStat _count;
213 public:
214 FaultName name() {return _name;}
215 FaultVect vect() {return _vect;}
216 FaultStat & countStat() {return _count;}
217 };
218
219 class ItbPageFault : public MipsFault
220 {
221 private:
222 static FaultName _name;
223 static FaultVect _vect;
224 static FaultStat _count;
225 public:
226 FaultName name() {return _name;}
227 FaultVect vect() {return _vect;}
228 FaultStat & countStat() {return _count;}
229 };
230
231 class ItbAcvFault : public MipsFault
232 {
233 private:
234 static FaultName _name;
235 static FaultVect _vect;
236 static FaultStat _count;
237 public:
238 FaultName name() {return _name;}
239 FaultVect vect() {return _vect;}
240 FaultStat & countStat() {return _count;}
241 };
242
243 class UnimplementedOpcodeFault : public MipsFault
244 {
245 private:
246 static FaultName _name;
247 static FaultVect _vect;
248 static FaultStat _count;
249 public:
250 FaultName name() {return _name;}
251 FaultVect vect() {return _vect;}
252 FaultStat & countStat() {return _count;}
253 };
254
255 class FloatEnableFault : public MipsFault
256 {
257 private:
258 static FaultName _name;
259 static FaultVect _vect;
260 static FaultStat _count;
261 public:
262 FaultName name() {return _name;}
263 FaultVect vect() {return _vect;}
264 FaultStat & countStat() {return _count;}
265 };
266
267 class PalFault : public MipsFault
268 {
269 protected:
270 bool skipFaultingInstruction() {return true;}
271 private:
272 static FaultName _name;
273 static FaultVect _vect;
274 static FaultStat _count;
275 public:
276 FaultName name() {return _name;}
277 FaultVect vect() {return _vect;}
278 FaultStat & countStat() {return _count;}
279 };
280
281 class IntegerOverflowFault : public MipsFault
282 {
283 private:
284 static FaultName _name;
285 static FaultVect _vect;
286 static FaultStat _count;
287 public:
288 FaultName name() {return _name;}
289 FaultVect vect() {return _vect;}
290 FaultStat & countStat() {return _count;}
291 };
292
293 } // MipsISA namespace
294
295 #endif // __FAULTS_HH__