gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
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
38namespace gem5
39{
40
41namespace SparcISA
42{
43
44typedef uint32_t TrapType;
45typedef uint32_t FaultPriority;
46
47class ITB;
48
50{
51 public:
61 using PrivilegeLevelSpec = std::array<PrivilegeLevel, NumLevels>;
62 struct FaultVals
63 {
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
81template<typename T>
83{
84 protected:
86 public:
87 FaultName name() const { return vals.name; }
90
93 {
94 return vals.nextPrivilegeLevel[current];
95 }
96};
97
98class PowerOnReset : public SparcFault<PowerOnReset>
99{
100 public:
101 void invoke(ThreadContext *tc, const StaticInstPtr &inst =
103};
104
105class WatchDogReset : public SparcFault<WatchDogReset> {};
106
107class ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {};
108
109class SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {};
110
111class REDStateException : public SparcFault<REDStateException> {};
112
113class StoreError : public SparcFault<StoreError> {};
114
115class InstructionAccessException : public SparcFault<InstructionAccessException> {};
116
117// class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {};
118
119class InstructionAccessError : public SparcFault<InstructionAccessError> {};
120
121class IllegalInstruction : public SparcFault<IllegalInstruction> {};
122
123class PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {};
124
125// class UnimplementedLDD : public SparcFault<UnimplementedLDD> {};
126
127// class UnimplementedSTD : public SparcFault<UnimplementedSTD> {};
128
129class FpDisabled : public SparcFault<FpDisabled> {};
130class VecDisabled : public SparcFault<VecDisabled> {};
131
132class FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {};
133
134class FpExceptionOther : public SparcFault<FpExceptionOther> {};
135
136class TagOverflow : public SparcFault<TagOverflow> {};
137
138class CleanWindow : public SparcFault<CleanWindow> {};
139
140class DivisionByZero : public SparcFault<DivisionByZero> {};
141
143 public SparcFault<InternalProcessorError> {};
144
146 public SparcFault<InstructionInvalidTSBEntry> {};
147
148class DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {};
149
150class DataAccessException : public SparcFault<DataAccessException> {};
151
152// class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {};
153
154class DataAccessError : public SparcFault<DataAccessError> {};
155
156class DataAccessProtection : public SparcFault<DataAccessProtection> {};
157
159 public SparcFault<MemAddressNotAligned> {};
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
172 public SparcFault<InstructionRealTranslationMiss> {};
173
174class DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {};
175
176// class AsyncDataError : public SparcFault<AsyncDataError> {};
177
178template <class T>
180{
181 protected:
182 uint32_t _n;
183 public:
184 EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {}
186};
187
188class InterruptLevelN : public EnumeratedFault<InterruptLevelN>
189{
190 public:
192 FaultPriority priority() { return 3200 - _n*100; }
193};
194
195class HstickMatch : public SparcFault<HstickMatch> {};
196
197class TrapLevelZero : public SparcFault<TrapLevelZero> {};
198
199class InterruptVector : public SparcFault<InterruptVector> {};
200
201class PAWatchpoint : public SparcFault<PAWatchpoint> {};
202
203class VAWatchpoint : public SparcFault<VAWatchpoint> {};
204
206 public SparcFault<FastInstructionAccessMMUMiss>
207{
208 protected:
210 public:
215 void invoke(ThreadContext * tc, const StaticInstPtr &inst =
217};
218
219class FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss>
220{
221 protected:
223 public:
228 void invoke(ThreadContext * tc, const StaticInstPtr &inst =
230};
231
232class FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {};
233
234class InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {};
235
236class CpuMondo : public SparcFault<CpuMondo> {};
237
238class DevMondo : public SparcFault<DevMondo> {};
239
240class ResumableError : public SparcFault<ResumableError> {};
241
242class 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
251class SpillNOther : public EnumeratedFault<SpillNOther>
252{
253 public:
256};
257
258class FillNNormal : public EnumeratedFault<FillNNormal>
259{
260 public:
263 // These need to be handled specially to enable fill traps in SE
264 void invoke(ThreadContext * tc, const StaticInstPtr &inst =
266};
267
268class FillNOther : public EnumeratedFault<FillNOther>
269{
270 public:
273};
274
275class TrapInstruction : public EnumeratedFault<TrapInstruction>
276{
277 public:
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 */
337template<>
348
349
351
352void doREDFault(ThreadContext *tc, TrapType tt);
353
354void doNormalFault(ThreadContext *tc, TrapType tt, bool gotoHpriv);
355
356void getREDVector(RegVal TT, Addr &PC, Addr &NPC);
357
358void getHyperVector(ThreadContext * tc, Addr &PC, Addr &NPC, RegVal TT);
359
360void 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:677
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition faults.cc:620
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition faults.cc:784
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition faults.cc:557
virtual PrivilegeLevel getNextLevel(PrivilegeLevel current)=0
virtual FaultPriority priority()=0
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition faults.cc:497
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:765
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition faults.cc:803
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:470
void getHyperVector(ThreadContext *tc, Addr &PC, Addr &NPC, RegVal TT)
Definition faults.cc:479
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:487
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:379
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t RegVal
Definition types.hh:173
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:55
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 Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0