On 11/11/21 2:35 AM, Xiaojuan Yang wrote:
+ void *irq[N_IRQS];
qemu_irq, not void*.
+ QEMUTimer *timer; /* Internal timer */
You can add this into the CPUArchState structure, rather than reference via pointer. It is always present with the cpu.
Neither of these are needed for CONFIG_USER_ONLY.
+void cpu_loongarch_store_stable_timer_config(CPULoongArchState *env, + uint64_t value) +{ + uint64_t now, next; + + env->CSR_TCFG = value; + if (value & STABLETIMER_ENABLE) { + now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + next = now + (value & STABLETIMER_TICK_MASK) * TIMER_PERIOD; + timer_mod(env->timer, next); + }
timer_mod_ns, when you use timer_new_ns. timer_del when not enabled.
+ env->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, + &loongarch_stable_timer_cb, env);
This would become timer_init_ns(&env->timer, ...) r~