2 * Copyright (c) 2003-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.
32 #ifndef __ALPHA_FAULTS_HH__
33 #define __ALPHA_FAULTS_HH__
35 #include "sim/faults.hh"
37 // The design of the "name" and "vect" functions is in sim/faults.hh
42 typedef const uint32_t TrapType;
43 typedef const uint32_t FaultPriority;
45 class SparcFault : public FaultBase
49 void invoke(ThreadContext * tc);
51 virtual TrapType trapType() = 0;
52 virtual FaultPriority priority() = 0;
53 virtual FaultStat & countStat() = 0;
56 class InternalProcessorError : public SparcFault
59 static FaultName _name;
60 static TrapType _trapType;
61 static FaultPriority _priority;
62 static FaultStat _count;
64 FaultName name() {return _name;}
65 TrapType trapType() {return _trapType;}
66 FaultPriority priority() {return _priority;}
67 FaultStat & countStat() {return _count;}
68 bool isMachineCheckFault() {return true;}
71 class MemAddressNotAligned : public SparcFault
74 static FaultName _name;
75 static TrapType _trapType;
76 static FaultPriority _priority;
77 static FaultStat _count;
79 FaultName name() {return _name;}
80 TrapType trapType() {return _trapType;}
81 FaultPriority priority() {return _priority;}
82 FaultStat & countStat() {return _count;}
83 bool isAlignmentFault() {return true;}
86 static inline Fault genMachineCheckFault()
88 return new InternalProcessorError;
91 static inline Fault genAlignmentFault()
93 return new MemAddressNotAligned;
96 class PowerOnReset : public SparcFault
99 static FaultName _name;
100 static TrapType _trapType;
101 static FaultPriority _priority;
102 static FaultStat _count;
104 FaultName name() {return _name;}
105 TrapType trapType() {return _trapType;}
106 FaultPriority priority() {return _priority;}
107 FaultStat & countStat() {return _count;}
110 class WatchDogReset : public SparcFault
113 static FaultName _name;
114 static TrapType _trapType;
115 static FaultPriority _priority;
116 static FaultStat _count;
118 FaultName name() {return _name;}
119 TrapType trapType() {return _trapType;}
120 FaultPriority priority() {return _priority;}
121 FaultStat & countStat() {return _count;}
124 class ExternallyInitiatedReset : public SparcFault
127 static FaultName _name;
128 static TrapType _trapType;
129 static FaultPriority _priority;
130 static FaultStat _count;
132 FaultName name() {return _name;}
133 TrapType trapType() {return _trapType;}
134 FaultPriority priority() {return _priority;}
135 FaultStat & countStat() {return _count;}
138 class SoftwareInitiatedReset : public SparcFault
141 static FaultName _name;
142 static TrapType _trapType;
143 static FaultPriority _priority;
144 static FaultStat _count;
146 FaultName name() {return _name;}
147 TrapType trapType() {return _trapType;}
148 FaultPriority priority() {return _priority;}
149 FaultStat & countStat() {return _count;}
152 class REDStateException : public SparcFault
155 static FaultName _name;
156 static TrapType _trapType;
157 static FaultPriority _priority;
158 static FaultStat _count;
160 FaultName name() {return _name;}
161 TrapType trapType() {return _trapType;}
162 FaultPriority priority() {return _priority;}
163 FaultStat & countStat() {return _count;}
166 class InstructionAccessException : public SparcFault
169 static FaultName _name;
170 static TrapType _trapType;
171 static FaultPriority _priority;
172 static FaultStat _count;
174 FaultName name() {return _name;}
175 TrapType trapType() {return _trapType;}
176 FaultPriority priority() {return _priority;}
177 FaultStat & countStat() {return _count;}
180 class InstructionAccessMMUMiss : public SparcFault
183 static FaultName _name;
184 static TrapType _trapType;
185 static FaultPriority _priority;
186 static FaultStat _count;
188 FaultName name() {return _name;}
189 TrapType trapType() {return _trapType;}
190 FaultPriority priority() {return _priority;}
191 FaultStat & countStat() {return _count;}
194 class InstructionAccessError : public SparcFault
197 static FaultName _name;
198 static TrapType _trapType;
199 static FaultPriority _priority;
200 static FaultStat _count;
202 FaultName name() {return _name;}
203 TrapType trapType() {return _trapType;}
204 FaultPriority priority() {return _priority;}
205 FaultStat & countStat() {return _count;}
208 class IllegalInstruction : public SparcFault
211 static FaultName _name;
212 static TrapType _trapType;
213 static FaultPriority _priority;
214 static FaultStat _count;
216 FaultName name() {return _name;}
217 TrapType trapType() {return _trapType;}
218 FaultPriority priority() {return _priority;}
219 FaultStat & countStat() {return _count;}
222 class PrivilegedOpcode : public SparcFault
225 static FaultName _name;
226 static TrapType _trapType;
227 static FaultPriority _priority;
228 static FaultStat _count;
230 FaultName name() {return _name;}
231 TrapType trapType() {return _trapType;}
232 FaultPriority priority() {return _priority;}
233 FaultStat & countStat() {return _count;}
236 class UnimplementedLDD : public SparcFault
239 static FaultName _name;
240 static TrapType _trapType;
241 static FaultPriority _priority;
242 static FaultStat _count;
244 FaultName name() {return _name;}
245 TrapType trapType() {return _trapType;}
246 FaultPriority priority() {return _priority;}
247 FaultStat & countStat() {return _count;}
250 class UnimplementedSTD : public SparcFault
253 static FaultName _name;
254 static TrapType _trapType;
255 static FaultPriority _priority;
256 static FaultStat _count;
258 FaultName name() {return _name;}
259 TrapType trapType() {return _trapType;}
260 FaultPriority priority() {return _priority;}
261 FaultStat & countStat() {return _count;}
264 class FpDisabled : public SparcFault
267 static FaultName _name;
268 static TrapType _trapType;
269 static FaultPriority _priority;
270 static FaultStat _count;
272 FaultName name() {return _name;}
273 TrapType trapType() {return _trapType;}
274 FaultPriority priority() {return _priority;}
275 FaultStat & countStat() {return _count;}
278 class FpExceptionIEEE754 : public SparcFault
281 static FaultName _name;
282 static TrapType _trapType;
283 static FaultPriority _priority;
284 static FaultStat _count;
286 FaultName name() {return _name;}
287 TrapType trapType() {return _trapType;}
288 FaultPriority priority() {return _priority;}
289 FaultStat & countStat() {return _count;}
292 class FpExceptionOther : public SparcFault
295 static FaultName _name;
296 static TrapType _trapType;
297 static FaultPriority _priority;
298 static FaultStat _count;
300 FaultName name() {return _name;}
301 TrapType trapType() {return _trapType;}
302 FaultPriority priority() {return _priority;}
303 FaultStat & countStat() {return _count;}
306 class TagOverflow : public SparcFault
309 static FaultName _name;
310 static TrapType _trapType;
311 static FaultPriority _priority;
312 static FaultStat _count;
314 FaultName name() {return _name;}
315 TrapType trapType() {return _trapType;}
316 FaultPriority priority() {return _priority;}
317 FaultStat & countStat() {return _count;}
320 class DivisionByZero : public SparcFault
323 static FaultName _name;
324 static TrapType _trapType;
325 static FaultPriority _priority;
326 static FaultStat _count;
328 FaultName name() {return _name;}
329 TrapType trapType() {return _trapType;}
330 FaultPriority priority() {return _priority;}
331 FaultStat & countStat() {return _count;}
334 class DataAccessException : public SparcFault
337 static FaultName _name;
338 static TrapType _trapType;
339 static FaultPriority _priority;
340 static FaultStat _count;
342 FaultName name() {return _name;}
343 TrapType trapType() {return _trapType;}
344 FaultPriority priority() {return _priority;}
345 FaultStat & countStat() {return _count;}
348 class DataAccessMMUMiss : public SparcFault
351 static FaultName _name;
352 static TrapType _trapType;
353 static FaultPriority _priority;
354 static FaultStat _count;
356 FaultName name() {return _name;}
357 TrapType trapType() {return _trapType;}
358 FaultPriority priority() {return _priority;}
359 FaultStat & countStat() {return _count;}
362 class DataAccessError : public SparcFault
365 static FaultName _name;
366 static TrapType _trapType;
367 static FaultPriority _priority;
368 static FaultStat _count;
370 FaultName name() {return _name;}
371 TrapType trapType() {return _trapType;}
372 FaultPriority priority() {return _priority;}
373 FaultStat & countStat() {return _count;}
376 class DataAccessProtection : public SparcFault
379 static FaultName _name;
380 static TrapType _trapType;
381 static FaultPriority _priority;
382 static FaultStat _count;
384 FaultName name() {return _name;}
385 TrapType trapType() {return _trapType;}
386 FaultPriority priority() {return _priority;}
387 FaultStat & countStat() {return _count;}
390 class LDDFMemAddressNotAligned : public SparcFault
393 static FaultName _name;
394 static TrapType _trapType;
395 static FaultPriority _priority;
396 static FaultStat _count;
398 FaultName name() {return _name;}
399 TrapType trapType() {return _trapType;}
400 FaultPriority priority() {return _priority;}
401 FaultStat & countStat() {return _count;}
404 class STDFMemAddressNotAligned : public SparcFault
407 static FaultName _name;
408 static TrapType _trapType;
409 static FaultPriority _priority;
410 static FaultStat _count;
412 FaultName name() {return _name;}
413 TrapType trapType() {return _trapType;}
414 FaultPriority priority() {return _priority;}
415 FaultStat & countStat() {return _count;}
418 class PrivilegedAction : public SparcFault
421 static FaultName _name;
422 static TrapType _trapType;
423 static FaultPriority _priority;
424 static FaultStat _count;
426 FaultName name() {return _name;}
427 TrapType trapType() {return _trapType;}
428 FaultPriority priority() {return _priority;}
429 FaultStat & countStat() {return _count;}
432 class LDQFMemAddressNotAligned : public SparcFault
435 static FaultName _name;
436 static TrapType _trapType;
437 static FaultPriority _priority;
438 static FaultStat _count;
440 FaultName name() {return _name;}
441 TrapType trapType() {return _trapType;}
442 FaultPriority priority() {return _priority;}
443 FaultStat & countStat() {return _count;}
446 class STQFMemAddressNotAligned : public SparcFault
449 static FaultName _name;
450 static TrapType _trapType;
451 static FaultPriority _priority;
452 static FaultStat _count;
454 FaultName name() {return _name;}
455 TrapType trapType() {return _trapType;}
456 FaultPriority priority() {return _priority;}
457 FaultStat & countStat() {return _count;}
460 class AsyncDataError : public SparcFault
463 static FaultName _name;
464 static TrapType _trapType;
465 static FaultPriority _priority;
466 static FaultStat _count;
468 FaultName name() {return _name;}
469 TrapType trapType() {return _trapType;}
470 FaultPriority priority() {return _priority;}
471 FaultStat & countStat() {return _count;}
474 class CleanWindow : public SparcFault
477 static FaultName _name;
478 static TrapType _trapType;
479 static FaultPriority _priority;
480 static FaultStat _count;
482 FaultName name() {return _name;}
483 TrapType trapType() {return _trapType;}
484 FaultPriority priority() {return _priority;}
485 FaultStat & countStat() {return _count;}
488 class EnumeratedFault : public SparcFault
492 virtual TrapType baseTrapType() = 0;
494 EnumeratedFault(uint32_t n) : SparcFault() {_n = n;}
495 TrapType trapType() {return baseTrapType() + _n;}
498 class InterruptLevelN : public EnumeratedFault
501 static FaultName _name;
502 static TrapType _baseTrapType;
503 static FaultStat _count;
504 TrapType baseTrapType() {return _baseTrapType;}
506 InterruptLevelN(uint32_t n) : EnumeratedFault(n) {;}
507 FaultName name() {return _name;}
508 FaultPriority priority() {return 32 - _n;}
509 FaultStat & countStat() {return _count;}
512 class SpillNNormal : public EnumeratedFault
515 static FaultName _name;
516 static TrapType _baseTrapType;
517 static FaultPriority _priority;
518 static FaultStat _count;
519 TrapType baseTrapType() {return _baseTrapType;}
521 SpillNNormal(uint32_t n) : EnumeratedFault(n) {;}
522 FaultName name() {return _name;}
523 FaultPriority priority() {return _priority;}
524 FaultStat & countStat() {return _count;}
527 class SpillNOther : public EnumeratedFault
530 static FaultName _name;
531 static TrapType _baseTrapType;
532 static FaultPriority _priority;
533 static FaultStat _count;
534 TrapType baseTrapType() {return _baseTrapType;}
536 SpillNOther(uint32_t n) : EnumeratedFault(n) {;}
537 FaultName name() {return _name;}
538 FaultPriority priority() {return _priority;}
539 FaultStat & countStat() {return _count;}
542 class FillNNormal : public EnumeratedFault
545 static FaultName _name;
546 static TrapType _baseTrapType;
547 static FaultPriority _priority;
548 static FaultStat _count;
549 TrapType baseTrapType() {return _baseTrapType;}
551 FillNNormal(uint32_t n) : EnumeratedFault(n) {;}
552 FaultName name() {return _name;}
553 FaultPriority priority() {return _priority;}
554 FaultStat & countStat() {return _count;}
557 class FillNOther : public EnumeratedFault
560 static FaultName _name;
561 static TrapType _baseTrapType;
562 static FaultPriority _priority;
563 static FaultStat _count;
564 TrapType baseTrapType() {return _baseTrapType;}
566 FillNOther(uint32_t n) : EnumeratedFault(n) {;}
567 FaultName name() {return _name;}
568 FaultPriority priority() {return _priority;}
569 FaultStat & countStat() {return _count;}
572 class TrapInstruction : public EnumeratedFault
575 static FaultName _name;
576 static TrapType _baseTrapType;
577 static FaultPriority _priority;
578 static FaultStat _count;
579 uint64_t syscall_num;
580 TrapType baseTrapType() {return _baseTrapType;}
582 TrapInstruction(uint32_t n, uint64_t syscall) :
583 EnumeratedFault(n), syscall_num(syscall) {;}
584 FaultName name() {return _name;}
585 FaultPriority priority() {return _priority;}
586 FaultStat & countStat() {return _count;}
588 void invoke(ThreadContext * tc);
592 } // SparcISA namespace
594 #endif // __FAULTS_HH__