From 65ffe4e13ef52d007d83c93467871c529705b522 Mon Sep 17 00:00:00 2001 From: Shell Date: Mon, 15 Jul 2024 12:06:17 +0800 Subject: [libcpu/rv64] feat: unify tick.c The changes unify the tick.c implementations for all risc-v64 architectures, leveraging the CPUTIME feature. This refactoring was necessary to streamline the codebase, and ensure consistent timer handling across different platforms. Changes: - Updated `Kconfig` in `bsp/cvitek/cv18xx_risc-v` to fix formatting issues. - Updated .config for BSPs to update `CPUTIME_TIMER_FREQ` - Updated header of for API `riscv_cputime_init` - Initialized riscv timer on `rt_hw_tick_init` - Refactored `tick.c` and `tick.h` in `libcpu/risc-v/t-head/c906` and `libcpu/risc-v/virt64`: - Replaced direct use of `rdtime` with `clock_cpu_gettime`. - Removed redundant timer frequency definitions. - Added static assertions to check the value of `CPUTIME_TIMER_FREQ`. - Initialized `tick_cycles` based on `CPUTIME_TIMER_FREQ`. - Integrated `ktime` support for tick initialization. Signed-off-by: Shell Reviewed-on: https://github.com/RT-Thread/rt-thread/pull/9164 Reviewed-by: Chen Wang --- components/drivers/include/drivers/cputime.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/cputime.h b/components/drivers/include/drivers/cputime.h index 3b1eb2aec0..478ccfd019 100644 --- a/components/drivers/include/drivers/cputime.h +++ b/components/drivers/include/drivers/cputime.h @@ -31,4 +31,8 @@ uint64_t clock_cpu_millisecond(uint64_t cpu_tick); int clock_cpu_setops(const struct rt_clock_cputime_ops *ops); +#ifdef RT_USING_CPUTIME_RISCV +int riscv_cputime_init(void); +#endif /* RT_USING_CPUTIME_RISCV */ + #endif -- cgit v1.3.1