Deleted Added
sdiff udiff text old ( 3575:295e99015da6 ) new ( 3576:c5a2b916a9fa )
full compact
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 __ALPHA_FAULTS_HH__
33#define __ALPHA_FAULTS_HH__
34
35#include "sim/faults.hh"
36
37// The design of the "name" and "vect" functions is in sim/faults.hh
38
39namespace SparcISA
40{
41
42typedef uint32_t TrapType;
43typedef uint32_t FaultPriority;
44
45class SparcFaultBase : public FaultBase
46{
47 public:
48 struct FaultVals
49 {
50 const FaultName name;
51 const TrapType trapType;
52 const FaultPriority priority;
53 FaultStat count;
54 };
55#if FULL_SYSTEM
56 void invoke(ThreadContext * tc);
57#endif
58 virtual FaultName name() = 0;
59 virtual TrapType trapType() = 0;
60 virtual FaultPriority priority() = 0;
61 virtual FaultStat & countStat() = 0;
62};
63
64template<typename T>
65class SparcFault : public SparcFaultBase
66{
67 protected:
68 static FaultVals vals;
69 public:
70 FaultName name() {return vals.name;}
71 TrapType trapType() {return vals.trapType;}
72 FaultPriority priority() {return vals.priority;}
73 FaultStat & countStat() {return vals.count;}
74};
75
76class InternalProcessorError :
77 public SparcFault<InternalProcessorError>
78{
79 public:
80 bool isMachineCheckFault() {return true;}
81};
82
83class MemAddressNotAligned :
84 public SparcFault<MemAddressNotAligned>
85{
86 public:
87 bool isAlignmentFault() {return true;}
88};
89
90#if !FULL_SYSTEM
91class PageTableFault : public SparcFault<PageTableFault>
92{
93 private:
94 Addr vaddr;
95 public:
96 PageTableFault(Addr va) : vaddr(va) {}
97 void invoke(ThreadContext * tc);
98};
99
100static inline Fault genPageTableFault(Addr va)
101{
102 return new PageTableFault(va);
103}
104#endif
105
106static inline Fault genMachineCheckFault()
107{
108 return new InternalProcessorError;
109}
110
111static inline Fault genAlignmentFault()
112{
113 return new MemAddressNotAligned;
114}
115
116class PowerOnReset : public SparcFault<PowerOnReset>
117{
118 void invoke(ThreadContext * tc);
119};
120
121class WatchDogReset : public SparcFault<WatchDogReset> {};
122
123class ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
124
125class SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
126
127class REDStateException : public SparcFault<REDStateException> {};
128
129class InstructionAccessException : public SparcFault<InstructionAccessException> {};
130
131class InstructionAccessMMUMiss : public SparcFault {};
132
133class InstructionAccessError : public SparcFault<InstructionAccessError> {};
134
135class IllegalInstruction : public SparcFault<IllegalInstruction> {};
136
137class PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
138
139class UnimplementedLDD : public SparcFault {};
140
141class UnimplementedSTD : public SparcFault {};
142
143class FpDisabled : public SparcFault<FpDisabled> {};
144
145class FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
146
147class FpExceptionOther : public SparcFault<FpExceptionOther> {};
148
149class TagOverflow : public SparcFault<TagOverflow> {};
150
151class DivisionByZero : public SparcFault<DivisionByZero> {};
152
153class DataAccessException : public SparcFault<DataAccessException> {};
154
155class DataAccessMMUMiss : public SparcFault {};
156
157class DataAccessError : public SparcFault<DataAccessError> {};
158
159class DataAccessProtection : public SparcFault<DataAccessProtection> {};
160
161class LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
162
163class STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
164
165class PrivilegedAction : public SparcFault<PrivilegedAction> {};
166
167class LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
168
169class STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
170
171class AsyncDataError : public SparcFault<AsyncDataError> {};
172
173class CleanWindow : public SparcFault<CleanWindow> {};
174
175template <class T>
176class EnumeratedFault : public SparcFault<T>
177{
178 protected:
179 uint32_t _n;
180 public:
181 EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
182 TrapType trapType() {return SparcFault<T>::trapType() + _n;}
183};
184
185class InterruptLevelN : public EnumeratedFault<InterruptLevelN>
186{
187 public:
188 InterruptLevelN(uint32_t n) :
189 EnumeratedFault<InterruptLevelN>(n) {;}
190 FaultPriority priority() {return 32 - _n;}
191};
192
193class SpillNNormal : public EnumeratedFault<SpillNNormal>
194{
195 public:
196 SpillNNormal(uint32_t n) :
197 EnumeratedFault<SpillNNormal>(n) {;}
198 //These need to be handled specially to enable spill traps in SE
199#if !FULL_SYSTEM
200 void invoke(ThreadContext * tc);
201#endif
202};
203
204class SpillNOther : public EnumeratedFault<SpillNOther>
205{
206 public:
207 SpillNOther(uint32_t n) :
208 EnumeratedFault<SpillNOther>(n) {;}
209};
210
211class FillNNormal : public EnumeratedFault<FillNNormal>
212{
213 public:
214 FillNNormal(uint32_t n) :
215 EnumeratedFault<FillNNormal>(n) {;}
216 //These need to be handled specially to enable fill traps in SE
217#if !FULL_SYSTEM
218 void invoke(ThreadContext * tc);
219#endif
220};
221
222class FillNOther : public EnumeratedFault<FillNOther>
223{
224 public:
225 FillNOther(uint32_t n) :
226 EnumeratedFault<FillNOther>(n) {;}
227};
228
229class TrapInstruction : public EnumeratedFault<TrapInstruction>
230{
231
232 public:
233 TrapInstruction(uint32_t n) :
234 EnumeratedFault<TrapInstruction>(n) {;}
235};
236
237
238} // SparcISA namespace
239
240#endif // __FAULTS_HH__