gem5
v20.0.0.2
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
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
arch
mips
interrupts.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006 The Regents of The University of Michigan
3
* Copyright (c) 2007 MIPS Technologies, Inc.
4
* All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions are
8
* met: redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer;
10
* redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution;
13
* neither the name of the copyright holders nor the names of its
14
* contributors may be used to endorse or promote products derived from
15
* this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
#include "
arch/mips/interrupts.hh
"
31
32
#include "
arch/mips/isa_traits.hh
"
33
#include "
arch/mips/pra_constants.hh
"
34
#include "
base/trace.hh
"
35
#include "
cpu/thread_context.hh
"
36
#include "debug/Interrupt.hh"
37
38
namespace
MipsISA
39
{
40
41
static
inline
uint8_t
42
getCauseIP
(
ThreadContext
*tc) {
43
CauseReg cause = tc->
readMiscRegNoEffect
(
MISCREG_CAUSE
);
44
return
cause.ip;
45
}
46
47
static
inline
void
48
setCauseIP
(
ThreadContext
*tc, uint8_t
val
) {
49
CauseReg cause = tc->
readMiscRegNoEffect
(
MISCREG_CAUSE
);
50
cause.ip =
val
;
51
tc->
setMiscRegNoEffect
(
MISCREG_CAUSE
, cause);
52
}
53
54
void
55
Interrupts::post
(
int
int_num,
ThreadContext
* tc)
56
{
57
DPRINTF
(Interrupt,
"Interrupt %d posted\n"
, int_num);
58
if
(int_num < 0 || int_num >=
NumInterruptLevels
)
59
panic
(
"int_num out of bounds\n"
);
60
61
uint8_t intstatus =
getCauseIP
(tc);
62
intstatus |= 1 << int_num;
63
setCauseIP
(tc, intstatus);
64
}
65
66
void
67
Interrupts::post
(
int
int_num,
int
index
)
68
{
69
fatal
(
"Must use Thread Context when posting MIPS Interrupts in M5"
);
70
}
71
72
void
73
Interrupts::clear
(
int
int_num,
ThreadContext
* tc)
74
{
75
DPRINTF
(Interrupt,
"Interrupt %d cleared\n"
, int_num);
76
if
(int_num < 0 || int_num >=
NumInterruptLevels
)
77
panic
(
"int_num out of bounds\n"
);
78
79
uint8_t intstatus =
getCauseIP
(tc);
80
intstatus &= ~(1 << int_num);
81
setCauseIP
(tc, intstatus);
82
}
83
84
void
85
Interrupts::clear
(
int
int_num,
int
index
)
86
{
87
fatal
(
"Must use Thread Context when clearing MIPS Interrupts in M5"
);
88
}
89
90
void
91
Interrupts::clearAll
(
ThreadContext
*tc)
92
{
93
DPRINTF
(Interrupt,
"Interrupts all cleared\n"
);
94
uint8_t intstatus = 0;
95
setCauseIP
(tc, intstatus);
96
}
97
98
void
99
Interrupts::clearAll
()
100
{
101
fatal
(
"Must use Thread Context when clearing MIPS Interrupts in M5"
);
102
}
103
104
105
bool
106
Interrupts::checkInterrupts
(
ThreadContext
*tc)
const
107
{
108
if
(!
interruptsPending
(tc))
109
return
false
;
110
111
//Check if there are any outstanding interrupts
112
StatusReg
status
= tc->
readMiscRegNoEffect
(
MISCREG_STATUS
);
113
// Interrupts must be enabled, error level must be 0 or interrupts
114
// inhibited, and exception level must be 0 or interrupts inhibited
115
if
((status.ie == 1) && (status.erl == 0) && (status.exl == 0)) {
116
// Software interrupts & hardware interrupts are handled in software.
117
// So if any interrupt that isn't masked is detected, jump to interrupt
118
// handler
119
CauseReg cause = tc->
readMiscRegNoEffect
(
MISCREG_CAUSE
);
120
if
(status.im && cause.ip)
121
return
true
;
122
123
}
124
125
return
false
;
126
}
127
128
Fault
129
Interrupts::getInterrupt
(
ThreadContext
* tc)
130
{
131
assert(
checkInterrupts
(tc));
132
133
StatusReg M5_VAR_USED
status
= tc->
readMiscRegNoEffect
(
MISCREG_STATUS
);
134
CauseReg M5_VAR_USED cause = tc->
readMiscRegNoEffect
(
MISCREG_CAUSE
);
135
DPRINTF
(Interrupt,
"Interrupt! IM[7:0]=%d IP[7:0]=%d \n"
,
136
(
unsigned
)status.im, (
unsigned
)cause.ip);
137
138
return
std::make_shared<InterruptFault>();
139
}
140
141
bool
142
Interrupts::onCpuTimerInterrupt
(
ThreadContext
* tc)
const
143
{
144
RegVal
compare
= tc->
readMiscRegNoEffect
(
MISCREG_COMPARE
);
145
RegVal
count
= tc->
readMiscRegNoEffect
(
MISCREG_COUNT
);
146
if
(compare == count && count != 0)
147
return
true
;
148
return
false
;
149
}
150
151
void
152
Interrupts::updateIntrInfo
(
ThreadContext
*tc)
153
{
154
//Nothing needs to be done.
155
}
156
157
bool
158
Interrupts::interruptsPending
(
ThreadContext
*tc)
const
159
{
160
//if there is a on cpu timer interrupt (i.e. Compare == Count)
161
//update CauseIP before proceeding to interrupt
162
if
(
onCpuTimerInterrupt
(tc)) {
163
DPRINTF
(Interrupt,
"Interrupts OnCpuTimerINterrupt(tc) == true\n"
);
164
//determine timer interrupt IP #
165
IntCtlReg intCtl = tc->
readMiscRegNoEffect
(
MISCREG_INTCTL
);
166
uint8_t intStatus =
getCauseIP
(tc);
167
intStatus |= 1 << intCtl.ipti;
168
setCauseIP
(tc, intStatus);
169
}
170
171
return
(
getCauseIP
(tc) != 0);
172
173
}
174
175
}
176
177
MipsISA::Interrupts
*
178
MipsInterruptsParams::create()
179
{
180
return
new
MipsISA::Interrupts
(
this
);
181
}
X86ISA::count
count
Definition:
misc.hh:703
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition:
logging.hh:163
DPRINTF
#define DPRINTF(x,...)
Definition:
trace.hh:222
MipsISA::Interrupts::post
void post(int int_num, ThreadContext *tc)
Definition:
interrupts.cc:55
MipsISA::MISCREG_CAUSE
Definition:
registers.hh:184
MipsISA::NumInterruptLevels
Definition:
isa_traits.hh:123
MipsISA::index
Bitfield< 30, 0 > index
Definition:
pra_constants.hh:44
MipsISA::MISCREG_STATUS
Definition:
registers.hh:179
MipsISA::Interrupts::clear
void clear(int int_num, ThreadContext *tc)
Definition:
interrupts.cc:73
MipsISA::MISCREG_COMPARE
Definition:
registers.hh:177
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition:
logging.hh:171
MipsISA::Interrupts::interruptsPending
bool interruptsPending(ThreadContext *tc) const
Definition:
interrupts.cc:158
MipsISA::Interrupts::checkInterrupts
bool checkInterrupts(ThreadContext *tc) const override
Definition:
interrupts.cc:106
ThreadContext::setMiscRegNoEffect
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
MipsISA::Interrupts::updateIntrInfo
void updateIntrInfo(ThreadContext *tc) override
Definition:
interrupts.cc:152
RegVal
uint64_t RegVal
Definition:
types.hh:166
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Definition:
thread_context.hh:91
X86ISA::val
Bitfield< 63 > val
Definition:
misc.hh:769
MipsISA::Interrupts
Definition:
interrupts.hh:47
trace.hh
ArmISA::status
Bitfield< 5, 0 > status
Definition:
miscregs_types.hh:417
MipsISA::getCauseIP
static uint8_t getCauseIP(ThreadContext *tc)
Definition:
interrupts.cc:42
interrupts.hh
MipsISA::Interrupts::getInterrupt
Fault getInterrupt(ThreadContext *tc) override
Definition:
interrupts.cc:129
MipsISA::MISCREG_COUNT
Definition:
registers.hh:173
MipsISA::Interrupts::clearAll
void clearAll() override
Definition:
interrupts.cc:99
isa_traits.hh
pra_constants.hh
MipsISA::setCauseIP
static void setCauseIP(ThreadContext *tc, uint8_t val)
Definition:
interrupts.cc:48
thread_context.hh
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
HsailISA::compare
bool compare(T src0, T src1, Brig::BrigCompareOperation cmpOp)
Definition:
decl.hh:592
MipsISA
Definition:
decoder.cc:31
MipsISA::Interrupts::onCpuTimerInterrupt
bool onCpuTimerInterrupt(ThreadContext *tc) const
Definition:
interrupts.cc:142
MipsISA::MISCREG_INTCTL
Definition:
registers.hh:180
Fault
std::shared_ptr< FaultBase > Fault
Definition:
types.hh:238
Generated on Mon Jun 8 2020 15:34:39 for gem5 by
doxygen
1.8.13