faults.hh (8570:ea93f18eead8) faults.hh (8571:13103d610fb7)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2007 MIPS Technologies, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Gabe Black
30 * Korey Sewell
31 * Jaidev Patwardhan
32 */
33
34#ifndef __MIPS_FAULTS_HH__
35#define __MIPS_FAULTS_HH__
36
37#include "sim/faults.hh"
38
39namespace MipsISA
40{
41
42typedef const Addr FaultVect;
43
44class MipsFaultBase : public FaultBase
45{
46 protected:
47 virtual bool skipFaultingInstruction() {return false;}
48 virtual bool setRestartAddress() {return true;}
49 public:
50 struct FaultVals
51 {
52 const FaultName name;
53 const FaultVect vect;
54 FaultStat count;
55 };
56
57 Addr badVAddr;
58 Addr entryHiAsid;
59 Addr entryHiVPN2;
60 Addr entryHiVPN2X;
61 Addr contextBadVPN2;
62#if FULL_SYSTEM
63 void invoke(ThreadContext * tc,
64 StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr)
65 {}
66 void setExceptionState(ThreadContext *, uint8_t);
67 void setHandlerPC(Addr, ThreadContext *);
68#endif
69};
70
71template <typename T>
72class MipsFault : public MipsFaultBase
73{
74 protected:
75 static FaultVals vals;
76 public:
77 FaultName name() const { return vals.name; }
78 FaultVect vect() const { return vals.vect; }
79 FaultStat & countStat() { return vals.count; }
80};
81
82class MachineCheckFault : public MipsFault<MachineCheckFault>
83{
84 public:
85 bool isMachineCheckFault() {return true;}
86};
87
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2007 MIPS Technologies, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Gabe Black
30 * Korey Sewell
31 * Jaidev Patwardhan
32 */
33
34#ifndef __MIPS_FAULTS_HH__
35#define __MIPS_FAULTS_HH__
36
37#include "sim/faults.hh"
38
39namespace MipsISA
40{
41
42typedef const Addr FaultVect;
43
44class MipsFaultBase : public FaultBase
45{
46 protected:
47 virtual bool skipFaultingInstruction() {return false;}
48 virtual bool setRestartAddress() {return true;}
49 public:
50 struct FaultVals
51 {
52 const FaultName name;
53 const FaultVect vect;
54 FaultStat count;
55 };
56
57 Addr badVAddr;
58 Addr entryHiAsid;
59 Addr entryHiVPN2;
60 Addr entryHiVPN2X;
61 Addr contextBadVPN2;
62#if FULL_SYSTEM
63 void invoke(ThreadContext * tc,
64 StaticInst::StaticInstPtr inst = StaticInst::nullStaticInstPtr)
65 {}
66 void setExceptionState(ThreadContext *, uint8_t);
67 void setHandlerPC(Addr, ThreadContext *);
68#endif
69};
70
71template <typename T>
72class MipsFault : public MipsFaultBase
73{
74 protected:
75 static FaultVals vals;
76 public:
77 FaultName name() const { return vals.name; }
78 FaultVect vect() const { return vals.vect; }
79 FaultStat & countStat() { return vals.count; }
80};
81
82class MachineCheckFault : public MipsFault<MachineCheckFault>
83{
84 public:
85 bool isMachineCheckFault() {return true;}
86};
87
88static inline Fault genMachineCheckFault()
89{
90 return new MachineCheckFault;
91}
92
88class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt>
89{
90 public:
91 bool isNonMaskableInterrupt() {return true;}
92};
93
94class AddressErrorFault : public MipsFault<AddressErrorFault>
95{
96 protected:
97 Addr vaddr;
98 bool store;
99 public:
100 AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store)
101 {}
102#if FULL_SYSTEM
103 void invoke(ThreadContext * tc,
104 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
105#endif
106
107};
108
93class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt>
94{
95 public:
96 bool isNonMaskableInterrupt() {return true;}
97};
98
99class AddressErrorFault : public MipsFault<AddressErrorFault>
100{
101 protected:
102 Addr vaddr;
103 bool store;
104 public:
105 AddressErrorFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store)
106 {}
107#if FULL_SYSTEM
108 void invoke(ThreadContext * tc,
109 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
110#endif
111
112};
113
109static inline Fault genMachineCheckFault()
110{
111 return new MachineCheckFault;
112}
113
114class ResetFault : public MipsFault<ResetFault>
115{
116 public:
117 void invoke(ThreadContext * tc,
118 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
119
120};
121
122class SystemCallFault : public MipsFault<SystemCallFault>
123{
124 public:
125#if FULL_SYSTEM
126 void invoke(ThreadContext * tc,
127 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
128#endif
129};
130
131class SoftResetFault : public MipsFault<SoftResetFault>
132{
133 public:
134 void invoke(ThreadContext * tc,
135 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
136};
137
138class CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault>
139{
140 protected:
141 int coProcID;
142 public:
143 CoprocessorUnusableFault(int _procid) : coProcID(_procid)
144 {}
145
146 void invoke(ThreadContext * tc,
147 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
148};
149
150class ReservedInstructionFault : public MipsFault<ReservedInstructionFault>
151{
152 public:
153 void invoke(ThreadContext * tc,
154 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
155};
156
157class ThreadFault : public MipsFault<ThreadFault>
158{
159 public:
160 void invoke(ThreadContext * tc,
161 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
162};
163
164class IntegerOverflowFault : public MipsFault<IntegerOverflowFault>
165{
166 protected:
167 bool skipFaultingInstruction() {return true;}
168 public:
169#if FULL_SYSTEM
170 void invoke(ThreadContext * tc,
171 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
172#endif
173};
174
175class InterruptFault : public MipsFault<InterruptFault>
176{
177 protected:
178 bool setRestartAddress() {return false;}
179 public:
180#if FULL_SYSTEM
181 void invoke(ThreadContext * tc,
182 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
183#endif
184};
185
186class TrapFault : public MipsFault<TrapFault>
187{
188 public:
189#if FULL_SYSTEM
190 void invoke(ThreadContext * tc,
191 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
192#endif
193};
194
195class BreakpointFault : public MipsFault<BreakpointFault>
196{
197 public:
198#if FULL_SYSTEM
199 void invoke(ThreadContext * tc,
200 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
201#endif
202};
203
204class ItbRefillFault : public MipsFault<ItbRefillFault>
205{
206 public:
207 ItbRefillFault(Addr asid, Addr vaddr, Addr vpn)
208 {
209 entryHiAsid = asid;
210 entryHiVPN2 = vpn >> 2;
211 entryHiVPN2X = vpn & 0x3;
212 badVAddr = vaddr;
213 contextBadVPN2 = vpn >> 2;
214 }
215#if FULL_SYSTEM
216 void invoke(ThreadContext * tc,
217 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
218#endif
219};
220
221class DtbRefillFault : public MipsFault<DtbRefillFault>
222{
223 public:
224 DtbRefillFault(Addr asid, Addr vaddr, Addr vpn)
225 {
226 entryHiAsid = asid;
227 entryHiVPN2 = vpn >> 2;
228 entryHiVPN2X = vpn & 0x3;
229 badVAddr = vaddr;
230 contextBadVPN2 = vpn >> 2;
231 }
232#if FULL_SYSTEM
233 void invoke(ThreadContext * tc,
234 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
235#endif
236};
237
238class ItbInvalidFault : public MipsFault<ItbInvalidFault>
239{
240 public:
241 ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn)
242 {
243 entryHiAsid = asid;
244 entryHiVPN2 = vpn >> 2;
245 entryHiVPN2X = vpn & 0x3;
246 badVAddr = vaddr;
247 contextBadVPN2 = vpn >> 2;
248 }
249#if FULL_SYSTEM
250 void invoke(ThreadContext * tc,
251 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
252#endif
253};
254
255class TLBModifiedFault : public MipsFault<TLBModifiedFault>
256{
257 public:
258 TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn)
259 {
260 entryHiAsid = asid;
261 entryHiVPN2 = vpn >> 2;
262 entryHiVPN2X = vpn & 0x3;
263 badVAddr = vaddr;
264 contextBadVPN2 = vpn >> 2;
265 }
266#if FULL_SYSTEM
267 void invoke(ThreadContext * tc,
268 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
269#endif
270};
271
272class DtbInvalidFault : public MipsFault<DtbInvalidFault>
273{
274 public:
275 DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn)
276 {
277 entryHiAsid = asid;
278 entryHiVPN2 = vpn >> 2;
279 entryHiVPN2X = vpn & 0x3;
280 badVAddr = vaddr;
281 contextBadVPN2 = vpn >> 2;
282 }
283#if FULL_SYSTEM
284 void invoke(ThreadContext * tc,
285 StaticInst::StaticInstPtr inst = nullStaticInstPtr);
286#endif
287};
288
289class DspStateDisabledFault : public MipsFault<DspStateDisabledFault>
290{
291 public:
292 void invoke(ThreadContext * tc,
293 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
294};
295
296} // namespace MipsISA
297
298#endif // __MIPS_FAULTS_HH__
114class ResetFault : public MipsFault<ResetFault>
115{
116 public:
117 void invoke(ThreadContext * tc,
118 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
119
120};
121
122class SystemCallFault : public MipsFault<SystemCallFault>
123{
124 public:
125#if FULL_SYSTEM
126 void invoke(ThreadContext * tc,
127 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
128#endif
129};
130
131class SoftResetFault : public MipsFault<SoftResetFault>
132{
133 public:
134 void invoke(ThreadContext * tc,
135 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
136};
137
138class CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault>
139{
140 protected:
141 int coProcID;
142 public:
143 CoprocessorUnusableFault(int _procid) : coProcID(_procid)
144 {}
145
146 void invoke(ThreadContext * tc,
147 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
148};
149
150class ReservedInstructionFault : public MipsFault<ReservedInstructionFault>
151{
152 public:
153 void invoke(ThreadContext * tc,
154 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
155};
156
157class ThreadFault : public MipsFault<ThreadFault>
158{
159 public:
160 void invoke(ThreadContext * tc,
161 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
162};
163
164class IntegerOverflowFault : public MipsFault<IntegerOverflowFault>
165{
166 protected:
167 bool skipFaultingInstruction() {return true;}
168 public:
169#if FULL_SYSTEM
170 void invoke(ThreadContext * tc,
171 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
172#endif
173};
174
175class InterruptFault : public MipsFault<InterruptFault>
176{
177 protected:
178 bool setRestartAddress() {return false;}
179 public:
180#if FULL_SYSTEM
181 void invoke(ThreadContext * tc,
182 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
183#endif
184};
185
186class TrapFault : public MipsFault<TrapFault>
187{
188 public:
189#if FULL_SYSTEM
190 void invoke(ThreadContext * tc,
191 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
192#endif
193};
194
195class BreakpointFault : public MipsFault<BreakpointFault>
196{
197 public:
198#if FULL_SYSTEM
199 void invoke(ThreadContext * tc,
200 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
201#endif
202};
203
204class ItbRefillFault : public MipsFault<ItbRefillFault>
205{
206 public:
207 ItbRefillFault(Addr asid, Addr vaddr, Addr vpn)
208 {
209 entryHiAsid = asid;
210 entryHiVPN2 = vpn >> 2;
211 entryHiVPN2X = vpn & 0x3;
212 badVAddr = vaddr;
213 contextBadVPN2 = vpn >> 2;
214 }
215#if FULL_SYSTEM
216 void invoke(ThreadContext * tc,
217 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
218#endif
219};
220
221class DtbRefillFault : public MipsFault<DtbRefillFault>
222{
223 public:
224 DtbRefillFault(Addr asid, Addr vaddr, Addr vpn)
225 {
226 entryHiAsid = asid;
227 entryHiVPN2 = vpn >> 2;
228 entryHiVPN2X = vpn & 0x3;
229 badVAddr = vaddr;
230 contextBadVPN2 = vpn >> 2;
231 }
232#if FULL_SYSTEM
233 void invoke(ThreadContext * tc,
234 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
235#endif
236};
237
238class ItbInvalidFault : public MipsFault<ItbInvalidFault>
239{
240 public:
241 ItbInvalidFault(Addr asid, Addr vaddr, Addr vpn)
242 {
243 entryHiAsid = asid;
244 entryHiVPN2 = vpn >> 2;
245 entryHiVPN2X = vpn & 0x3;
246 badVAddr = vaddr;
247 contextBadVPN2 = vpn >> 2;
248 }
249#if FULL_SYSTEM
250 void invoke(ThreadContext * tc,
251 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
252#endif
253};
254
255class TLBModifiedFault : public MipsFault<TLBModifiedFault>
256{
257 public:
258 TLBModifiedFault(Addr asid, Addr vaddr, Addr vpn)
259 {
260 entryHiAsid = asid;
261 entryHiVPN2 = vpn >> 2;
262 entryHiVPN2X = vpn & 0x3;
263 badVAddr = vaddr;
264 contextBadVPN2 = vpn >> 2;
265 }
266#if FULL_SYSTEM
267 void invoke(ThreadContext * tc,
268 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
269#endif
270};
271
272class DtbInvalidFault : public MipsFault<DtbInvalidFault>
273{
274 public:
275 DtbInvalidFault(Addr asid, Addr vaddr, Addr vpn)
276 {
277 entryHiAsid = asid;
278 entryHiVPN2 = vpn >> 2;
279 entryHiVPN2X = vpn & 0x3;
280 badVAddr = vaddr;
281 contextBadVPN2 = vpn >> 2;
282 }
283#if FULL_SYSTEM
284 void invoke(ThreadContext * tc,
285 StaticInst::StaticInstPtr inst = nullStaticInstPtr);
286#endif
287};
288
289class DspStateDisabledFault : public MipsFault<DspStateDisabledFault>
290{
291 public:
292 void invoke(ThreadContext * tc,
293 StaticInstPtr inst = StaticInst::nullStaticInstPtr);
294};
295
296} // namespace MipsISA
297
298#endif // __MIPS_FAULTS_HH__