faults.hh revision 2665:a124942bacb8
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
38namespace MipsISA
39{
40
41typedef const Addr FaultVect;
42
43class 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(ExecContext * xc);
51#endif
52    virtual FaultVect vect() = 0;
53    virtual FaultStat & countStat() = 0;
54};
55
56class 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
69class 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
82static inline Fault genMachineCheckFault()
83{
84    return new MachineCheckFault;
85}
86
87static inline Fault genAlignmentFault()
88{
89    return new AlignmentFault;
90}
91
92class ResetFault : public MipsFault
93{
94  private:
95    static FaultName _name;
96    static FaultVect _vect;
97    static FaultStat _count;
98  public:
99    FaultName name() {return _name;}
100    FaultVect vect() {return _vect;}
101    FaultStat & countStat() {return _count;}
102};
103
104class ArithmeticFault : public MipsFault
105{
106  protected:
107    bool skipFaultingInstruction() {return true;}
108  private:
109    static FaultName _name;
110    static FaultVect _vect;
111    static FaultStat _count;
112  public:
113    FaultName name() {return _name;}
114    FaultVect vect() {return _vect;}
115    FaultStat & countStat() {return _count;}
116#if FULL_SYSTEM
117    void invoke(ExecContext * xc);
118#endif
119};
120
121class InterruptFault : public MipsFault
122{
123  protected:
124    bool setRestartAddress() {return false;}
125  private:
126    static FaultName _name;
127    static FaultVect _vect;
128    static FaultStat _count;
129  public:
130    FaultName name() {return _name;}
131    FaultVect vect() {return _vect;}
132    FaultStat & countStat() {return _count;}
133};
134
135class NDtbMissFault : public MipsFault
136{
137  private:
138    static FaultName _name;
139    static FaultVect _vect;
140    static FaultStat _count;
141  public:
142    FaultName name() {return _name;}
143    FaultVect vect() {return _vect;}
144    FaultStat & countStat() {return _count;}
145};
146
147class PDtbMissFault : public MipsFault
148{
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
159class DtbPageFault : 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
171class DtbAcvFault : 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
183class ItbMissFault : 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
195class ItbPageFault : 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
207class ItbAcvFault : 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
219class UnimplementedOpcodeFault : 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
231class FloatEnableFault : 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
243class PalFault : public MipsFault
244{
245  protected:
246    bool skipFaultingInstruction() {return true;}
247  private:
248    static FaultName _name;
249    static FaultVect _vect;
250    static FaultStat _count;
251  public:
252    FaultName name() {return _name;}
253    FaultVect vect() {return _vect;}
254    FaultStat & countStat() {return _count;}
255};
256
257class IntegerOverflowFault : public MipsFault
258{
259  private:
260    static FaultName _name;
261    static FaultVect _vect;
262    static FaultStat _count;
263  public:
264    FaultName name() {return _name;}
265    FaultVect vect() {return _vect;}
266    FaultStat & countStat() {return _count;}
267};
268
269} // MipsISA namespace
270
271#endif // __FAULTS_HH__
272