[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 06/30] target/loongarch: Add stabletimer support
From: |
Richard Henderson |
Subject: |
Re: [RFC PATCH v2 06/30] target/loongarch: Add stabletimer support |
Date: |
Thu, 11 Nov 2021 15:34:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
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~