On 7/11/25 11:23, Luc Michel wrote:
Replace the env->rdtime_fn function pointer with an instance of the
RISCVCPUTimeSrcIf QOM interface.

This allows to remove the dependency on the ACLINT in the
riscv_timer_write_timecmp function:
    - This dependency was buggy because env->rdtime_fn_arg was an opaque
      pointer and was converted in riscv_timer_write_timecmp to a ACLINT
      without dynamic type check.
    - This will allow to have time sources provided by other devices than
      an ACLINT.

Signed-off-by: Luc Michel <[email protected]>
---
  target/riscv/cpu.h         |  8 +++-----
  hw/intc/riscv_aclint.c     |  2 +-
  target/riscv/cpu_helper.c  |  7 -------
  target/riscv/csr.c         | 24 ++++++++++++------------
  target/riscv/time_helper.c | 15 +++++++++------
  5 files changed, 25 insertions(+), 31 deletions(-)


+void riscv_cpu_set_time_src(CPURISCVState *env, RISCVCPUTimeSrcIf *src)
+{
+    env->time_src = src;

Worth asserting time_src is NULL? Regardless, good cleanup:

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

+}


Reply via email to