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: Gabe Black
29 *          Kevin Lim
30 */
31
32#ifndef __ARCH_ALPHA_FAULTS_HH__
33#define __ARCH_ALPHA_FAULTS_HH__
34
35#include "arch/alpha/pagetable.hh"
36#include "mem/request.hh"
37#include "sim/faults.hh"
38
39// The design of the "name" and "vect" functions is in sim/faults.hh
40
41namespace AlphaISA {
42
43typedef Addr FaultVect;
44
45class AlphaFault : public FaultBase
46{
47  protected:
48    virtual bool skipFaultingInstruction() {return false;}
49    virtual bool setRestartAddress() {return true;}
50  public:
51    virtual ~AlphaFault() {}
52    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
53                StaticInst::nullStaticInstPtr);
54    virtual FaultVect vect() = 0;
55    virtual FaultStat & countStat() = 0;
56};
57
58class MachineCheckFault : public AlphaFault
59{
60  private:
61    static FaultName _name;
62    static FaultVect _vect;
63    static FaultStat _count;
64
65  public:
66    FaultName name() const {return _name;}
67    FaultVect vect() {return _vect;}
68    FaultStat & countStat() {return _count;}
69};
70
71class AlignmentFault : public AlphaFault
72{
73  private:
74    static FaultName _name;
75    static FaultVect _vect;
76    static FaultStat _count;
77
78  public:
79    FaultName name() const {return _name;}
80    FaultVect vect() {return _vect;}
81    FaultStat & countStat() {return _count;}
82    bool isAlignmentFault() const {return true;}
83};
84
85class ResetFault : public AlphaFault
86{
87  private:
88    static FaultName _name;
89    static FaultVect _vect;
90    static FaultStat _count;
91
92  public:
93    FaultName name() const {return _name;}
94    FaultVect vect() {return _vect;}
95    FaultStat & countStat() {return _count;}
96};
97
98class ArithmeticFault : public AlphaFault
99{
100  private:
101    static FaultName _name;
102    static FaultVect _vect;
103    static FaultStat _count;
104
105  protected:
106    bool skipFaultingInstruction() {return true;}
107
108  public:
109    FaultName name() const {return _name;}
110    FaultVect vect() {return _vect;}
111    FaultStat & countStat() {return _count;}
112    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
113                StaticInst::nullStaticInstPtr);
114};
115
116class InterruptFault : public AlphaFault
117{
118  private:
119    static FaultName _name;
120    static FaultVect _vect;
121    static FaultStat _count;
122
123  protected:
124    bool setRestartAddress() {return false;}
125
126  public:
127    FaultName name() const {return _name;}
128    FaultVect vect() {return _vect;}
129    FaultStat & countStat() {return _count;}
130};
131
132class DtbFault : public AlphaFault
133{
134  protected:
135    VAddr vaddr;
136    Request::Flags reqFlags;
137    uint64_t flags;
138
139  public:
140    DtbFault(VAddr _vaddr, Request::Flags _reqFlags, uint64_t _flags)
141        : vaddr(_vaddr), reqFlags(_reqFlags), flags(_flags)
142    { }
143    FaultName name() const = 0;
144    FaultVect vect() = 0;
145    FaultStat & countStat() = 0;
146    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
147                StaticInst::nullStaticInstPtr);
148};
149
150class NDtbMissFault : public DtbFault
151{
152  private:
153    static FaultName _name;
154    static FaultVect _vect;
155    static FaultStat _count;
156
157  public:
158    NDtbMissFault(VAddr vaddr, Request::Flags reqFlags, uint64_t flags)
159        : DtbFault(vaddr, reqFlags, flags)
160    { }
161    FaultName name() const {return _name;}
162    FaultVect vect() {return _vect;}
163    FaultStat & countStat() {return _count;}
164    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
165                StaticInst::nullStaticInstPtr);
166};
167
168class PDtbMissFault : public DtbFault
169{
170  private:
171    static FaultName _name;
172    static FaultVect _vect;
173    static FaultStat _count;
174
175  public:
176    PDtbMissFault(VAddr vaddr, Request::Flags reqFlags, uint64_t flags)
177        : DtbFault(vaddr, reqFlags, flags)
178    { }
179    FaultName name() const {return _name;}
180    FaultVect vect() {return _vect;}
181    FaultStat & countStat() {return _count;}
182};
183
184class DtbPageFault : public DtbFault
185{
186  private:
187    static FaultName _name;
188    static FaultVect _vect;
189    static FaultStat _count;
190
191  public:
192    DtbPageFault(VAddr vaddr, Request::Flags reqFlags, uint64_t flags)
193        : DtbFault(vaddr, reqFlags, flags)
194    { }
195    FaultName name() const {return _name;}
196    FaultVect vect() {return _vect;}
197    FaultStat & countStat() {return _count;}
198};
199
200class DtbAcvFault : public DtbFault
201{
202  private:
203    static FaultName _name;
204    static FaultVect _vect;
205    static FaultStat _count;
206
207  public:
208    DtbAcvFault(VAddr vaddr, Request::Flags reqFlags, uint64_t flags)
209        : DtbFault(vaddr, reqFlags, flags)
210    { }
211    FaultName name() const {return _name;}
212    FaultVect vect() {return _vect;}
213    FaultStat & countStat() {return _count;}
214};
215
216class DtbAlignmentFault : public DtbFault
217{
218  private:
219    static FaultName _name;
220    static FaultVect _vect;
221    static FaultStat _count;
222
223  public:
224    DtbAlignmentFault(VAddr vaddr, Request::Flags reqFlags, uint64_t flags)
225        : DtbFault(vaddr, reqFlags, flags)
226    { }
227    FaultName name() const {return _name;}
228    FaultVect vect() {return _vect;}
229    FaultStat & countStat() {return _count;}
230};
231
232class ItbFault : public AlphaFault
233{
234  protected:
235    Addr pc;
236
237  public:
238    ItbFault(Addr _pc) : pc(_pc) { }
239    FaultName name() const = 0;
240    FaultVect vect() = 0;
241    FaultStat & countStat() = 0;
242    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
243                StaticInst::nullStaticInstPtr);
244};
245
246class ItbPageFault : public ItbFault
247{
248  private:
249    static FaultName _name;
250    static FaultVect _vect;
251    static FaultStat _count;
252
253  public:
254    ItbPageFault(Addr pc) : ItbFault(pc) { }
255    FaultName name() const {return _name;}
256    FaultVect vect() {return _vect;}
257    FaultStat & countStat() {return _count;}
258    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
259                StaticInst::nullStaticInstPtr);
260};
261
262class ItbAcvFault : public ItbFault
263{
264  private:
265    static FaultName _name;
266    static FaultVect _vect;
267    static FaultStat _count;
268
269  public:
270    ItbAcvFault(Addr pc) : ItbFault(pc) { }
271    FaultName name() const {return _name;}
272    FaultVect vect() {return _vect;}
273    FaultStat & countStat() {return _count;}
274};
275
276class UnimplementedOpcodeFault : public AlphaFault
277{
278  private:
279    static FaultName _name;
280    static FaultVect _vect;
281    static FaultStat _count;
282
283  public:
284    FaultName name() const {return _name;}
285    FaultVect vect() {return _vect;}
286    FaultStat & countStat() {return _count;}
287};
288
289class FloatEnableFault : public AlphaFault
290{
291  private:
292    static FaultName _name;
293    static FaultVect _vect;
294    static FaultStat _count;
295
296  public:
297    FaultName name() const {return _name;}
298    FaultVect vect() {return _vect;}
299    FaultStat & countStat() {return _count;}
300};
301
302class VectorEnableFault : public AlphaFault
303{
304  private:
305    static FaultName _name;
306    static FaultVect _vect;
307    static FaultStat _count;
308
309  public:
310    FaultName name() const {return _name;}
311    FaultVect vect() {return _vect;}
312    FaultStat & countStat() {return _count;}
313};
314
315class PalFault : public AlphaFault
316{
317  private:
318    static FaultName _name;
319    static FaultVect _vect;
320    static FaultStat _count;
321
322  protected:
323    bool skipFaultingInstruction() {return true;}
324
325  public:
326    FaultName name() const {return _name;}
327    FaultVect vect() {return _vect;}
328    FaultStat & countStat() {return _count;}
329};
330
331class IntegerOverflowFault : public AlphaFault
332{
333  private:
334    static FaultName _name;
335    static FaultVect _vect;
336    static FaultStat _count;
337
338  public:
339    FaultName name() const {return _name;}
340    FaultVect vect() {return _vect;}
341    FaultStat & countStat() {return _count;}
342};
343
344} // namespace AlphaISA
345
346#endif // __ARCH_ALPHA_FAULTS_HH__
347