arch-riscv: Fix CLINT mtime reset handling (#1638)

The previous https://github.com/gem5/gem5/pull/1617 introduce the CLINT
reset feature. When reset, we changed the mtime to 0 and keep mtimecmp
unchanged by default, we also need to check mtime & mtimecmp regiter to
update the MTI signal. However, the mtime register will be incremented
to 1 by `raiseInterruptPin`.

In the PR, we introduced the interrupt ID for CLINT, the mtime will be
incremented only if received the RTC signal

---------

Co-authored-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Yu-Cheng Chang
2024-10-08 23:51:20 +08:00
committed by GitHub
parent 4f7b3ed827
commit 67edf64326
2 changed files with 13 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ Clint::Clint(const Params &params) :
BasicPioDevice(params, params.pio_size),
system(params.system),
nThread(params.num_threads),
signal(params.name + ".signal", 0, this),
signal(params.name + ".signal", 0, this, INT_RTC),
reset(params.name + ".reset"),
resetMtimecmp(params.reset_mtimecmp),
registers(params.name + ".registers", params.pio_addr, this,
@@ -69,9 +69,11 @@ Clint::Clint(const Params &params) :
void
Clint::raiseInterruptPin(int id)
{
// Increment mtime
// Increment mtime when received RTC signal
uint64_t& mtime = registers.mtime.get();
mtime++;
if (id == INT_RTC) {
mtime++;
}
for (int context_id = 0; context_id < nThread; context_id++) {
@@ -261,7 +263,7 @@ Clint::doReset() {
registers.msip[i].reset();
}
// We need to update the mtip interrupt bits when reset
raiseInterruptPin(0);
raiseInterruptPin(INT_RESET);
}
} // namespace gem5

View File

@@ -91,6 +91,13 @@ class Clint : public BasicPioDevice
void raiseInterruptPin(int id);
void lowerInterruptPin(int id) {}
// Interrupt ID
enum InterruptId
{
INT_RTC = 0, // received from RTC(signal port)
INT_RESET, // received from reset port
};
// Register bank
public: