There is only one timer type on LoongArch, its frequency is fixed at 100MHZ. Here rename function name constant_timer_xxx with timer_xxx for simplity.
Signed-off-by: Bibo Mao <[email protected]> --- target/loongarch/cpu.c | 2 +- target/loongarch/internals.h | 9 ++++----- target/loongarch/tcg/constant_timer.c | 9 ++++----- target/loongarch/tcg/csr_helper.c | 4 ++-- target/loongarch/tcg/op_helper.c | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 84a130956d..cba227fd1b 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -762,7 +762,7 @@ static void loongarch_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(cpu), loongarch_cpu_set_irq, N_IRQS); #ifdef CONFIG_TCG timer_init_ns(&cpu->timer, QEMU_CLOCK_VIRTUAL, - &loongarch_constant_timer_cb, cpu); + &cpu_loongarch_timer_cb, cpu); #endif #endif } diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index 0b670f9466..8c5f095782 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -34,11 +34,10 @@ extern const VMStateDescription vmstate_loongarch_cpu; void loongarch_cpu_update_irq(LoongArchCPU *cpu, uint64_t old); void loongarch_cpu_set_irq(void *opaque, int irq, int level); -void loongarch_constant_timer_cb(void *opaque); -uint64_t cpu_loongarch_get_constant_timer_counter(LoongArchCPU *cpu); -uint64_t cpu_loongarch_get_constant_timer_ticks(LoongArchCPU *cpu); -void cpu_loongarch_store_constant_timer_config(LoongArchCPU *cpu, - uint64_t value); +void cpu_loongarch_timer_cb(void *opaque); +uint64_t cpu_loongarch_get_timer_counter(LoongArchCPU *cpu); +uint64_t cpu_loongarch_get_timer_ticks(LoongArchCPU *cpu); +void cpu_loongarch_set_timer_config(LoongArchCPU *cpu, uint64_t value); bool loongarch_cpu_has_work(CPUState *cs); bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env); #endif /* !CONFIG_USER_ONLY */ diff --git a/target/loongarch/tcg/constant_timer.c b/target/loongarch/tcg/constant_timer.c index b91ad1de69..a25312b9ab 100644 --- a/target/loongarch/tcg/constant_timer.c +++ b/target/loongarch/tcg/constant_timer.c @@ -15,12 +15,12 @@ #define CONSTANT_TIMER_TICK_MASK 0xfffffffffffcUL #define CONSTANT_TIMER_ENABLE 0x1UL -uint64_t cpu_loongarch_get_constant_timer_counter(LoongArchCPU *cpu) +uint64_t cpu_loongarch_get_timer_counter(LoongArchCPU *cpu) { return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / TIMER_PERIOD; } -uint64_t cpu_loongarch_get_constant_timer_ticks(LoongArchCPU *cpu) +uint64_t cpu_loongarch_get_timer_ticks(LoongArchCPU *cpu) { CPULoongArchState *env = &cpu->env; CPUSysState *sys = env_sys(env); @@ -36,8 +36,7 @@ uint64_t cpu_loongarch_get_constant_timer_ticks(LoongArchCPU *cpu) return sys->CSR_TVAL; } -void cpu_loongarch_store_constant_timer_config(LoongArchCPU *cpu, - uint64_t value) +void cpu_loongarch_set_timer_config(LoongArchCPU *cpu, uint64_t value) { CPULoongArchState *env = &cpu->env; CPUSysState *sys = env_sys(env); @@ -55,7 +54,7 @@ void cpu_loongarch_store_constant_timer_config(LoongArchCPU *cpu, } } -void loongarch_constant_timer_cb(void *opaque) +void cpu_loongarch_timer_cb(void *opaque) { LoongArchCPU *cpu = opaque; CPULoongArchState *env = &cpu->env; diff --git a/target/loongarch/tcg/csr_helper.c b/target/loongarch/tcg/csr_helper.c index 155482efc6..b1a0b005e9 100644 --- a/target/loongarch/tcg/csr_helper.c +++ b/target/loongarch/tcg/csr_helper.c @@ -74,7 +74,7 @@ target_ulong helper_csrrd_tval(CPULoongArchState *env) { LoongArchCPU *cpu = env_archcpu(env); - return cpu_loongarch_get_constant_timer_ticks(cpu); + return cpu_loongarch_get_timer_ticks(cpu); } target_ulong helper_csrrd_msgir(CPULoongArchState *env) @@ -139,7 +139,7 @@ target_ulong helper_csrwr_tcfg(CPULoongArchState *env, target_ulong val) CPUSysState *sys = env_sys(env); int64_t old_v = sys->CSR_TCFG; - cpu_loongarch_store_constant_timer_config(cpu, val); + cpu_loongarch_set_timer_config(cpu, val); return old_v; } diff --git a/target/loongarch/tcg/op_helper.c b/target/loongarch/tcg/op_helper.c index f41f0cb1e6..c090d5b12e 100644 --- a/target/loongarch/tcg/op_helper.c +++ b/target/loongarch/tcg/op_helper.c @@ -81,7 +81,7 @@ uint64_t helper_rdtime_d(CPULoongArchState *env) do_raise_exception(env, EXCCODE_IPE, GETPC()); } - return cpu_loongarch_get_constant_timer_counter(cpu); + return cpu_loongarch_get_timer_counter(cpu); #endif } -- 2.54.0
