41#include "debug/Clint.hh"
44#include "params/Clint.hh"
50using namespace RiscvISA;
55 nThread(params.num_threads),
56 signal(params.
name +
".signal", 0, this),
57 registers(params.
name +
".registers", params.pio_addr, this)
68 for (
int context_id = 0; context_id <
nThread; context_id++) {
73 ISA* isa =
dynamic_cast<ISA*
>(tc->getIsaPtr());
74 if (isa->rvType() ==
RV32) {
83 if (mtime >= mtimecmp) {
84 if (mtime == mtimecmp) {
86 "MTIP posted - thread: %d, mtime: %d, mtimecmp: %d\n",
87 context_id, mtime, mtimecmp);
89 tc->getCpuPtr()->postInterrupt(tc->threadId(),
90 ExceptionCode::INT_TIMER_MACHINE, 0);
92 tc->getCpuPtr()->clearInterrupt(tc->threadId(),
93 ExceptionCode::INT_TIMER_MACHINE, 0);
101 using namespace std::placeholders;
105 reserved.emplace_back(
"reserved0", reserved0_size);
108 reserved.emplace_back(
"reserved1", reserved1_size);
115 msip.emplace_back(std::string(
"msip") + std::to_string(
i), 0);
116 mtimecmp.emplace_back(std::string(
"mtimecmp") + std::to_string(
i), 0);
122 msip[
i].reader(read_cb);
124 msip[
i].writer(write_cb);
142 uint32_t msip =
bits<uint32_t>(mip, ExceptionCode::INT_SOFTWARE_MACHINE);
154 DPRINTF(
Clint,
"MSIP posted - thread: %d\n", thread_id);
155 tc->getCpuPtr()->postInterrupt(tc->threadId(),
156 ExceptionCode::INT_SOFTWARE_MACHINE, 0);
158 DPRINTF(
Clint,
"MSIP cleared - thread: %d\n", thread_id);
159 tc->getCpuPtr()->clearInterrupt(tc->threadId(),
160 ExceptionCode::INT_SOFTWARE_MACHINE, 0);
170 "Read request - addr: %#x, size: %#x, atomic:%d\n",
190 "Write request - addr: %#x, size: %#x\n",
210 if (if_name ==
"int_pin")
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Tick pioDelay
Delay that the device experinces on an access.
Addr pioSize
Size that the device's address range.
std::vector< Register64 > mtimecmp
std::vector< RegisterRaz > reserved
std::vector< Register32 > msip
NOTE: This implementation of CLINT is based on the SiFive U54MC datasheet: https://sifive....
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.
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.
uint32_t readMSIP(Register32 ®, const int thread_id)
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
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)
virtual void read(Addr addr, void *buf, Addr bytes)
virtual void write(Addr addr, const void *buf, Addr bytes)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
constexpr enums::RiscvType RV32
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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()