gem5
[DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
arch
riscv
interrupts.hh
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Google
3
* Copyright (c) 2024 University of Rostock
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
#ifndef __ARCH_RISCV_INTERRUPT_HH__
31
#define __ARCH_RISCV_INTERRUPT_HH__
32
33
#include <bitset>
34
#include <memory>
35
36
#include "
arch/generic/interrupts.hh
"
37
#include "
arch/riscv/faults.hh
"
38
#include "
arch/riscv/regs/misc.hh
"
39
#include "
base/logging.hh
"
40
#include "
cpu/base.hh
"
41
#include "
cpu/thread_context.hh
"
42
#include "debug/Interrupt.hh"
43
#include "
dev/intpin.hh
"
44
#include "params/RiscvInterrupts.hh"
45
#include "
sim/sim_object.hh
"
46
47
namespace
gem5
48
{
49
50
class
BaseCPU
;
51
class
ThreadContext
;
52
53
namespace
RiscvISA
{
54
55
/*
56
* This is based on version 1.10 of the RISC-V privileged ISA reference,
57
* chapter 3.1.14.
58
*/
59
class
Interrupts
:
public
BaseInterrupts
60
{
61
private
:
62
std::bitset<NumInterruptTypes>
ip
;
63
std::bitset<NumInterruptTypes>
ie
;
64
65
std::vector<gem5::IntSinkPin<Interrupts>
*>
localInterruptPins
;
66
protected
:
67
int
nmi_cause
;
68
69
public
:
70
using
Params
= RiscvInterruptsParams;
71
72
Interrupts
(
const
Params
&
p
);
73
74
std::bitset<NumInterruptTypes>
globalMask
()
const
;
75
76
bool
77
checkNonMaskableInterrupt
()
const
78
{
79
return
tc
->readMiscReg(
MISCREG_NMIP
) &
tc
->readMiscReg(
MISCREG_NMIE
);
80
}
81
82
bool
checkInterrupt
(
int
num)
const
{
return
ip
[num] &&
ie
[num]; }
83
bool
checkInterrupts
()
const override
84
{
85
ISA
* isa =
static_cast<
ISA
*
>
(
tc
->getIsaPtr());
86
if
(isa->
enableSmrnmi
() &&
tc
->readMiscReg(
MISCREG_NMIE
) == 0) {
87
return
false
;
88
}
89
return
checkNonMaskableInterrupt
() || (
ip
&
ie
&
globalMask
()).any();
90
}
91
92
Fault
getInterrupt
()
override
;
93
94
void
updateIntrInfo
()
override
{}
95
96
void
post
(
int
int_num,
int
index
)
override
;
97
98
void
clear
(
int
int_num,
int
index
)
override
;
99
100
void
postNMI
() {
tc
->setMiscReg(
MISCREG_NMIP
, 1); }
101
void
clearNMI
() {
tc
->setMiscReg(
MISCREG_NMIP
, 0); }
102
103
void
clearAll
()
override
;
104
105
bool
isWakeUp
()
const override
106
{
107
return
checkNonMaskableInterrupt
() || (
ip
&
ie
).any();
108
}
109
110
uint64_t
readIP
()
const
{
return
(uint64_t)
ip
.to_ulong(); }
111
uint64_t
readIE
()
const
{
return
(uint64_t)
ie
.to_ulong(); }
112
void
setIP
(
const
uint64_t&
val
) {
ip
=
val
; }
113
void
setIE
(
const
uint64_t&
val
) {
ie
=
val
; }
114
115
void
serialize
(
CheckpointOut
&
cp
)
const override
;
116
117
void
unserialize
(
CheckpointIn
&
cp
)
override
;
118
119
Port
&
getPort
(
const
std::string &if_name,
PortID
idx)
override
;
120
121
void
raiseInterruptPin
(uint32_t num);
122
void
lowerInterruptPin
(uint32_t num) {};
123
};
124
125
}
// namespace RiscvISA
126
}
// namespace gem5
127
128
#endif
// __ARCH_RISCV_INTERRUPT_HH__
faults.hh
misc.hh
gem5::BaseCPU
Definition
base.hh:106
gem5::BaseInterrupts::tc
ThreadContext * tc
Definition
interrupts.hh:44
gem5::BaseInterrupts::BaseInterrupts
BaseInterrupts(const Params &p)
Definition
interrupts.hh:49
gem5::CheckpointIn
Definition
serialize.hh:69
gem5::Port
Ports are used to interface objects to each other.
Definition
port.hh:62
gem5::RiscvISA::ISA
Definition
isa.hh:74
gem5::RiscvISA::ISA::enableSmrnmi
bool enableSmrnmi()
Definition
isa.hh:200
gem5::RiscvISA::Interrupts::localInterruptPins
std::vector< gem5::IntSinkPin< Interrupts > * > localInterruptPins
Definition
interrupts.hh:65
gem5::RiscvISA::Interrupts::postNMI
void postNMI()
Definition
interrupts.hh:100
gem5::RiscvISA::Interrupts::setIP
void setIP(const uint64_t &val)
Definition
interrupts.hh:112
gem5::RiscvISA::Interrupts::setIE
void setIE(const uint64_t &val)
Definition
interrupts.hh:113
gem5::RiscvISA::Interrupts::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition
interrupts.cc:206
gem5::RiscvISA::Interrupts::Interrupts
Interrupts(const Params &p)
Definition
interrupts.cc:39
gem5::RiscvISA::Interrupts::readIE
uint64_t readIE() const
Definition
interrupts.hh:111
gem5::RiscvISA::Interrupts::clear
void clear(int int_num, int index) override
Definition
interrupts.cc:172
gem5::RiscvISA::Interrupts::checkInterrupts
bool checkInterrupts() const override
Definition
interrupts.hh:83
gem5::RiscvISA::Interrupts::checkNonMaskableInterrupt
bool checkNonMaskableInterrupt() const
Definition
interrupts.hh:77
gem5::RiscvISA::Interrupts::readIP
uint64_t readIP() const
Definition
interrupts.hh:110
gem5::RiscvISA::Interrupts::lowerInterruptPin
void lowerInterruptPin(uint32_t num)
Definition
interrupts.hh:122
gem5::RiscvISA::Interrupts::post
void post(int int_num, int index) override
Definition
interrupts.cc:161
gem5::RiscvISA::Interrupts::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition
interrupts.cc:197
gem5::RiscvISA::Interrupts::raiseInterruptPin
void raiseInterruptPin(uint32_t num)
Definition
interrupts.cc:191
gem5::RiscvISA::Interrupts::getPort
Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
Definition
interrupts.cc:217
gem5::RiscvISA::Interrupts::clearNMI
void clearNMI()
Definition
interrupts.hh:101
gem5::RiscvISA::Interrupts::clearAll
void clearAll() override
Definition
interrupts.cc:183
gem5::RiscvISA::Interrupts::nmi_cause
int nmi_cause
Definition
interrupts.hh:67
gem5::RiscvISA::Interrupts::Params
RiscvInterruptsParams Params
Definition
interrupts.hh:70
gem5::RiscvISA::Interrupts::updateIntrInfo
void updateIntrInfo() override
Definition
interrupts.hh:94
gem5::RiscvISA::Interrupts::isWakeUp
bool isWakeUp() const override
Definition
interrupts.hh:105
gem5::RiscvISA::Interrupts::globalMask
std::bitset< NumInterruptTypes > globalMask() const
Definition
interrupts.cc:59
gem5::RiscvISA::Interrupts::ip
std::bitset< NumInterruptTypes > ip
Definition
interrupts.hh:62
gem5::RiscvISA::Interrupts::checkInterrupt
bool checkInterrupt(int num) const
Definition
interrupts.hh:82
gem5::RiscvISA::Interrupts::getInterrupt
Fault getInterrupt() override
Definition
interrupts.cc:112
gem5::RiscvISA::Interrupts::ie
std::bitset< NumInterruptTypes > ie
Definition
interrupts.hh:63
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition
thread_context.hh:89
std::vector
STL vector class.
Definition
stl.hh:37
base.hh
thread_context.hh
interrupts.hh
intpin.hh
logging.hh
gem5::RiscvISA
Definition
fs_workload.cc:41
gem5::RiscvISA::p
Bitfield< 0 > p
Definition
pra_constants.hh:326
gem5::RiscvISA::index
Bitfield< 30, 0 > index
Definition
pra_constants.hh:47
gem5::RiscvISA::MISCREG_NMIE
@ MISCREG_NMIE
Definition
misc.hh:210
gem5::RiscvISA::MISCREG_NMIP
@ MISCREG_NMIP
Definition
misc.hh:212
gem5::X86ISA::val
Bitfield< 63 > val
Definition
misc.hh:804
gem5::cp
Definition
cprintf.cc:41
gem5
Copyright (c) 2024 Arm Limited All rights reserved.
Definition
binary32.hh:36
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition
types.hh:249
gem5::CheckpointOut
std::ostream CheckpointOut
Definition
serialize.hh:66
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition
types.hh:245
sim_object.hh
Generated on Mon May 26 2025 09:19:05 for gem5 by
doxygen
1.13.2