gem5
v20.0.0.3
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
+
Enumerations
a
b
c
d
e
f
i
l
m
o
p
r
s
t
v
x
+
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
w
+
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Related Functions
:
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
+
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
+
Enumerations
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
v
w
+
Enumerator
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
arch
riscv
faults.hh
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016 RISC-V Foundation
3
* Copyright (c) 2016 The University of Virginia
4
* Copyright (c) 2018 TU Dresden
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
9
* met: redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer;
11
* redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution;
14
* neither the name of the copyright holders nor the names of its
15
* contributors may be used to endorse or promote products derived from
16
* this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#ifndef __ARCH_RISCV_FAULTS_HH__
32
#define __ARCH_RISCV_FAULTS_HH__
33
34
#include <string>
35
36
#include "
arch/riscv/isa.hh
"
37
#include "
arch/riscv/registers.hh
"
38
#include "
cpu/thread_context.hh
"
39
#include "
sim/faults.hh
"
40
41
namespace
RiscvISA
42
{
43
44
enum
FloatException
: uint64_t {
45
FloatInexact
= 0x1,
46
FloatUnderflow
= 0x2,
47
FloatOverflow
= 0x4,
48
FloatDivZero
= 0x8,
49
FloatInvalid
= 0x10
50
};
51
52
/*
53
* In RISC-V, exception and interrupt codes share some values. They can be
54
* differentiated by an 'Interrupt' flag that is enabled for interrupt faults
55
* but not exceptions. The full fault cause can be computed by placing the
56
* exception (or interrupt) code in the least significant bits of the CAUSE
57
* CSR and then setting the highest bit of CAUSE with the 'Interrupt' flag.
58
* For more details on exception causes, see Chapter 3.1.20 of the RISC-V
59
* privileged specification v 1.10. Codes are enumerated in Table 3.6.
60
*/
61
enum
ExceptionCode
: uint64_t {
62
INST_ADDR_MISALIGNED
= 0,
63
INST_ACCESS
= 1,
64
INST_ILLEGAL
= 2,
65
BREAKPOINT
= 3,
66
LOAD_ADDR_MISALIGNED
= 4,
67
LOAD_ACCESS
= 5,
68
STORE_ADDR_MISALIGNED
= 6,
69
AMO_ADDR_MISALIGNED
= 6,
70
STORE_ACCESS
= 7,
71
AMO_ACCESS
= 7,
72
ECALL_USER
= 8,
73
ECALL_SUPER
= 9,
74
ECALL_MACHINE
= 11,
75
INST_PAGE
= 12,
76
LOAD_PAGE
= 13,
77
STORE_PAGE
= 15,
78
AMO_PAGE
= 15,
79
80
INT_SOFTWARE_USER
= 0,
81
INT_SOFTWARE_SUPER
= 1,
82
INT_SOFTWARE_MACHINE
= 3,
83
INT_TIMER_USER
= 4,
84
INT_TIMER_SUPER
= 5,
85
INT_TIMER_MACHINE
= 7,
86
INT_EXT_USER
= 8,
87
INT_EXT_SUPER
= 9,
88
INT_EXT_MACHINE
= 11,
89
NumInterruptTypes
90
};
91
92
class
RiscvFault
:
public
FaultBase
93
{
94
protected
:
95
const
FaultName
_name
;
96
const
bool
_interrupt
;
97
ExceptionCode
_code
;
98
99
RiscvFault
(
FaultName
n
,
bool
i
,
ExceptionCode
c
)
100
: _name(n), _interrupt(i), _code(c)
101
{}
102
103
FaultName
name
()
const override
{
return
_name
; }
104
bool
isInterrupt
()
const
{
return
_interrupt
; }
105
ExceptionCode
exception
()
const
{
return
_code
; }
106
virtual
RegVal
trap_value
()
const
{
return
0; }
107
108
virtual
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst);
109
void
invoke
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
110
};
111
112
class
Reset
:
public
FaultBase
113
{
114
private
:
115
const
FaultName
_name
;
116
117
public
:
118
Reset
() : _name(
"reset"
) {}
119
FaultName
name
()
const override
{
return
_name
; }
120
121
void
invoke
(
ThreadContext
*tc,
const
StaticInstPtr
&inst =
122
StaticInst::nullStaticInstPtr
)
override
;
123
};
124
125
class
InterruptFault
:
public
RiscvFault
126
{
127
public
:
128
InterruptFault
(
ExceptionCode
c
) :
RiscvFault
(
"interrupt"
, true, c) {}
129
InterruptFault
(
int
c
) :
InterruptFault
(static_cast<
ExceptionCode
>(c)) {}
130
};
131
132
class
InstFault
:
public
RiscvFault
133
{
134
protected
:
135
const
ExtMachInst
_inst
;
136
137
public
:
138
InstFault
(
FaultName
n
,
const
ExtMachInst
inst)
139
:
RiscvFault
(n, false,
INST_ILLEGAL
), _inst(inst)
140
{}
141
142
RegVal
trap_value
()
const override
{
return
_inst; }
143
};
144
145
class
UnknownInstFault
:
public
InstFault
146
{
147
public
:
148
UnknownInstFault
(
const
ExtMachInst
inst)
149
:
InstFault
(
"Unknown instruction"
, inst)
150
{}
151
152
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
153
};
154
155
class
IllegalInstFault
:
public
InstFault
156
{
157
private
:
158
const
std::string
reason
;
159
160
public
:
161
IllegalInstFault
(std::string
r
,
const
ExtMachInst
inst)
162
:
InstFault
(
"Illegal instruction"
, inst)
163
{}
164
165
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
166
};
167
168
class
UnimplementedFault
:
public
InstFault
169
{
170
private
:
171
const
std::string
instName
;
172
173
public
:
174
UnimplementedFault
(std::string
name
,
const
ExtMachInst
inst)
175
:
InstFault
(
"Unimplemented instruction"
, inst),
176
instName(name)
177
{}
178
179
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
180
};
181
182
class
IllegalFrmFault
:
public
InstFault
183
{
184
private
:
185
const
uint8_t
frm
;
186
187
public
:
188
IllegalFrmFault
(uint8_t
r
,
const
ExtMachInst
inst)
189
:
InstFault
(
"Illegal floating-point rounding mode"
, inst),
190
frm(r)
191
{}
192
193
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
194
};
195
196
class
AddressFault
:
public
RiscvFault
197
{
198
private
:
199
const
Addr
_addr
;
200
201
public
:
202
AddressFault
(
const
Addr
addr
,
ExceptionCode
code)
203
:
RiscvFault
(
"Address"
, false, code), _addr(addr)
204
{}
205
206
RegVal
trap_value
()
const override
{
return
_addr; }
207
};
208
209
class
BreakpointFault
:
public
RiscvFault
210
{
211
private
:
212
const
PCState
pcState
;
213
214
public
:
215
BreakpointFault
(
const
PCState
&
pc
)
216
:
RiscvFault
(
"Breakpoint"
, false,
BREAKPOINT
), pcState(pc)
217
{}
218
219
RegVal
trap_value
()
const override
{
return
pcState.
pc
(); }
220
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
221
};
222
223
class
SyscallFault
:
public
RiscvFault
224
{
225
public
:
226
SyscallFault
(
PrivilegeMode
prv)
227
:
RiscvFault
(
"System call"
, false,
ECALL_USER
)
228
{
229
switch
(prv) {
230
case
PRV_U
:
231
_code
=
ECALL_USER
;
232
break
;
233
case
PRV_S
:
234
_code
=
ECALL_SUPER
;
235
break
;
236
case
PRV_M
:
237
_code
=
ECALL_MACHINE
;
238
break
;
239
default
:
240
panic
(
"Unknown privilege mode %d."
, prv);
241
break
;
242
}
243
}
244
245
void
invokeSE
(
ThreadContext
*tc,
const
StaticInstPtr
&inst)
override
;
246
};
247
248
}
// namespace RiscvISA
249
250
#endif // __ARCH_RISCV_FAULTS_HH__
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition:
logging.hh:163
RiscvISA::UnimplementedFault::UnimplementedFault
UnimplementedFault(std::string name, const ExtMachInst inst)
Definition:
faults.hh:174
RiscvISA::PRV_M
Definition:
isa.hh:60
RiscvISA::INT_TIMER_USER
Definition:
faults.hh:83
RiscvISA::PCState
Definition:
types.hh:53
RiscvISA::Reset::Reset
Reset()
Definition:
faults.hh:118
RiscvISA::RiscvFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst) override
Definition:
faults.cc:54
RiscvISA::ECALL_MACHINE
Definition:
faults.hh:74
RiscvISA::INT_EXT_MACHINE
Definition:
faults.hh:88
RiscvISA::RiscvFault::_code
ExceptionCode _code
Definition:
faults.hh:97
RiscvISA::INT_SOFTWARE_MACHINE
Definition:
faults.hh:82
RiscvISA::STORE_ACCESS
Definition:
faults.hh:70
RiscvISA::STORE_ADDR_MISALIGNED
Definition:
faults.hh:68
addr
ip6_addr_t addr
Definition:
inet.hh:330
RiscvISA::IllegalFrmFault::IllegalFrmFault
IllegalFrmFault(uint8_t r, const ExtMachInst inst)
Definition:
faults.hh:188
RiscvISA::UnknownInstFault
Definition:
faults.hh:145
RiscvISA::IllegalInstFault::reason
const std::string reason
Definition:
faults.hh:158
RiscvISA::r
Bitfield< 1 > r
Definition:
pagetable.hh:71
RiscvISA::ExceptionCode
ExceptionCode
Definition:
faults.hh:61
RiscvISA::BreakpointFault
Definition:
faults.hh:209
RegVal
uint64_t RegVal
Definition:
types.hh:166
RiscvISA::InstFault::InstFault
InstFault(FaultName n, const ExtMachInst inst)
Definition:
faults.hh:138
RiscvISA::ExtMachInst
uint64_t ExtMachInst
Definition:
types.hh:51
RiscvISA::FloatUnderflow
Definition:
faults.hh:46
RiscvISA::INT_SOFTWARE_SUPER
Definition:
faults.hh:81
RiscvISA::IllegalFrmFault
Definition:
faults.hh:182
isa.hh
RiscvISA::RiscvFault::trap_value
virtual RegVal trap_value() const
Definition:
faults.hh:106
RefCountingPtr< StaticInst >
RiscvISA::INST_ADDR_MISALIGNED
Definition:
faults.hh:62
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Definition:
thread_context.hh:91
RiscvISA::UnimplementedFault
Definition:
faults.hh:168
RiscvISA::ECALL_SUPER
Definition:
faults.hh:73
RiscvISA::INT_TIMER_MACHINE
Definition:
faults.hh:85
RiscvISA::AddressFault::trap_value
RegVal trap_value() const override
Definition:
faults.hh:206
GenericISA::SimplePCState::pc
Addr pc() const
Definition:
types.hh:146
RiscvISA::Reset::name
FaultName name() const override
Definition:
faults.hh:119
ArmISA::n
Bitfield< 31 > n
Definition:
miscregs_types.hh:450
RiscvISA::NumInterruptTypes
Definition:
faults.hh:89
RiscvISA::InterruptFault::InterruptFault
InterruptFault(ExceptionCode c)
Definition:
faults.hh:128
RiscvISA::AMO_ACCESS
Definition:
faults.hh:71
RiscvISA::LOAD_PAGE
Definition:
faults.hh:76
RiscvISA::RiscvFault::invokeSE
virtual void invokeSE(ThreadContext *tc, const StaticInstPtr &inst)
Definition:
faults.cc:48
RiscvISA::InterruptFault
Definition:
faults.hh:125
RiscvISA::UnimplementedFault::instName
const std::string instName
Definition:
faults.hh:171
RiscvISA::pc
Bitfield< 4 > pc
Definition:
pra_constants.hh:240
RiscvISA::BreakpointFault::trap_value
RegVal trap_value() const override
Definition:
faults.hh:219
RiscvISA::BreakpointFault::pcState
const PCState pcState
Definition:
faults.hh:212
RiscvISA::AddressFault::_addr
const Addr _addr
Definition:
faults.hh:199
RiscvISA::LOAD_ADDR_MISALIGNED
Definition:
faults.hh:66
FaultName
const char * FaultName
Definition:
faults.hh:36
RiscvISA::SyscallFault
Definition:
faults.hh:223
RiscvISA::InstFault
Definition:
faults.hh:132
faults.hh
RiscvISA::i
Bitfield< 2 > i
Definition:
pra_constants.hh:276
RiscvISA::PRV_S
Definition:
isa.hh:59
RiscvISA::AMO_ADDR_MISALIGNED
Definition:
faults.hh:69
RiscvISA::INST_ILLEGAL
Definition:
faults.hh:64
RiscvISA::Reset
Definition:
faults.hh:112
RiscvISA::FloatOverflow
Definition:
faults.hh:47
RiscvISA::ECALL_USER
Definition:
faults.hh:72
RiscvISA::STORE_PAGE
Definition:
faults.hh:77
registers.hh
RiscvISA::IllegalFrmFault::frm
const uint8_t frm
Definition:
faults.hh:185
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition:
types.hh:140
RiscvISA::INT_SOFTWARE_USER
Definition:
faults.hh:80
RiscvISA::PrivilegeMode
PrivilegeMode
Definition:
isa.hh:56
RiscvISA::RiscvFault
Definition:
faults.hh:92
RiscvISA::INST_PAGE
Definition:
faults.hh:75
RiscvISA::InstFault::_inst
const ExtMachInst _inst
Definition:
faults.hh:135
RiscvISA::RiscvFault::isInterrupt
bool isInterrupt() const
Definition:
faults.hh:104
RiscvISA::RiscvFault::RiscvFault
RiscvFault(FaultName n, bool i, ExceptionCode c)
Definition:
faults.hh:99
RiscvISA::INST_ACCESS
Definition:
faults.hh:63
RiscvISA::IllegalInstFault::IllegalInstFault
IllegalInstFault(std::string r, const ExtMachInst inst)
Definition:
faults.hh:161
RiscvISA::InterruptFault::InterruptFault
InterruptFault(int c)
Definition:
faults.hh:129
RiscvISA::UnknownInstFault::UnknownInstFault
UnknownInstFault(const ExtMachInst inst)
Definition:
faults.hh:148
thread_context.hh
RiscvISA::SyscallFault::SyscallFault
SyscallFault(PrivilegeMode prv)
Definition:
faults.hh:226
RiscvISA::BreakpointFault::BreakpointFault
BreakpointFault(const PCState &pc)
Definition:
faults.hh:215
RiscvISA::RiscvFault::name
FaultName name() const override
Definition:
faults.hh:103
RiscvISA::AddressFault
Definition:
faults.hh:196
RiscvISA::PRV_U
Definition:
isa.hh:58
RiscvISA::AddressFault::AddressFault
AddressFault(const Addr addr, ExceptionCode code)
Definition:
faults.hh:202
RiscvISA::FloatInexact
Definition:
faults.hh:45
RiscvISA::BREAKPOINT
Definition:
faults.hh:65
RiscvISA::FloatInvalid
Definition:
faults.hh:49
RiscvISA::FloatDivZero
Definition:
faults.hh:48
RiscvISA::AMO_PAGE
Definition:
faults.hh:78
RiscvISA::INT_TIMER_SUPER
Definition:
faults.hh:84
RiscvISA::LOAD_ACCESS
Definition:
faults.hh:67
RiscvISA::INT_EXT_USER
Definition:
faults.hh:86
StaticInst::nullStaticInstPtr
static StaticInstPtr nullStaticInstPtr
Pointer to a statically allocated "null" instruction object.
Definition:
static_inst.hh:225
RiscvISA::RiscvFault::exception
ExceptionCode exception() const
Definition:
faults.hh:105
RiscvISA::FloatException
FloatException
Definition:
faults.hh:44
RiscvISA::c
Bitfield< 5, 3 > c
Definition:
pra_constants.hh:56
RiscvISA::IllegalInstFault
Definition:
faults.hh:155
RiscvISA::InstFault::trap_value
RegVal trap_value() const override
Definition:
faults.hh:142
RiscvISA::RiscvFault::_interrupt
const bool _interrupt
Definition:
faults.hh:96
RiscvISA::INT_EXT_SUPER
Definition:
faults.hh:87
RiscvISA
Definition:
fs_workload.cc:36
RiscvISA::RiscvFault::_name
const FaultName _name
Definition:
faults.hh:95
RiscvISA::Reset::_name
const FaultName _name
Definition:
faults.hh:115
FaultBase
Definition:
faults.hh:41
Generated on Fri Jul 3 2020 15:42:38 for gem5 by
doxygen
1.8.13