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

Generated on Fri Jul 3 2020 15:42:38 for gem5 by doxygen 1.8.13