faults.hh revision 2632:1bb2f91485ea
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
29#ifndef __ALPHA_FAULTS_HH__
30#define __ALPHA_FAULTS_HH__
31
32#include "sim/faults.hh"
33
34// The design of the "name" and "vect" functions is in sim/faults.hh
35
36namespace SparcISA
37{
38
39typedef const uint32_t TrapType;
40typedef const uint32_t FaultPriority;
41
42class SparcFault : public FaultBase
43{
44  public:
45#if FULL_SYSTEM
46    void invoke(ExecContext * xc);
47#endif
48    virtual TrapType trapType() = 0;
49    virtual FaultPriority priority() = 0;
50    virtual FaultStat & countStat() = 0;
51};
52
53class InternalProcessorError : public SparcFault
54{
55  private:
56    static FaultName _name;
57    static TrapType _trapType;
58    static FaultPriority _priority;
59    static FaultStat _count;
60  public:
61    FaultName name() {return _name;}
62    TrapType trapType() {return _trapType;}
63    FaultPriority priority() {return _priority;}
64    FaultStat & countStat() {return _count;}
65    bool isMachineCheckFault() {return true;}
66};
67
68class MemAddressNotAligned : public SparcFault
69{
70  private:
71    static FaultName _name;
72    static TrapType _trapType;
73    static FaultPriority _priority;
74    static FaultStat _count;
75  public:
76    FaultName name() {return _name;}
77    TrapType trapType() {return _trapType;}
78    FaultPriority priority() {return _priority;}
79    FaultStat & countStat() {return _count;}
80    bool isAlignmentFault() {return true;}
81};
82
83static inline Fault genMachineCheckFault()
84{
85    return new InternalProcessorError;
86}
87
88static inline Fault genAlignmentFault()
89{
90    return new MemAddressNotAligned;
91}
92
93class PowerOnReset : public SparcFault
94{
95  private:
96    static FaultName _name;
97    static TrapType _trapType;
98    static FaultPriority _priority;
99    static FaultStat _count;
100  public:
101    FaultName name() {return _name;}
102    TrapType trapType() {return _trapType;}
103    FaultPriority priority() {return _priority;}
104    FaultStat & countStat() {return _count;}
105};
106
107class WatchDogReset : public SparcFault
108{
109  private:
110    static FaultName _name;
111    static TrapType _trapType;
112    static FaultPriority _priority;
113    static FaultStat _count;
114  public:
115    FaultName name() {return _name;}
116    TrapType trapType() {return _trapType;}
117    FaultPriority priority() {return _priority;}
118    FaultStat & countStat() {return _count;}
119};
120
121class ExternallyInitiatedReset : public SparcFault
122{
123  private:
124    static FaultName _name;
125    static TrapType _trapType;
126    static FaultPriority _priority;
127    static FaultStat _count;
128  public:
129    FaultName name() {return _name;}
130    TrapType trapType() {return _trapType;}
131    FaultPriority priority() {return _priority;}
132    FaultStat & countStat() {return _count;}
133};
134
135class SoftwareInitiatedReset : public SparcFault
136{
137  private:
138    static FaultName _name;
139    static TrapType _trapType;
140    static FaultPriority _priority;
141    static FaultStat _count;
142  public:
143    FaultName name() {return _name;}
144    TrapType trapType() {return _trapType;}
145    FaultPriority priority() {return _priority;}
146    FaultStat & countStat() {return _count;}
147};
148
149class REDStateException : public SparcFault
150{
151  private:
152    static FaultName _name;
153    static TrapType _trapType;
154    static FaultPriority _priority;
155    static FaultStat _count;
156  public:
157    FaultName name() {return _name;}
158    TrapType trapType() {return _trapType;}
159    FaultPriority priority() {return _priority;}
160    FaultStat & countStat() {return _count;}
161};
162
163class InstructionAccessException : public SparcFault
164{
165  private:
166    static FaultName _name;
167    static TrapType _trapType;
168    static FaultPriority _priority;
169    static FaultStat _count;
170  public:
171    FaultName name() {return _name;}
172    TrapType trapType() {return _trapType;}
173    FaultPriority priority() {return _priority;}
174    FaultStat & countStat() {return _count;}
175};
176
177class InstructionAccessMMUMiss : public SparcFault
178{
179  private:
180    static FaultName _name;
181    static TrapType _trapType;
182    static FaultPriority _priority;
183    static FaultStat _count;
184  public:
185    FaultName name() {return _name;}
186    TrapType trapType() {return _trapType;}
187    FaultPriority priority() {return _priority;}
188    FaultStat & countStat() {return _count;}
189};
190
191class InstructionAccessError : public SparcFault
192{
193  private:
194    static FaultName _name;
195    static TrapType _trapType;
196    static FaultPriority _priority;
197    static FaultStat _count;
198  public:
199    FaultName name() {return _name;}
200    TrapType trapType() {return _trapType;}
201    FaultPriority priority() {return _priority;}
202    FaultStat & countStat() {return _count;}
203};
204
205class IllegalInstruction : public SparcFault
206{
207  private:
208    static FaultName _name;
209    static TrapType _trapType;
210    static FaultPriority _priority;
211    static FaultStat _count;
212  public:
213    FaultName name() {return _name;}
214    TrapType trapType() {return _trapType;}
215    FaultPriority priority() {return _priority;}
216    FaultStat & countStat() {return _count;}
217};
218
219class PrivilegedOpcode : public SparcFault
220{
221  private:
222    static FaultName _name;
223    static TrapType _trapType;
224    static FaultPriority _priority;
225    static FaultStat _count;
226  public:
227    FaultName name() {return _name;}
228    TrapType trapType() {return _trapType;}
229    FaultPriority priority() {return _priority;}
230    FaultStat & countStat() {return _count;}
231};
232
233class UnimplementedLDD : public SparcFault
234{
235  private:
236    static FaultName _name;
237    static TrapType _trapType;
238    static FaultPriority _priority;
239    static FaultStat _count;
240  public:
241    FaultName name() {return _name;}
242    TrapType trapType() {return _trapType;}
243    FaultPriority priority() {return _priority;}
244    FaultStat & countStat() {return _count;}
245};
246
247class UnimplementedSTD : public SparcFault
248{
249  private:
250    static FaultName _name;
251    static TrapType _trapType;
252    static FaultPriority _priority;
253    static FaultStat _count;
254  public:
255    FaultName name() {return _name;}
256    TrapType trapType() {return _trapType;}
257    FaultPriority priority() {return _priority;}
258    FaultStat & countStat() {return _count;}
259};
260
261class FpDisabled : public SparcFault
262{
263  private:
264    static FaultName _name;
265    static TrapType _trapType;
266    static FaultPriority _priority;
267    static FaultStat _count;
268  public:
269    FaultName name() {return _name;}
270    TrapType trapType() {return _trapType;}
271    FaultPriority priority() {return _priority;}
272    FaultStat & countStat() {return _count;}
273};
274
275class FpExceptionIEEE754 : public SparcFault
276{
277  private:
278    static FaultName _name;
279    static TrapType _trapType;
280    static FaultPriority _priority;
281    static FaultStat _count;
282  public:
283    FaultName name() {return _name;}
284    TrapType trapType() {return _trapType;}
285    FaultPriority priority() {return _priority;}
286    FaultStat & countStat() {return _count;}
287};
288
289class FpExceptionOther : public SparcFault
290{
291  private:
292    static FaultName _name;
293    static TrapType _trapType;
294    static FaultPriority _priority;
295    static FaultStat _count;
296  public:
297    FaultName name() {return _name;}
298    TrapType trapType() {return _trapType;}
299    FaultPriority priority() {return _priority;}
300    FaultStat & countStat() {return _count;}
301};
302
303class TagOverflow : public SparcFault
304{
305  private:
306    static FaultName _name;
307    static TrapType _trapType;
308    static FaultPriority _priority;
309    static FaultStat _count;
310  public:
311    FaultName name() {return _name;}
312    TrapType trapType() {return _trapType;}
313    FaultPriority priority() {return _priority;}
314    FaultStat & countStat() {return _count;}
315};
316
317class DivisionByZero : public SparcFault
318{
319  private:
320    static FaultName _name;
321    static TrapType _trapType;
322    static FaultPriority _priority;
323    static FaultStat _count;
324  public:
325    FaultName name() {return _name;}
326    TrapType trapType() {return _trapType;}
327    FaultPriority priority() {return _priority;}
328    FaultStat & countStat() {return _count;}
329};
330
331class DataAccessException : public SparcFault
332{
333  private:
334    static FaultName _name;
335    static TrapType _trapType;
336    static FaultPriority _priority;
337    static FaultStat _count;
338  public:
339    FaultName name() {return _name;}
340    TrapType trapType() {return _trapType;}
341    FaultPriority priority() {return _priority;}
342    FaultStat & countStat() {return _count;}
343};
344
345class DataAccessMMUMiss : public SparcFault
346{
347  private:
348    static FaultName _name;
349    static TrapType _trapType;
350    static FaultPriority _priority;
351    static FaultStat _count;
352  public:
353    FaultName name() {return _name;}
354    TrapType trapType() {return _trapType;}
355    FaultPriority priority() {return _priority;}
356    FaultStat & countStat() {return _count;}
357};
358
359class DataAccessError : public SparcFault
360{
361  private:
362    static FaultName _name;
363    static TrapType _trapType;
364    static FaultPriority _priority;
365    static FaultStat _count;
366  public:
367    FaultName name() {return _name;}
368    TrapType trapType() {return _trapType;}
369    FaultPriority priority() {return _priority;}
370    FaultStat & countStat() {return _count;}
371};
372
373class DataAccessProtection : public SparcFault
374{
375  private:
376    static FaultName _name;
377    static TrapType _trapType;
378    static FaultPriority _priority;
379    static FaultStat _count;
380  public:
381    FaultName name() {return _name;}
382    TrapType trapType() {return _trapType;}
383    FaultPriority priority() {return _priority;}
384    FaultStat & countStat() {return _count;}
385};
386
387class LDDFMemAddressNotAligned : public SparcFault
388{
389  private:
390    static FaultName _name;
391    static TrapType _trapType;
392    static FaultPriority _priority;
393    static FaultStat _count;
394  public:
395    FaultName name() {return _name;}
396    TrapType trapType() {return _trapType;}
397    FaultPriority priority() {return _priority;}
398    FaultStat & countStat() {return _count;}
399};
400
401class STDFMemAddressNotAligned : public SparcFault
402{
403  private:
404    static FaultName _name;
405    static TrapType _trapType;
406    static FaultPriority _priority;
407    static FaultStat _count;
408  public:
409    FaultName name() {return _name;}
410    TrapType trapType() {return _trapType;}
411    FaultPriority priority() {return _priority;}
412    FaultStat & countStat() {return _count;}
413};
414
415class PrivilegedAction : public SparcFault
416{
417  private:
418    static FaultName _name;
419    static TrapType _trapType;
420    static FaultPriority _priority;
421    static FaultStat _count;
422  public:
423    FaultName name() {return _name;}
424    TrapType trapType() {return _trapType;}
425    FaultPriority priority() {return _priority;}
426    FaultStat & countStat() {return _count;}
427};
428
429class LDQFMemAddressNotAligned : public SparcFault
430{
431  private:
432    static FaultName _name;
433    static TrapType _trapType;
434    static FaultPriority _priority;
435    static FaultStat _count;
436  public:
437    FaultName name() {return _name;}
438    TrapType trapType() {return _trapType;}
439    FaultPriority priority() {return _priority;}
440    FaultStat & countStat() {return _count;}
441};
442
443class STQFMemAddressNotAligned : public SparcFault
444{
445  private:
446    static FaultName _name;
447    static TrapType _trapType;
448    static FaultPriority _priority;
449    static FaultStat _count;
450  public:
451    FaultName name() {return _name;}
452    TrapType trapType() {return _trapType;}
453    FaultPriority priority() {return _priority;}
454    FaultStat & countStat() {return _count;}
455};
456
457class AsyncDataError : public SparcFault
458{
459  private:
460    static FaultName _name;
461    static TrapType _trapType;
462    static FaultPriority _priority;
463    static FaultStat _count;
464  public:
465    FaultName name() {return _name;}
466    TrapType trapType() {return _trapType;}
467    FaultPriority priority() {return _priority;}
468    FaultStat & countStat() {return _count;}
469};
470
471class CleanWindow : public SparcFault
472{
473  private:
474    static FaultName _name;
475    static TrapType _trapType;
476    static FaultPriority _priority;
477    static FaultStat _count;
478  public:
479    FaultName name() {return _name;}
480    TrapType trapType() {return _trapType;}
481    FaultPriority priority() {return _priority;}
482    FaultStat & countStat() {return _count;}
483};
484
485class EnumeratedFault : public SparcFault
486{
487  protected:
488    uint32_t _n;
489    virtual TrapType baseTrapType() = 0;
490  public:
491    EnumeratedFault(uint32_t n) : SparcFault() {_n = n;}
492    TrapType trapType() {return baseTrapType() + _n;}
493};
494
495class InterruptLevelN : public EnumeratedFault
496{
497  private:
498    static FaultName _name;
499    static TrapType _baseTrapType;
500    static FaultStat _count;
501    TrapType baseTrapType() {return _baseTrapType;}
502  public:
503    InterruptLevelN(uint32_t n) : EnumeratedFault(n) {;}
504    FaultName name() {return _name;}
505    FaultPriority priority() {return 32 - _n;}
506    FaultStat & countStat() {return _count;}
507};
508
509class SpillNNormal : public EnumeratedFault
510{
511  private:
512    static FaultName _name;
513    static TrapType _baseTrapType;
514    static FaultPriority _priority;
515    static FaultStat _count;
516    TrapType baseTrapType() {return _baseTrapType;}
517  public:
518    SpillNNormal(uint32_t n) : EnumeratedFault(n) {;}
519    FaultName name() {return _name;}
520    FaultPriority priority() {return _priority;}
521    FaultStat & countStat() {return _count;}
522};
523
524class SpillNOther : public EnumeratedFault
525{
526  private:
527    static FaultName _name;
528    static TrapType _baseTrapType;
529    static FaultPriority _priority;
530    static FaultStat _count;
531    TrapType baseTrapType() {return _baseTrapType;}
532  public:
533    SpillNOther(uint32_t n) : EnumeratedFault(n) {;}
534    FaultName name() {return _name;}
535    FaultPriority priority() {return _priority;}
536    FaultStat & countStat() {return _count;}
537};
538
539class FillNNormal : public EnumeratedFault
540{
541  private:
542    static FaultName _name;
543    static TrapType _baseTrapType;
544    static FaultPriority _priority;
545    static FaultStat _count;
546    TrapType baseTrapType() {return _baseTrapType;}
547  public:
548    FillNNormal(uint32_t n) : EnumeratedFault(n) {;}
549    FaultName name() {return _name;}
550    FaultPriority priority() {return _priority;}
551    FaultStat & countStat() {return _count;}
552};
553
554class FillNOther : public EnumeratedFault
555{
556  private:
557    static FaultName _name;
558    static TrapType _baseTrapType;
559    static FaultPriority _priority;
560    static FaultStat _count;
561    TrapType baseTrapType() {return _baseTrapType;}
562  public:
563    FillNOther(uint32_t n) : EnumeratedFault(n) {;}
564    FaultName name() {return _name;}
565    FaultPriority priority() {return _priority;}
566    FaultStat & countStat() {return _count;}
567};
568
569class TrapInstruction : public EnumeratedFault
570{
571  private:
572    static FaultName _name;
573    static TrapType _baseTrapType;
574    static FaultPriority _priority;
575    static FaultStat _count;
576    uint64_t syscall_num;
577    TrapType baseTrapType() {return _baseTrapType;}
578  public:
579    TrapInstruction(uint32_t n, uint64_t syscall) :
580        EnumeratedFault(n), syscall_num(syscall) {;}
581    FaultName name() {return _name;}
582    FaultPriority priority() {return _priority;}
583    FaultStat & countStat() {return _count;}
584#if !FULL_SYSTEM
585    void invoke(ExecContext * xc);
586#endif
587};
588
589} // SparcISA namespace
590
591#endif // __FAULTS_HH__
592