Skip to content

Commit

Permalink
Add extension_t csrs in reset(), not register_extension()
Browse files Browse the repository at this point in the history
This addresses one issue raised in #1863. register_extension() is only
called once, while reset() is called whenever the processor_t is reset.
This ensures that extension_t state, including CSRs, is always reset
with reset()
  • Loading branch information
jerryz123 committed Dec 1, 2024
1 parent 4156e07 commit a10dfd0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions riscv/processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ void processor_t::reset()
put_csr(CSR_PMPCFG0, PMP_R | PMP_W | PMP_X | PMP_NAPOT);
}

for (auto e : custom_extensions) // reset any extensions
for (auto e : custom_extensions) { // reset any extensions
for (auto &csr: e.second->get_csrs(*this))
state.add_csr(csr->address, csr);
e.second->reset();
}

if (sim)
sim->proc_reset(id);
Expand Down Expand Up @@ -711,8 +714,6 @@ void processor_t::register_extension(extension_t *x) {
fprintf(stderr, "extensions must have unique names (got two named \"%s\"!)\n", x->name());
abort();
}
for (auto &csr: x->get_csrs(*this))
state.add_csr(csr->address, csr);
x->set_processor(this);
}

Expand Down

0 comments on commit a10dfd0

Please sign in to comment.