gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
faults.hh
Go to the documentation of this file.
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 __SPARC_FAULTS_HH__
33 #define __SPARC_FAULTS_HH__
34 
35 #include "cpu/static_inst.hh"
36 #include "sim/faults.hh"
37 
38 // The design of the "name" and "vect" functions is in sim/faults.hh
39 
40 namespace SparcISA
41 {
42 
43 typedef uint32_t TrapType;
44 typedef uint32_t FaultPriority;
45 
46 class ITB;
47 
48 class SparcFaultBase : public FaultBase
49 {
50  public:
52  {
53  U, User = U,
57  SH = -1,
59  };
60  using PrivilegeLevelSpec = std::array<PrivilegeLevel, NumLevels>;
61  struct FaultVals
62  {
63  const FaultName name;
64  const TrapType trapType;
65  const FaultPriority priority;
68  FaultVals(const FaultName& name_, const TrapType& trapType_,
69  const FaultPriority& priority_, const PrivilegeLevelSpec& il)
70  : name(name_), trapType(trapType_), priority(priority_),
71  nextPrivilegeLevel(il)
72  {}
73  };
74  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
76  virtual TrapType trapType() = 0;
77  virtual FaultPriority priority() = 0;
78  virtual FaultStat & countStat() = 0;
79  virtual PrivilegeLevel getNextLevel(PrivilegeLevel current) = 0;
80 };
81 
82 template<typename T>
83 class SparcFault : public SparcFaultBase
84 {
85  protected:
86  static FaultVals vals;
87  public:
88  FaultName name() const { return vals.name; }
89  TrapType trapType() { return vals.trapType; }
90  FaultPriority priority() { return vals.priority; }
91  FaultStat & countStat() { return vals.count; }
92 
95  {
96  return vals.nextPrivilegeLevel[current];
97  }
98 };
99 
100 class PowerOnReset : public SparcFault<PowerOnReset>
101 {
102  public:
103  void invoke(ThreadContext *tc, const StaticInstPtr &inst =
105 };
106 
107 class WatchDogReset : public SparcFault<WatchDogReset> {};
108 
109 class ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
110 
111 class SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
112 
113 class REDStateException : public SparcFault<REDStateException> {};
114 
115 class StoreError : public SparcFault<StoreError> {};
116 
117 class InstructionAccessException : public SparcFault<InstructionAccessException> {};
118 
119 // class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
120 
121 class InstructionAccessError : public SparcFault<InstructionAccessError> {};
122 
123 class IllegalInstruction : public SparcFault<IllegalInstruction> {};
124 
125 class PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
126 
127 // class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
128 
129 // class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
130 
131 class FpDisabled : public SparcFault<FpDisabled> {};
132 class VecDisabled : public SparcFault<VecDisabled> {};
133 
134 class FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
135 
136 class FpExceptionOther : public SparcFault<FpExceptionOther> {};
137 
138 class TagOverflow : public SparcFault<TagOverflow> {};
139 
140 class CleanWindow : public SparcFault<CleanWindow> {};
141 
142 class DivisionByZero : public SparcFault<DivisionByZero> {};
143 
145  public SparcFault<InternalProcessorError> {};
146 
148  public SparcFault<InstructionInvalidTSBEntry> {};
149 
150 class DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
151 
152 class DataAccessException : public SparcFault<DataAccessException> {};
153 
154 // class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
155 
156 class DataAccessError : public SparcFault<DataAccessError> {};
157 
158 class DataAccessProtection : public SparcFault<DataAccessProtection> {};
159 
161  public SparcFault<MemAddressNotAligned> {};
162 
163 class LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
164 
165 class STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
166 
167 class PrivilegedAction : public SparcFault<PrivilegedAction> {};
168 
169 class LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
170 
171 class STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
172 
174  public SparcFault<InstructionRealTranslationMiss> {};
175 
176 class DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
177 
178 // class AsyncDataError : public SparcFault<AsyncDataError> {};
179 
180 template <class T>
181 class EnumeratedFault : public SparcFault<T>
182 {
183  protected:
184  uint32_t _n;
185  public:
186  EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
187  TrapType trapType() { return SparcFault<T>::trapType() + _n; }
188 };
189 
190 class InterruptLevelN : public EnumeratedFault<InterruptLevelN>
191 {
192  public:
194  FaultPriority priority() { return 3200 - _n*100; }
195 };
196 
197 class HstickMatch : public SparcFault<HstickMatch> {};
198 
199 class TrapLevelZero : public SparcFault<TrapLevelZero> {};
200 
201 class InterruptVector : public SparcFault<InterruptVector> {};
202 
203 class PAWatchpoint : public SparcFault<PAWatchpoint> {};
204 
205 class VAWatchpoint : public SparcFault<VAWatchpoint> {};
206 
208  public SparcFault<FastInstructionAccessMMUMiss>
209 {
210  protected:
212  public:
214  {}
216  {}
217  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
219 };
220 
221 class FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss>
222 {
223  protected:
225  public:
227  {}
229  {}
230  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
232 };
233 
234 class FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
235 
236 class InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
237 
238 class CpuMondo : public SparcFault<CpuMondo> {};
239 
240 class DevMondo : public SparcFault<DevMondo> {};
241 
242 class ResumableError : public SparcFault<ResumableError> {};
243 
244 class SpillNNormal : public EnumeratedFault<SpillNNormal>
245 {
246  public:
248  // These need to be handled specially to enable spill traps in SE
249  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
251 };
252 
253 class SpillNOther : public EnumeratedFault<SpillNOther>
254 {
255  public:
257  {}
258 };
259 
260 class FillNNormal : public EnumeratedFault<FillNNormal>
261 {
262  public:
264  {}
265  // These need to be handled specially to enable fill traps in SE
266  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
268 };
269 
270 class FillNOther : public EnumeratedFault<FillNOther>
271 {
272  public:
274  {}
275 };
276 
277 class TrapInstruction : public EnumeratedFault<TrapInstruction>
278 {
279  public:
281  {}
282  // In SE, trap instructions are requesting services from the OS.
283  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
285 };
286 
287 /*
288  * Explicitly declare template static member variables to avoid warnings
289  * in some clang versions
290  */
293 template<> SparcFaultBase::FaultVals
298 template<> SparcFaultBase::FaultVals
311 template<> SparcFaultBase::FaultVals
318 template<> SparcFaultBase::FaultVals
320 template<> SparcFaultBase::FaultVals
323 template<> SparcFaultBase::FaultVals
325 template<> SparcFaultBase::FaultVals
327 template<> SparcFaultBase::FaultVals
336 template<> SparcFaultBase::FaultVals
339 template<>
350 
351 
352 void enterREDState(ThreadContext *tc);
353 
354 void doREDFault(ThreadContext *tc, TrapType tt);
355 
356 void doNormalFault(ThreadContext *tc, TrapType tt, bool gotoHpriv);
357 
358 void getREDVector(RegVal TT, Addr &PC, Addr &NPC);
359 
360 void getHyperVector(ThreadContext * tc, Addr &PC, Addr &NPC, RegVal TT);
361 
362 void getPrivVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT,
363  RegVal TL);
364 
365 } // namespace SparcISA
366 
367 #endif // __SPARC_FAULTS_HH__
void getREDVector(RegVal TT, Addr &PC, Addr &NPC)
Definition: faults.cc:473
virtual PrivilegeLevel getNextLevel(PrivilegeLevel current)=0
uint32_t TrapType
Definition: faults.hh:43
void doNormalFault(ThreadContext *tc, TrapType tt, bool gotoHpriv)
This sets everything up for a normal trap except for actually jumping to the handler.
Definition: faults.cc:382
void getHyperVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT)
Definition: faults.cc:482
ip6_addr_t addr
Definition: inet.hh:335
uint64_t RegVal
Definition: types.hh:168
FaultStat & countStat()
Definition: faults.hh:91
FillNNormal(uint32_t n)
Definition: faults.hh:263
static FaultVals vals
Definition: faults.hh:86
FaultPriority priority()
Definition: faults.hh:194
ThreadContext is the external interface to all thread state for anything outside of the CPU...
SpillNNormal(uint32_t n)
Definition: faults.hh:247
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
Bitfield< 31 > n
FaultVals(const FaultName &name_, const TrapType &trapType_, const FaultPriority &priority_, const PrivilegeLevelSpec &il)
Definition: faults.hh:68
const char * FaultName
Definition: faults.hh:39
FaultPriority priority()
Definition: faults.hh:90
EnumeratedFault(uint32_t n)
Definition: faults.hh:186
const PrivilegeLevelSpec nextPrivilegeLevel
Definition: faults.hh:66
void enterREDState(ThreadContext *tc)
This causes the thread context to enter RED state.
Definition: faults.cc:282
std::array< PrivilegeLevel, NumLevels > PrivilegeLevelSpec
Definition: faults.hh:60
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
const FaultPriority priority
Definition: faults.hh:65
virtual FaultStat & countStat()=0
uint32_t FaultPriority
Definition: faults.hh:44
PrivilegeLevel getNextLevel(PrivilegeLevel current)
Definition: faults.hh:94
Definition: asi.cc:34
SpillNOther(uint32_t n)
Definition: faults.hh:256
FillNOther(uint32_t n)
Definition: faults.hh:273
void doREDFault(ThreadContext *tc, TrapType tt)
This sets everything up for a RED state trap except for actually jumping to the handler.
Definition: faults.cc:303
InterruptLevelN(uint32_t n)
Definition: faults.hh:193
static StaticInstPtr nullStaticInstPtr
Pointer to a statically allocated "null" instruction object.
Definition: static_inst.hh:223
void getPrivVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT, RegVal TL)
Definition: faults.cc:490
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:500
Bitfield< 20 > il
TrapType trapType()
Definition: faults.hh:89
FaultName name() const
Definition: faults.hh:88
TrapInstruction(uint32_t n)
Definition: faults.hh:280

Generated on Fri Feb 28 2020 16:26:55 for gem5 by doxygen 1.8.13