41#include "debug/Clint.hh"
44#include "params/Clint.hh"
60 params.mtimecmp_reset_value)
62 reset.onChange([
this](
const bool& new_val){
78 for (
int context_id = 0; context_id <
nThread; context_id++) {
80 auto tc =
system->threads[context_id];
83 ISA* isa =
dynamic_cast<ISA*
>(tc->getIsaPtr());
84 if (isa->rvType() ==
RV32) {
92 uint64_t mtimecmp =
registers.mtimecmp[context_id].get();
93 if (mtime >= mtimecmp) {
94 if (mtime == mtimecmp) {
96 "MTIP posted - thread: %d, mtime: %d, mtimecmp: %d\n",
97 context_id, mtime, mtimecmp);
99 tc->getCpuPtr()->postInterrupt(tc->threadId(),
100 ExceptionCode::INT_TIMER_MACHINE, 0);
102 tc->getCpuPtr()->clearInterrupt(tc->threadId(),
103 ExceptionCode::INT_TIMER_MACHINE, 0);
111 using namespace std::placeholders;
118 reserved.emplace_back(
"reserved0", reserved0_size);
121 reserved.emplace_back(
"reserved1", reserved1_size);
123 if (reserved2_size > 0) {
124 reserved.emplace_back(
"reserved2", reserved2_size);
128 for (
int i = 0;
i <
clint->nThread;
i++) {
129 msip.emplace_back(std::string(
"msip") + std::to_string(
i), 0);
135 for (
int i = 0;
i <
clint->nThread;
i++) {
137 msip[
i].writeable(0x1);
138 msip[
i].writer(write_cb);
142 for (
int i = 0;
i <
clint->nThread;
i++) {
148 if (reserved2_size > 0) {
166 "Read request - addr: %#x, size: %#x, atomic:%d\n",
186 "Write request - addr: %#x, size: %#x\n",
206 if (if_name ==
"int_pin")
208 else if (if_name ==
"reset")
241 auto tc =
system->threads[thread_id];
243 DPRINTF(
Clint,
"MSIP posted - thread: %d\n", thread_id);
244 tc->getCpuPtr()->postInterrupt(tc->threadId(),
245 ExceptionCode::INT_SOFTWARE_MACHINE, 0);
247 DPRINTF(
Clint,
"MSIP cleared - thread: %d\n", thread_id);
248 tc->getCpuPtr()->clearInterrupt(tc->threadId(),
249 ExceptionCode::INT_SOFTWARE_MACHINE, 0);
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
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)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
const Params & params() const
constexpr enums::RiscvType RV32
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()