gem5  v22.1.0.0
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/null_static_inst.hh"
33 #include "cpu/static_inst.hh"
34 #include "sim/faults.hh"
35 
36 // The design of the "name" and "vect" functions is in sim/faults.hh
37 
38 namespace gem5
39 {
40 
41 namespace SparcISA
42 {
43 
44 typedef uint32_t TrapType;
45 typedef uint32_t FaultPriority;
46 
47 class ITB;
48 
49 class SparcFaultBase : public FaultBase
50 {
51  public:
53  {
54  U, User = U,
58  SH = -1,
60  };
61  using PrivilegeLevelSpec = std::array<PrivilegeLevel, NumLevels>;
62  struct FaultVals
63  {
64  const FaultName name;
68  FaultVals(const FaultName& name_, const TrapType& trapType_,
69  const FaultPriority& priority_, const PrivilegeLevelSpec& il)
70  : name(name_), trapType(trapType_), priority(priority_),
72  {}
73  };
74  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
76  virtual TrapType trapType() = 0;
77  virtual FaultPriority priority() = 0;
79 };
80 
81 template<typename T>
82 class SparcFault : public SparcFaultBase
83 {
84  protected:
85  static FaultVals vals;
86  public:
87  FaultName name() const { return vals.name; }
90 
93  {
94  return vals.nextPrivilegeLevel[current];
95  }
96 };
97 
98 class PowerOnReset : public SparcFault<PowerOnReset>
99 {
100  public:
101  void invoke(ThreadContext *tc, const StaticInstPtr &inst =
103 };
104 
105 class WatchDogReset : public SparcFault<WatchDogReset> {};
106 
107 class ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
108 
109 class SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
110 
111 class REDStateException : public SparcFault<REDStateException> {};
112 
113 class StoreError : public SparcFault<StoreError> {};
114 
115 class InstructionAccessException : public SparcFault<InstructionAccessException> {};
116 
117 // class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
118 
119 class InstructionAccessError : public SparcFault<InstructionAccessError> {};
120 
121 class IllegalInstruction : public SparcFault<IllegalInstruction> {};
122 
123 class PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
124 
125 // class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
126 
127 // class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
128 
129 class FpDisabled : public SparcFault<FpDisabled> {};
130 class VecDisabled : public SparcFault<VecDisabled> {};
131 
132 class FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
133 
134 class FpExceptionOther : public SparcFault<FpExceptionOther> {};
135 
136 class TagOverflow : public SparcFault<TagOverflow> {};
137 
138 class CleanWindow : public SparcFault<CleanWindow> {};
139 
140 class DivisionByZero : public SparcFault<DivisionByZero> {};
141 
143  public SparcFault<InternalProcessorError> {};
144 
146  public SparcFault<InstructionInvalidTSBEntry> {};
147 
148 class DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
149 
150 class DataAccessException : public SparcFault<DataAccessException> {};
151 
152 // class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
153 
154 class DataAccessError : public SparcFault<DataAccessError> {};
155 
156 class DataAccessProtection : public SparcFault<DataAccessProtection> {};
157 
159  public SparcFault<MemAddressNotAligned> {};
160 
161 class LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {};
162 
163 class STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {};
164 
165 class PrivilegedAction : public SparcFault<PrivilegedAction> {};
166 
167 class LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {};
168 
169 class STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {};
170 
172  public SparcFault<InstructionRealTranslationMiss> {};
173 
174 class DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
175 
176 // class AsyncDataError : public SparcFault<AsyncDataError> {};
177 
178 template <class T>
179 class EnumeratedFault : public SparcFault<T>
180 {
181  protected:
182  uint32_t _n;
183  public:
184  EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
186 };
187 
188 class InterruptLevelN : public EnumeratedFault<InterruptLevelN>
189 {
190  public:
192  FaultPriority priority() { return 3200 - _n*100; }
193 };
194 
195 class HstickMatch : public SparcFault<HstickMatch> {};
196 
197 class TrapLevelZero : public SparcFault<TrapLevelZero> {};
198 
199 class InterruptVector : public SparcFault<InterruptVector> {};
200 
201 class PAWatchpoint : public SparcFault<PAWatchpoint> {};
202 
203 class VAWatchpoint : public SparcFault<VAWatchpoint> {};
204 
206  public SparcFault<FastInstructionAccessMMUMiss>
207 {
208  protected:
210  public:
212  {}
214  {}
215  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
217 };
218 
219 class FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss>
220 {
221  protected:
223  public:
225  {}
227  {}
228  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
230 };
231 
232 class FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
233 
234 class InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
235 
236 class CpuMondo : public SparcFault<CpuMondo> {};
237 
238 class DevMondo : public SparcFault<DevMondo> {};
239 
240 class ResumableError : public SparcFault<ResumableError> {};
241 
242 class SpillNNormal : public EnumeratedFault<SpillNNormal>
243 {
244  public:
246  // These need to be handled specially to enable spill traps in SE
247  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
249 };
250 
251 class SpillNOther : public EnumeratedFault<SpillNOther>
252 {
253  public:
255  {}
256 };
257 
258 class FillNNormal : public EnumeratedFault<FillNNormal>
259 {
260  public:
262  {}
263  // These need to be handled specially to enable fill traps in SE
264  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
266 };
267 
268 class FillNOther : public EnumeratedFault<FillNOther>
269 {
270  public:
272  {}
273 };
274 
275 class TrapInstruction : public EnumeratedFault<TrapInstruction>
276 {
277  public:
279  {}
280  // In SE, trap instructions are requesting services from the OS.
281  void invoke(ThreadContext * tc, const StaticInstPtr &inst =
283 };
284 
285 /*
286  * Explicitly declare template static member variables to avoid warnings
287  * in some clang versions
288  */
291 template<> SparcFaultBase::FaultVals
296 template<> SparcFaultBase::FaultVals
309 template<> SparcFaultBase::FaultVals
316 template<> SparcFaultBase::FaultVals
318 template<> SparcFaultBase::FaultVals
321 template<> SparcFaultBase::FaultVals
323 template<> SparcFaultBase::FaultVals
325 template<> SparcFaultBase::FaultVals
334 template<> SparcFaultBase::FaultVals
337 template<>
348 
349 
350 void enterREDState(ThreadContext *tc);
351 
352 void doREDFault(ThreadContext *tc, TrapType tt);
353 
354 void doNormalFault(ThreadContext *tc, TrapType tt, bool gotoHpriv);
355 
356 void getREDVector(RegVal TT, Addr &PC, Addr &NPC);
357 
358 void getHyperVector(ThreadContext * tc, Addr &PC, Addr &NPC, RegVal TT);
359 
360 void getPrivVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT,
361  RegVal TL);
362 
363 } // namespace SparcISA
364 } // namespace gem5
365 
366 #endif // __SPARC_FAULTS_HH__
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:680
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:623
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:787
FillNOther(uint32_t n)
Definition: faults.hh:271
FaultPriority priority()
Definition: faults.hh:192
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:560
virtual PrivilegeLevel getNextLevel(PrivilegeLevel current)=0
virtual FaultPriority priority()=0
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:500
std::array< PrivilegeLevel, NumLevels > PrivilegeLevelSpec
Definition: faults.hh:61
virtual TrapType trapType()=0
static FaultVals vals
Definition: faults.hh:85
FaultName name() const
Definition: faults.hh:87
FaultPriority priority()
Definition: faults.hh:89
PrivilegeLevel getNextLevel(PrivilegeLevel current)
Definition: faults.hh:92
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:768
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:806
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Bitfield< 20 > il
Definition: misc_types.hh:61
Bitfield< 7 > n
Definition: misc.hh:142
uint32_t TrapType
Definition: faults.hh:44
void getREDVector(RegVal TT, Addr &PC, Addr &NPC)
Definition: faults.cc:473
void getHyperVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT)
Definition: faults.cc:482
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
uint32_t FaultPriority
Definition: faults.hh:45
void getPrivVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT, RegVal TL)
Definition: faults.cc:490
void enterREDState(ThreadContext *tc)
This causes the thread context to enter RED state.
Definition: faults.cc:282
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
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
const char * FaultName
Definition: faults.hh:53
uint64_t RegVal
Definition: types.hh:173
const StaticInstPtr nullStaticInstPtr
Statically allocated null StaticInstPtr.
FaultVals(const FaultName &name_, const TrapType &trapType_, const FaultPriority &priority_, const PrivilegeLevelSpec &il)
Definition: faults.hh:68
const PrivilegeLevelSpec nextPrivilegeLevel
Definition: faults.hh:67

Generated on Wed Dec 21 2022 10:22:24 for gem5 by doxygen 1.9.1