gem5
v21.0.1.0
arch
sparc
interrupts.hh
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006 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 __ARCH_SPARC_INTERRUPT_HH__
30
#define __ARCH_SPARC_INTERRUPT_HH__
31
32
#include "
arch/generic/interrupts.hh
"
33
#include "
arch/sparc/faults.hh
"
34
#include "
arch/sparc/isa_traits.hh
"
35
#include "
arch/sparc/registers.hh
"
36
#include "
cpu/thread_context.hh
"
37
#include "debug/Interrupt.hh"
38
#include "params/SparcInterrupts.hh"
39
#include "
sim/sim_object.hh
"
40
41
namespace
SparcISA
42
{
43
44
enum
InterruptTypes
45
{
46
IT_TRAP_LEVEL_ZERO
,
47
IT_HINTP
,
48
IT_INT_VEC
,
49
IT_CPU_MONDO
,
50
IT_DEV_MONDO
,
51
IT_RES_ERROR
,
52
IT_SOFT_INT
,
53
NumInterruptTypes
54
};
55
56
class
Interrupts
:
public
BaseInterrupts
57
{
58
private
:
59
uint64_t
interrupts
[
NumInterruptTypes
];
60
uint64_t
intStatus
;
61
62
public
:
63
64
using
Params
= SparcInterruptsParams;
65
66
Interrupts
(
const
Params
&
p
) :
BaseInterrupts
(
p
)
67
{
68
clearAll
();
69
}
70
71
int
72
InterruptLevel
(uint64_t softint)
73
{
74
if
(softint & 0x10000 || softint & 0x1)
75
return
14;
76
77
int
level
= 15;
78
while
(
level
> 0 && !(1 <<
level
& softint))
79
level
--;
80
if
(1 <<
level
& softint)
81
return
level
;
82
return
0;
83
}
84
85
void
86
post
(
int
int_num,
int
index
)
override
87
{
88
DPRINTF
(Interrupt,
"Interrupt %d:%d posted\n"
, int_num,
index
);
89
assert(int_num >= 0 && int_num <
NumInterruptTypes
);
90
assert(
index
>= 0 &&
index
< 64);
91
92
interrupts
[int_num] |=
ULL
(1) <<
index
;
93
intStatus
|=
ULL
(1) << int_num;
94
}
95
96
void
97
clear
(
int
int_num,
int
index
)
override
98
{
99
DPRINTF
(Interrupt,
"Interrupt %d:%d cleared\n"
, int_num,
index
);
100
assert(int_num >= 0 && int_num <
NumInterruptTypes
);
101
assert(
index
>= 0 &&
index
< 64);
102
103
interrupts
[int_num] &= ~(
ULL
(1) <<
index
);
104
if
(!
interrupts
[int_num])
105
intStatus
&= ~(
ULL
(1) << int_num);
106
}
107
108
void
109
clearAll
()
override
110
{
111
for
(
int
i
= 0;
i
<
NumInterruptTypes
; ++
i
) {
112
interrupts
[
i
] = 0;
113
}
114
intStatus
= 0;
115
}
116
117
bool
118
checkInterrupts
()
const override
119
{
120
if
(!
intStatus
)
121
return
false
;
122
123
HPSTATE hpstate =
tc
->
readMiscRegNoEffect
(
MISCREG_HPSTATE
);
124
PSTATE pstate =
tc
->
readMiscRegNoEffect
(
MISCREG_PSTATE
);
125
126
// THESE ARE IN ORDER OF PRIORITY
127
// since there are early returns, and the highest
128
// priority interrupts should get serviced,
129
// it is v. important that new interrupts are inserted
130
// in the right order of processing
131
if
(hpstate.hpriv) {
132
if
(pstate.ie) {
133
if
(
interrupts
[
IT_HINTP
]) {
134
// This will be cleaned by a HINTP write
135
return
true
;
136
}
137
if
(
interrupts
[
IT_INT_VEC
]) {
138
// this will be cleared by an ASI read (or write)
139
return
true
;
140
}
141
}
142
}
else
{
143
if
(
interrupts
[
IT_TRAP_LEVEL_ZERO
]) {
144
// this is cleared by deasserting HPSTATE::tlz
145
return
true
;
146
}
147
// HStick matches always happen in priv mode (ie doesn't matter)
148
if
(
interrupts
[
IT_HINTP
]) {
149
return
true
;
150
}
151
if
(
interrupts
[
IT_INT_VEC
]) {
152
// this will be cleared by an ASI read (or write)
153
return
true
;
154
}
155
if
(pstate.ie) {
156
if
(
interrupts
[
IT_CPU_MONDO
]) {
157
return
true
;
158
}
159
if
(
interrupts
[
IT_DEV_MONDO
]) {
160
return
true
;
161
}
162
if
(
interrupts
[
IT_SOFT_INT
]) {
163
return
true
;
164
}
165
166
if
(
interrupts
[
IT_RES_ERROR
]) {
167
return
true
;
168
}
169
}
// !hpriv && pstate.ie
170
}
// !hpriv
171
172
return
false
;
173
}
174
175
Fault
176
getInterrupt
()
override
177
{
178
assert(
checkInterrupts
());
179
180
HPSTATE hpstate =
tc
->
readMiscRegNoEffect
(
MISCREG_HPSTATE
);
181
PSTATE pstate =
tc
->
readMiscRegNoEffect
(
MISCREG_PSTATE
);
182
183
// THESE ARE IN ORDER OF PRIORITY
184
// since there are early returns, and the highest
185
// priority interrupts should get serviced,
186
// it is v. important that new interrupts are inserted
187
// in the right order of processing
188
if
(hpstate.hpriv) {
189
if
(pstate.ie) {
190
if
(
interrupts
[
IT_HINTP
]) {
191
// This will be cleaned by a HINTP write
192
return
std::make_shared<HstickMatch>();
193
}
194
if
(
interrupts
[
IT_INT_VEC
]) {
195
// this will be cleared by an ASI read (or write)
196
return
std::make_shared<InterruptVector>();
197
}
198
}
199
}
else
{
200
if
(
interrupts
[
IT_TRAP_LEVEL_ZERO
]) {
201
// this is cleared by deasserting HPSTATE::tlz
202
return
std::make_shared<TrapLevelZero>();
203
}
204
// HStick matches always happen in priv mode (ie doesn't matter)
205
if
(
interrupts
[
IT_HINTP
]) {
206
return
std::make_shared<HstickMatch>();
207
}
208
if
(
interrupts
[
IT_INT_VEC
]) {
209
// this will be cleared by an ASI read (or write)
210
return
std::make_shared<InterruptVector>();
211
}
212
if
(pstate.ie) {
213
if
(
interrupts
[
IT_CPU_MONDO
]) {
214
return
std::make_shared<CpuMondo>();
215
}
216
if
(
interrupts
[
IT_DEV_MONDO
]) {
217
return
std::make_shared<DevMondo>();
218
}
219
if
(
interrupts
[
IT_SOFT_INT
]) {
220
int
level
=
InterruptLevel
(
interrupts
[
IT_SOFT_INT
]);
221
return
std::make_shared<InterruptLevelN>(
level
);
222
}
223
224
if
(
interrupts
[
IT_RES_ERROR
]) {
225
return
std::make_shared<ResumableError>();
226
}
227
}
// !hpriv && pstate.ie
228
}
// !hpriv
229
return
NoFault
;
230
}
231
232
void
updateIntrInfo
()
override
{}
233
234
uint64_t
235
get_vec
(
int
int_num)
236
{
237
assert(int_num >= 0 && int_num <
NumInterruptTypes
);
238
return
interrupts
[int_num];
239
}
240
241
void
242
serialize
(
CheckpointOut
&
cp
)
const override
243
{
244
SERIALIZE_ARRAY
(
interrupts
,
NumInterruptTypes
);
245
SERIALIZE_SCALAR
(
intStatus
);
246
}
247
248
void
249
unserialize
(
CheckpointIn
&
cp
)
override
250
{
251
UNSERIALIZE_ARRAY
(
interrupts
,
NumInterruptTypes
);
252
UNSERIALIZE_SCALAR
(
intStatus
);
253
}
254
};
255
}
// namespace SPARC_ISA
256
257
#endif // __ARCH_SPARC_INTERRUPT_HH__
SparcISA::Interrupts::intStatus
uint64_t intStatus
Definition:
interrupts.hh:60
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
SparcISA::MISCREG_PSTATE
@ MISCREG_PSTATE
Definition:
miscregs.hh:62
SparcISA::Interrupts::getInterrupt
Fault getInterrupt() override
Definition:
interrupts.hh:176
SparcISA::Interrupts::InterruptLevel
int InterruptLevel(uint64_t softint)
Definition:
interrupts.hh:72
SparcISA::Interrupts::clearAll
void clearAll() override
Definition:
interrupts.hh:109
MipsISA::index
Bitfield< 30, 0 > index
Definition:
pra_constants.hh:44
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition:
serialize.hh:591
ArmISA::i
Bitfield< 7 > i
Definition:
miscregs_types.hh:63
SparcISA::Interrupts::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition:
interrupts.hh:242
SparcISA::IT_CPU_MONDO
@ IT_CPU_MONDO
Definition:
interrupts.hh:49
SparcISA::Interrupts::updateIntrInfo
void updateIntrInfo() override
Definition:
interrupts.hh:232
SparcISA::IT_INT_VEC
@ IT_INT_VEC
Definition:
interrupts.hh:48
SparcISA::Interrupts::checkInterrupts
bool checkInterrupts() const override
Definition:
interrupts.hh:118
SparcISA
Definition:
asi.cc:31
SparcISA::IT_TRAP_LEVEL_ZERO
@ IT_TRAP_LEVEL_ZERO
Definition:
interrupts.hh:46
cp
Definition:
cprintf.cc:37
SparcISA::Interrupts::clear
void clear(int int_num, int index) override
Definition:
interrupts.hh:97
faults.hh
sim_object.hh
DPRINTF
#define DPRINTF(x,...)
Definition:
trace.hh:237
SparcISA::IT_DEV_MONDO
@ IT_DEV_MONDO
Definition:
interrupts.hh:50
Fault
std::shared_ptr< FaultBase > Fault
Definition:
types.hh:246
SparcISA::Interrupts::post
void post(int int_num, int index) override
Definition:
interrupts.hh:86
isa_traits.hh
SparcISA::IT_SOFT_INT
@ IT_SOFT_INT
Definition:
interrupts.hh:52
SERIALIZE_ARRAY
#define SERIALIZE_ARRAY(member, size)
Definition:
serialize.hh:626
SparcISA::NumInterruptTypes
@ NumInterruptTypes
Definition:
interrupts.hh:53
NoFault
constexpr decltype(nullptr) NoFault
Definition:
types.hh:251
BaseInterrupts::Params
BaseInterruptsParams Params
Definition:
interrupts.hh:44
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition:
serialize.hh:584
SparcISA::MISCREG_HPSTATE
@ MISCREG_HPSTATE
Hyper privileged registers.
Definition:
miscregs.hh:74
X86ISA::level
Bitfield< 20 > level
Definition:
intmessage.hh:47
SparcISA::Interrupts::get_vec
uint64_t get_vec(int int_num)
Definition:
interrupts.hh:235
SparcISA::IT_RES_ERROR
@ IT_RES_ERROR
Definition:
interrupts.hh:51
SparcISA::InterruptTypes
InterruptTypes
Definition:
interrupts.hh:44
UNSERIALIZE_ARRAY
#define UNSERIALIZE_ARRAY(member, size)
Definition:
serialize.hh:634
interrupts.hh
CheckpointOut
std::ostream CheckpointOut
Definition:
serialize.hh:64
SparcISA::Interrupts::interrupts
uint64_t interrupts[NumInterruptTypes]
Definition:
interrupts.hh:59
registers.hh
MipsISA::p
Bitfield< 0 > p
Definition:
pra_constants.hh:323
SparcISA::Interrupts::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition:
interrupts.hh:249
BaseInterrupts
Definition:
interrupts.hh:38
BaseInterrupts::tc
ThreadContext * tc
Definition:
interrupts.hh:41
CheckpointIn
Definition:
serialize.hh:68
thread_context.hh
SparcISA::Interrupts::Interrupts
Interrupts(const Params &p)
Definition:
interrupts.hh:66
ULL
#define ULL(N)
uint64_t constant
Definition:
types.hh:46
SparcISA::IT_HINTP
@ IT_HINTP
Definition:
interrupts.hh:47
SparcISA::Interrupts
Definition:
interrupts.hh:56
Generated on Tue Jun 22 2021 15:28:19 for gem5 by
doxygen
1.8.17