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 uint32_t TrapType;
43 typedef 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;}
87 class PageTableFault : public SparcFault
91 static FaultName _name;
92 static TrapType _trapType;
93 static FaultPriority _priority;
94 static FaultStat _count;
96 PageTableFault(Addr va)
98 FaultName name() {return _name;}
99 TrapType trapType() {return _trapType;}
100 FaultPriority priority() {return _priority;}
101 FaultStat & countStat() {return _count;}
102 void invoke(ThreadContext * tc);
105 static inline Fault genPageTableFault(Addr va)
107 return new PageTableFault(va);
111 static inline Fault genMachineCheckFault()
113 return new InternalProcessorError;
116 static inline Fault genAlignmentFault()
118 return new MemAddressNotAligned;
121 class PowerOnReset : public SparcFault
124 static FaultName _name;
125 static TrapType _trapType;
126 static FaultPriority _priority;
127 static FaultStat _count;
129 FaultName name() {return _name;}
130 TrapType trapType() {return _trapType;}
131 FaultPriority priority() {return _priority;}
132 FaultStat & countStat() {return _count;}
133 void invoke(ThreadContext * tc);
136 class WatchDogReset : public SparcFault
139 static FaultName _name;
140 static TrapType _trapType;
141 static FaultPriority _priority;
142 static FaultStat _count;
144 FaultName name() {return _name;}
145 TrapType trapType() {return _trapType;}
146 FaultPriority priority() {return _priority;}
147 FaultStat & countStat() {return _count;}
150 class ExternallyInitiatedReset : public SparcFault
153 static FaultName _name;
154 static TrapType _trapType;
155 static FaultPriority _priority;
156 static FaultStat _count;
158 FaultName name() {return _name;}
159 TrapType trapType() {return _trapType;}
160 FaultPriority priority() {return _priority;}
161 FaultStat & countStat() {return _count;}
164 class SoftwareInitiatedReset : public SparcFault
167 static FaultName _name;
168 static TrapType _trapType;
169 static FaultPriority _priority;
170 static FaultStat _count;
172 FaultName name() {return _name;}
173 TrapType trapType() {return _trapType;}
174 FaultPriority priority() {return _priority;}
175 FaultStat & countStat() {return _count;}
178 class REDStateException : public SparcFault
181 static FaultName _name;
182 static TrapType _trapType;
183 static FaultPriority _priority;
184 static FaultStat _count;
186 FaultName name() {return _name;}
187 TrapType trapType() {return _trapType;}
188 FaultPriority priority() {return _priority;}
189 FaultStat & countStat() {return _count;}
192 class InstructionAccessException : public SparcFault
195 static FaultName _name;
196 static TrapType _trapType;
197 static FaultPriority _priority;
198 static FaultStat _count;
200 FaultName name() {return _name;}
201 TrapType trapType() {return _trapType;}
202 FaultPriority priority() {return _priority;}
203 FaultStat & countStat() {return _count;}
206 class InstructionAccessMMUMiss : public SparcFault
209 static FaultName _name;
210 static TrapType _trapType;
211 static FaultPriority _priority;
212 static FaultStat _count;
214 FaultName name() {return _name;}
215 TrapType trapType() {return _trapType;}
216 FaultPriority priority() {return _priority;}
217 FaultStat & countStat() {return _count;}
220 class InstructionAccessError : public SparcFault
223 static FaultName _name;
224 static TrapType _trapType;
225 static FaultPriority _priority;
226 static FaultStat _count;
228 FaultName name() {return _name;}
229 TrapType trapType() {return _trapType;}
230 FaultPriority priority() {return _priority;}
231 FaultStat & countStat() {return _count;}
234 class IllegalInstruction : public SparcFault
237 static FaultName _name;
238 static TrapType _trapType;
239 static FaultPriority _priority;
240 static FaultStat _count;
242 FaultName name() {return _name;}
243 TrapType trapType() {return _trapType;}
244 FaultPriority priority() {return _priority;}
245 FaultStat & countStat() {return _count;}
248 class PrivilegedOpcode : public SparcFault
251 static FaultName _name;
252 static TrapType _trapType;
253 static FaultPriority _priority;
254 static FaultStat _count;
256 FaultName name() {return _name;}
257 TrapType trapType() {return _trapType;}
258 FaultPriority priority() {return _priority;}
259 FaultStat & countStat() {return _count;}
262 class UnimplementedLDD : public SparcFault
265 static FaultName _name;
266 static TrapType _trapType;
267 static FaultPriority _priority;
268 static FaultStat _count;
270 FaultName name() {return _name;}
271 TrapType trapType() {return _trapType;}
272 FaultPriority priority() {return _priority;}
273 FaultStat & countStat() {return _count;}
276 class UnimplementedSTD : public SparcFault
279 static FaultName _name;
280 static TrapType _trapType;
281 static FaultPriority _priority;
282 static FaultStat _count;
284 FaultName name() {return _name;}
285 TrapType trapType() {return _trapType;}
286 FaultPriority priority() {return _priority;}
287 FaultStat & countStat() {return _count;}
290 class FpDisabled : public SparcFault
293 static FaultName _name;
294 static TrapType _trapType;
295 static FaultPriority _priority;
296 static FaultStat _count;
298 FaultName name() {return _name;}
299 TrapType trapType() {return _trapType;}
300 FaultPriority priority() {return _priority;}
301 FaultStat & countStat() {return _count;}
304 class FpExceptionIEEE754 : public SparcFault
307 static FaultName _name;
308 static TrapType _trapType;
309 static FaultPriority _priority;
310 static FaultStat _count;
312 FaultName name() {return _name;}
313 TrapType trapType() {return _trapType;}
314 FaultPriority priority() {return _priority;}
315 FaultStat & countStat() {return _count;}
318 class FpExceptionOther : public SparcFault
321 static FaultName _name;
322 static TrapType _trapType;
323 static FaultPriority _priority;
324 static FaultStat _count;
326 FaultName name() {return _name;}
327 TrapType trapType() {return _trapType;}
328 FaultPriority priority() {return _priority;}
329 FaultStat & countStat() {return _count;}
332 class TagOverflow : public SparcFault
335 static FaultName _name;
336 static TrapType _trapType;
337 static FaultPriority _priority;
338 static FaultStat _count;
340 FaultName name() {return _name;}
341 TrapType trapType() {return _trapType;}
342 FaultPriority priority() {return _priority;}
343 FaultStat & countStat() {return _count;}
346 class DivisionByZero : public SparcFault
349 static FaultName _name;
350 static TrapType _trapType;
351 static FaultPriority _priority;
352 static FaultStat _count;
354 FaultName name() {return _name;}
355 TrapType trapType() {return _trapType;}
356 FaultPriority priority() {return _priority;}
357 FaultStat & countStat() {return _count;}
360 class DataAccessException : public SparcFault
363 static FaultName _name;
364 static TrapType _trapType;
365 static FaultPriority _priority;
366 static FaultStat _count;
368 FaultName name() {return _name;}
369 TrapType trapType() {return _trapType;}
370 FaultPriority priority() {return _priority;}
371 FaultStat & countStat() {return _count;}
374 class DataAccessMMUMiss : public SparcFault
377 static FaultName _name;
378 static TrapType _trapType;
379 static FaultPriority _priority;
380 static FaultStat _count;
382 FaultName name() {return _name;}
383 TrapType trapType() {return _trapType;}
384 FaultPriority priority() {return _priority;}
385 FaultStat & countStat() {return _count;}
388 class DataAccessError : public SparcFault
391 static FaultName _name;
392 static TrapType _trapType;
393 static FaultPriority _priority;
394 static FaultStat _count;
396 FaultName name() {return _name;}
397 TrapType trapType() {return _trapType;}
398 FaultPriority priority() {return _priority;}
399 FaultStat & countStat() {return _count;}
402 class DataAccessProtection : public SparcFault
405 static FaultName _name;
406 static TrapType _trapType;
407 static FaultPriority _priority;
408 static FaultStat _count;
410 FaultName name() {return _name;}
411 TrapType trapType() {return _trapType;}
412 FaultPriority priority() {return _priority;}
413 FaultStat & countStat() {return _count;}
416 class LDDFMemAddressNotAligned : public SparcFault
419 static FaultName _name;
420 static TrapType _trapType;
421 static FaultPriority _priority;
422 static FaultStat _count;
424 FaultName name() {return _name;}
425 TrapType trapType() {return _trapType;}
426 FaultPriority priority() {return _priority;}
427 FaultStat & countStat() {return _count;}
430 class STDFMemAddressNotAligned : public SparcFault
433 static FaultName _name;
434 static TrapType _trapType;
435 static FaultPriority _priority;
436 static FaultStat _count;
438 FaultName name() {return _name;}
439 TrapType trapType() {return _trapType;}
440 FaultPriority priority() {return _priority;}
441 FaultStat & countStat() {return _count;}
444 class PrivilegedAction : public SparcFault
447 static FaultName _name;
448 static TrapType _trapType;
449 static FaultPriority _priority;
450 static FaultStat _count;
452 FaultName name() {return _name;}
453 TrapType trapType() {return _trapType;}
454 FaultPriority priority() {return _priority;}
455 FaultStat & countStat() {return _count;}
458 class LDQFMemAddressNotAligned : public SparcFault
461 static FaultName _name;
462 static TrapType _trapType;
463 static FaultPriority _priority;
464 static FaultStat _count;
466 FaultName name() {return _name;}
467 TrapType trapType() {return _trapType;}
468 FaultPriority priority() {return _priority;}
469 FaultStat & countStat() {return _count;}
472 class STQFMemAddressNotAligned : public SparcFault
475 static FaultName _name;
476 static TrapType _trapType;
477 static FaultPriority _priority;
478 static FaultStat _count;
480 FaultName name() {return _name;}
481 TrapType trapType() {return _trapType;}
482 FaultPriority priority() {return _priority;}
483 FaultStat & countStat() {return _count;}
486 class AsyncDataError : public SparcFault
489 static FaultName _name;
490 static TrapType _trapType;
491 static FaultPriority _priority;
492 static FaultStat _count;
494 FaultName name() {return _name;}
495 TrapType trapType() {return _trapType;}
496 FaultPriority priority() {return _priority;}
497 FaultStat & countStat() {return _count;}
500 class CleanWindow : public SparcFault
503 static FaultName _name;
504 static TrapType _trapType;
505 static FaultPriority _priority;
506 static FaultStat _count;
508 FaultName name() {return _name;}
509 TrapType trapType() {return _trapType;}
510 FaultPriority priority() {return _priority;}
511 FaultStat & countStat() {return _count;}
514 class EnumeratedFault : public SparcFault
518 virtual TrapType baseTrapType() = 0;
520 EnumeratedFault(uint32_t n) : SparcFault() {_n = n;}
521 TrapType trapType() {return baseTrapType() + _n;}
524 class InterruptLevelN : public EnumeratedFault
527 static FaultName _name;
528 static TrapType _baseTrapType;
529 static FaultStat _count;
530 TrapType baseTrapType() {return _baseTrapType;}
532 InterruptLevelN(uint32_t n) : EnumeratedFault(n) {;}
533 FaultName name() {return _name;}
534 FaultPriority priority() {return 32 - _n;}
535 FaultStat & countStat() {return _count;}
538 class SpillNNormal : public EnumeratedFault
541 static FaultName _name;
542 static TrapType _baseTrapType;
543 static FaultPriority _priority;
544 static FaultStat _count;
545 TrapType baseTrapType() {return _baseTrapType;}
547 SpillNNormal(uint32_t n) : EnumeratedFault(n) {;}
548 FaultName name() {return _name;}
549 FaultPriority priority() {return _priority;}
550 FaultStat & countStat() {return _count;}
551 void invoke(ThreadContext * tc);
554 class SpillNOther : public EnumeratedFault
557 static FaultName _name;
558 static TrapType _baseTrapType;
559 static FaultPriority _priority;
560 static FaultStat _count;
561 TrapType baseTrapType() {return _baseTrapType;}
563 SpillNOther(uint32_t n) : EnumeratedFault(n) {;}
564 FaultName name() {return _name;}
565 FaultPriority priority() {return _priority;}
566 FaultStat & countStat() {return _count;}
569 class FillNNormal : public EnumeratedFault
572 static FaultName _name;
573 static TrapType _baseTrapType;
574 static FaultPriority _priority;
575 static FaultStat _count;
576 TrapType baseTrapType() {return _baseTrapType;}
578 FillNNormal(uint32_t n) : EnumeratedFault(n) {;}
579 FaultName name() {return _name;}
580 FaultPriority priority() {return _priority;}
581 FaultStat & countStat() {return _count;}
582 void invoke(ThreadContext * tc);
585 class FillNOther : public EnumeratedFault
588 static FaultName _name;
589 static TrapType _baseTrapType;
590 static FaultPriority _priority;
591 static FaultStat _count;
592 TrapType baseTrapType() {return _baseTrapType;}
594 FillNOther(uint32_t n) : EnumeratedFault(n) {;}
595 FaultName name() {return _name;}
596 FaultPriority priority() {return _priority;}
597 FaultStat & countStat() {return _count;}
600 class TrapInstruction : public EnumeratedFault
603 static FaultName _name;
604 static TrapType _baseTrapType;
605 static FaultPriority _priority;
606 static FaultStat _count;
607 uint64_t syscall_num;
608 TrapType baseTrapType() {return _baseTrapType;}
610 TrapInstruction(uint32_t n, uint64_t syscall) :
611 EnumeratedFault(n), syscall_num(syscall) {;}
612 FaultName name() {return _name;}
613 FaultPriority priority() {return _priority;}
614 FaultStat & countStat() {return _count;}
616 void invoke(ThreadContext * tc);
621 } // SparcISA namespace
623 #endif // __FAULTS_HH__