42#include "debug/Clint.hh"
45#include "params/Clint.hh"
61 params.mtimecmp_reset_value)
63 reset.onChange([
this](
const bool& new_val){
79 for (
int context_id = 0; context_id <
nThread; context_id++) {
81 auto tc =
system->threads[context_id];
84 uint64_t mtimecmp =
registers.mtimecmp[context_id].get();
85 if (mtime >= mtimecmp) {
86 if (mtime == mtimecmp) {
88 "MTIP posted - thread: %d, mtime: %d, mtimecmp: %d\n",
89 context_id, mtime, mtimecmp);
91 tc->getCpuPtr()->postInterrupt(tc->threadId(),
92 ExceptionCode::INT_TIMER_MACHINE, 0);
94 tc->getCpuPtr()->clearInterrupt(tc->threadId(),
95 ExceptionCode::INT_TIMER_MACHINE, 0);
103 using namespace std::placeholders;
110 reserved.emplace_back(
"reserved0", reserved0_size);
113 reserved.emplace_back(
"reserved1", reserved1_size);
115 if (reserved2_size > 0) {
116 reserved.emplace_back(
"reserved2", reserved2_size);
120 for (
int i = 0;
i <
clint->nThread;
i++) {
121 msip.emplace_back(std::string(
"msip") + std::to_string(
i), 0);
127 for (
int i = 0;
i <
clint->nThread;
i++) {
129 msip[
i].writeable(0x1);
130 msip[
i].writer(write_cb);
134 for (
int i = 0;
i <
clint->nThread;
i++) {
140 if (reserved2_size > 0) {
158 "Read request - addr: %#x, size: %#x, atomic:%d\n",
178 "Write request - addr: %#x, size: %#x\n",
195 if (rv_sys !=
nullptr) {
198 warn(
"Set Clint to RiscvSystem failed.");
205 if (if_name ==
"int_pin")
207 else if (if_name ==
"reset")
240 auto tc =
system->threads[thread_id];
242 DPRINTF(
Clint,
"MSIP posted - thread: %d\n", thread_id);
243 tc->getCpuPtr()->postInterrupt(tc->threadId(),
244 ExceptionCode::INT_SOFTWARE_MACHINE, 0);
246 DPRINTF(
Clint,
"MSIP cleared - thread: %d\n", thread_id);
247 tc->getCpuPtr()->clearInterrupt(tc->threadId(),
248 ExceptionCode::INT_SOFTWARE_MACHINE, 0);
BasicPioDevice(const Params &p, Addr size)
Tick pioDelay
Delay that the device experinces on an access.
std::vector< Register64 > mtimecmp
uint64_t mtimecmpResetValue
std::vector< RegisterRaz > reserved
std::vector< Register32 > msip
void updateMSIP(const int thread_id)
Software Interrupt.
void raiseInterruptPin(int id)
Timer tick callback.
Clint(const Params ¶ms)
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void init() override
SimObject functions.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
SignalSinkPort< bool > reset
ClintRegisters::Register32 Register32
IntSinkPin< Clint > signal
void writeMSIP(Register32 ®, const uint32_t &data, const int thread_id)
gem5::Clint::ClintRegisters registers
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Tick read(PacketPtr pkt) override
PioDevice interface functions.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
T * getPtr()
get a pointer to the data ptr.
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
MemCmd cmd
The command field of the packet.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Ports are used to interface objects to each other.
void addRegister(RegisterAdder reg)
void setClint(Clint *clint)
Sets the pointer to the CLINT.
const Params & params() const
Copyright (c) 2024 Arm Limited All rights reserved.
std::ostream CheckpointOut
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
Declaration of the Packet class.
const std::string & name()