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;}
135 class WatchDogReset : public SparcFault
138 static FaultName _name;
139 static TrapType _trapType;
140 static FaultPriority _priority;
141 static FaultStat _count;
143 FaultName name() {return _name;}
144 TrapType trapType() {return _trapType;}
145 FaultPriority priority() {return _priority;}
146 FaultStat & countStat() {return _count;}
149 class ExternallyInitiatedReset : public SparcFault
152 static FaultName _name;
153 static TrapType _trapType;
154 static FaultPriority _priority;
155 static FaultStat _count;
157 FaultName name() {return _name;}
158 TrapType trapType() {return _trapType;}
159 FaultPriority priority() {return _priority;}
160 FaultStat & countStat() {return _count;}
163 class SoftwareInitiatedReset : public SparcFault
166 static FaultName _name;
167 static TrapType _trapType;
168 static FaultPriority _priority;
169 static FaultStat _count;
171 FaultName name() {return _name;}
172 TrapType trapType() {return _trapType;}
173 FaultPriority priority() {return _priority;}
174 FaultStat & countStat() {return _count;}
177 class REDStateException : public SparcFault
180 static FaultName _name;
181 static TrapType _trapType;
182 static FaultPriority _priority;
183 static FaultStat _count;
185 FaultName name() {return _name;}
186 TrapType trapType() {return _trapType;}
187 FaultPriority priority() {return _priority;}
188 FaultStat & countStat() {return _count;}
191 class InstructionAccessException : public SparcFault
194 static FaultName _name;
195 static TrapType _trapType;
196 static FaultPriority _priority;
197 static FaultStat _count;
199 FaultName name() {return _name;}
200 TrapType trapType() {return _trapType;}
201 FaultPriority priority() {return _priority;}
202 FaultStat & countStat() {return _count;}
205 class InstructionAccessMMUMiss : public SparcFault
208 static FaultName _name;
209 static TrapType _trapType;
210 static FaultPriority _priority;
211 static FaultStat _count;
213 FaultName name() {return _name;}
214 TrapType trapType() {return _trapType;}
215 FaultPriority priority() {return _priority;}
216 FaultStat & countStat() {return _count;}
219 class InstructionAccessError : public SparcFault
222 static FaultName _name;
223 static TrapType _trapType;
224 static FaultPriority _priority;
225 static FaultStat _count;
227 FaultName name() {return _name;}
228 TrapType trapType() {return _trapType;}
229 FaultPriority priority() {return _priority;}
230 FaultStat & countStat() {return _count;}
233 class IllegalInstruction : public SparcFault
236 static FaultName _name;
237 static TrapType _trapType;
238 static FaultPriority _priority;
239 static FaultStat _count;
241 FaultName name() {return _name;}
242 TrapType trapType() {return _trapType;}
243 FaultPriority priority() {return _priority;}
244 FaultStat & countStat() {return _count;}
247 class PrivilegedOpcode : public SparcFault
250 static FaultName _name;
251 static TrapType _trapType;
252 static FaultPriority _priority;
253 static FaultStat _count;
255 FaultName name() {return _name;}
256 TrapType trapType() {return _trapType;}
257 FaultPriority priority() {return _priority;}
258 FaultStat & countStat() {return _count;}
261 class UnimplementedLDD : public SparcFault
264 static FaultName _name;
265 static TrapType _trapType;
266 static FaultPriority _priority;
267 static FaultStat _count;
269 FaultName name() {return _name;}
270 TrapType trapType() {return _trapType;}
271 FaultPriority priority() {return _priority;}
272 FaultStat & countStat() {return _count;}
275 class UnimplementedSTD : public SparcFault
278 static FaultName _name;
279 static TrapType _trapType;
280 static FaultPriority _priority;
281 static FaultStat _count;
283 FaultName name() {return _name;}
284 TrapType trapType() {return _trapType;}
285 FaultPriority priority() {return _priority;}
286 FaultStat & countStat() {return _count;}
289 class FpDisabled : public SparcFault
292 static FaultName _name;
293 static TrapType _trapType;
294 static FaultPriority _priority;
295 static FaultStat _count;
297 FaultName name() {return _name;}
298 TrapType trapType() {return _trapType;}
299 FaultPriority priority() {return _priority;}
300 FaultStat & countStat() {return _count;}
303 class FpExceptionIEEE754 : public SparcFault
306 static FaultName _name;
307 static TrapType _trapType;
308 static FaultPriority _priority;
309 static FaultStat _count;
311 FaultName name() {return _name;}
312 TrapType trapType() {return _trapType;}
313 FaultPriority priority() {return _priority;}
314 FaultStat & countStat() {return _count;}
317 class FpExceptionOther : public SparcFault
320 static FaultName _name;
321 static TrapType _trapType;
322 static FaultPriority _priority;
323 static FaultStat _count;
325 FaultName name() {return _name;}
326 TrapType trapType() {return _trapType;}
327 FaultPriority priority() {return _priority;}
328 FaultStat & countStat() {return _count;}
331 class TagOverflow : public SparcFault
334 static FaultName _name;
335 static TrapType _trapType;
336 static FaultPriority _priority;
337 static FaultStat _count;
339 FaultName name() {return _name;}
340 TrapType trapType() {return _trapType;}
341 FaultPriority priority() {return _priority;}
342 FaultStat & countStat() {return _count;}
345 class DivisionByZero : public SparcFault
348 static FaultName _name;
349 static TrapType _trapType;
350 static FaultPriority _priority;
351 static FaultStat _count;
353 FaultName name() {return _name;}
354 TrapType trapType() {return _trapType;}
355 FaultPriority priority() {return _priority;}
356 FaultStat & countStat() {return _count;}
359 class DataAccessException : public SparcFault
362 static FaultName _name;
363 static TrapType _trapType;
364 static FaultPriority _priority;
365 static FaultStat _count;
367 FaultName name() {return _name;}
368 TrapType trapType() {return _trapType;}
369 FaultPriority priority() {return _priority;}
370 FaultStat & countStat() {return _count;}
373 class DataAccessMMUMiss : public SparcFault
376 static FaultName _name;
377 static TrapType _trapType;
378 static FaultPriority _priority;
379 static FaultStat _count;
381 FaultName name() {return _name;}
382 TrapType trapType() {return _trapType;}
383 FaultPriority priority() {return _priority;}
384 FaultStat & countStat() {return _count;}
387 class DataAccessError : public SparcFault
390 static FaultName _name;
391 static TrapType _trapType;
392 static FaultPriority _priority;
393 static FaultStat _count;
395 FaultName name() {return _name;}
396 TrapType trapType() {return _trapType;}
397 FaultPriority priority() {return _priority;}
398 FaultStat & countStat() {return _count;}
401 class DataAccessProtection : public SparcFault
404 static FaultName _name;
405 static TrapType _trapType;
406 static FaultPriority _priority;
407 static FaultStat _count;
409 FaultName name() {return _name;}
410 TrapType trapType() {return _trapType;}
411 FaultPriority priority() {return _priority;}
412 FaultStat & countStat() {return _count;}
415 class LDDFMemAddressNotAligned : public SparcFault
418 static FaultName _name;
419 static TrapType _trapType;
420 static FaultPriority _priority;
421 static FaultStat _count;
423 FaultName name() {return _name;}
424 TrapType trapType() {return _trapType;}
425 FaultPriority priority() {return _priority;}
426 FaultStat & countStat() {return _count;}
429 class STDFMemAddressNotAligned : public SparcFault
432 static FaultName _name;
433 static TrapType _trapType;
434 static FaultPriority _priority;
435 static FaultStat _count;
437 FaultName name() {return _name;}
438 TrapType trapType() {return _trapType;}
439 FaultPriority priority() {return _priority;}
440 FaultStat & countStat() {return _count;}
443 class PrivilegedAction : public SparcFault
446 static FaultName _name;
447 static TrapType _trapType;
448 static FaultPriority _priority;
449 static FaultStat _count;
451 FaultName name() {return _name;}
452 TrapType trapType() {return _trapType;}
453 FaultPriority priority() {return _priority;}
454 FaultStat & countStat() {return _count;}
457 class LDQFMemAddressNotAligned : public SparcFault
460 static FaultName _name;
461 static TrapType _trapType;
462 static FaultPriority _priority;
463 static FaultStat _count;
465 FaultName name() {return _name;}
466 TrapType trapType() {return _trapType;}
467 FaultPriority priority() {return _priority;}
468 FaultStat & countStat() {return _count;}
471 class STQFMemAddressNotAligned : public SparcFault
474 static FaultName _name;
475 static TrapType _trapType;
476 static FaultPriority _priority;
477 static FaultStat _count;
479 FaultName name() {return _name;}
480 TrapType trapType() {return _trapType;}
481 FaultPriority priority() {return _priority;}
482 FaultStat & countStat() {return _count;}
485 class AsyncDataError : public SparcFault
488 static FaultName _name;
489 static TrapType _trapType;
490 static FaultPriority _priority;
491 static FaultStat _count;
493 FaultName name() {return _name;}
494 TrapType trapType() {return _trapType;}
495 FaultPriority priority() {return _priority;}
496 FaultStat & countStat() {return _count;}
499 class CleanWindow : public SparcFault
502 static FaultName _name;
503 static TrapType _trapType;
504 static FaultPriority _priority;
505 static FaultStat _count;
507 FaultName name() {return _name;}
508 TrapType trapType() {return _trapType;}
509 FaultPriority priority() {return _priority;}
510 FaultStat & countStat() {return _count;}
513 class EnumeratedFault : public SparcFault
517 virtual TrapType baseTrapType() = 0;
519 EnumeratedFault(uint32_t n) : SparcFault() {_n = n;}
520 TrapType trapType() {return baseTrapType() + _n;}
523 class InterruptLevelN : public EnumeratedFault
526 static FaultName _name;
527 static TrapType _baseTrapType;
528 static FaultStat _count;
529 TrapType baseTrapType() {return _baseTrapType;}
531 InterruptLevelN(uint32_t n) : EnumeratedFault(n) {;}
532 FaultName name() {return _name;}
533 FaultPriority priority() {return 32 - _n;}
534 FaultStat & countStat() {return _count;}
537 class SpillNNormal : public EnumeratedFault
540 static FaultName _name;
541 static TrapType _baseTrapType;
542 static FaultPriority _priority;
543 static FaultStat _count;
544 TrapType baseTrapType() {return _baseTrapType;}
546 SpillNNormal(uint32_t n) : EnumeratedFault(n) {;}
547 FaultName name() {return _name;}
548 FaultPriority priority() {return _priority;}
549 FaultStat & countStat() {return _count;}
550 void invoke(ThreadContext * tc);
553 class SpillNOther : public EnumeratedFault
556 static FaultName _name;
557 static TrapType _baseTrapType;
558 static FaultPriority _priority;
559 static FaultStat _count;
560 TrapType baseTrapType() {return _baseTrapType;}
562 SpillNOther(uint32_t n) : EnumeratedFault(n) {;}
563 FaultName name() {return _name;}
564 FaultPriority priority() {return _priority;}
565 FaultStat & countStat() {return _count;}
568 class FillNNormal : public EnumeratedFault
571 static FaultName _name;
572 static TrapType _baseTrapType;
573 static FaultPriority _priority;
574 static FaultStat _count;
575 TrapType baseTrapType() {return _baseTrapType;}
577 FillNNormal(uint32_t n) : EnumeratedFault(n) {;}
578 FaultName name() {return _name;}
579 FaultPriority priority() {return _priority;}
580 FaultStat & countStat() {return _count;}
581 void invoke(ThreadContext * tc);
584 class FillNOther : public EnumeratedFault
587 static FaultName _name;
588 static TrapType _baseTrapType;
589 static FaultPriority _priority;
590 static FaultStat _count;
591 TrapType baseTrapType() {return _baseTrapType;}
593 FillNOther(uint32_t n) : EnumeratedFault(n) {;}
594 FaultName name() {return _name;}
595 FaultPriority priority() {return _priority;}
596 FaultStat & countStat() {return _count;}
599 class TrapInstruction : public EnumeratedFault
602 static FaultName _name;
603 static TrapType _baseTrapType;
604 static FaultPriority _priority;
605 static FaultStat _count;
606 uint64_t syscall_num;
607 TrapType baseTrapType() {return _baseTrapType;}
609 TrapInstruction(uint32_t n, uint64_t syscall) :
610 EnumeratedFault(n), syscall_num(syscall) {;}
611 FaultName name() {return _name;}
612 FaultPriority priority() {return _priority;}
613 FaultStat & countStat() {return _count;}
615 void invoke(ThreadContext * tc);
620 } // SparcISA namespace
622 #endif // __FAULTS_HH__