diff options
| author | Bernard Xiong <[email protected]> | 2026-01-31 17:44:27 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-31 17:44:27 +0800 |
| commit | 743b614875fc33257be47ab53b6c5e040ec27893 (patch) | |
| tree | e4b78b63c5c331e4a69a9d01ffcc9ed24389a9b8 /src | |
| parent | f2a646cff4947bef7554ddbf443765e63d888d96 (diff) | |
[components][clock_time] Refactor time subsystem around clock_time (#11111)
* [components][clock_time] Refactor time subsystem around clock_time
Introduce the clock_time core with clock source/event separation, high-resolution scheduling, and boot-time helpers, plus clock_timer adapters for timer peripherals.
Remove legacy ktime/cputime/hwtimer implementations and migrate arch and BSP time paths to the new subsystem while keeping POSIX time integration functional.
Update drivers, Kconfig/SConscript wiring, documentation, and tests; add clock_time overview docs and align naming to clock_boottime/clock_hrtimer/clock_timer.
* [components][clock_time] Use BSP-provided clock timer frequency on riscv64
* [risc-v] Use runtime clock timer frequency for tick and delays
* [bsp] Add clock timer frequency hooks for riscv64 boards
* [bsp] Update Renesas RA driver doc clock_timer link
* [bsp] Sync zynqmp-r5-axu4ev rtconfig after config refresh
* [bsp][rk3500] Update rk3500 clock configuration
* [bsp][hpmicro] Add rt_hw_us_delay hook and update board delays
* [bsp][stm32l496-st-nucleo] enable clock_time for hwtimer sample in ci
* [bsp][hpmicro] Fix rtconfig include scope for hpm6750evk
Move rtconfig.h include outside the ENET_MULTIPLE_PORT guard for hpm6750evk and hpm6750evk2 so configuration macros are available regardless of ENET settings.
* [bsp][raspi3] select clock time for systimer
* [bsp][hpm5300evk] Trim trailing blank line
* [bsp][hpm5301evklite] Trim trailing blank line
* [bsp][hpm5e00evk] Trim trailing blank line
* [bsp][hpm6200evk] Trim trailing blank line
* [bsp][hpm6300evk] Trim trailing blank line
* [bsp][hpm6750evk] Trim trailing blank line
* [bsp][hpm6750evk2] Trim trailing blank line
* [bsp][hpm6750evkmini] Trim trailing blank line
* [bsp][hpm6800evk] Trim trailing blank line
* [bsp][hpm6e00evk] Trim trailing blank line
* [bsp][nxp] switch lpc178x to gcc and remove mcx timer source
* [bsp][stm32] fix the CONFIG_RT_USING_CLOCK_TIME issue.
* [docs][clock_time] add clock time documentation
* [docs][clock_time] Update clock time subsystem documentation
- Update device driver index to use correct page reference
- Clarify upper layer responsibilities in architecture overview
- Update README to describe POSIX/libc, Soft RTC, and device driver usage
- Refine architecture diagram with improved layout and color scheme
- Remove obsolete clock_timer.md file
* [kernel][utest] Trim trailing space
* [clock_time] Fix hrtimer wrap handling
* [clock_time] fix the static rt_inline issue
* [clock_time] fix the rt_clock_hrtimer_control result issue
Diffstat (limited to 'src')
| -rw-r--r-- | src/Kconfig | 2 | ||||
| -rw-r--r-- | src/utest/perf/Kconfig | 6 | ||||
| -rw-r--r-- | src/utest/perf/irq_latency_tc.c | 11 | ||||
| -rw-r--r-- | src/utest/perf/perf_tc.c | 20 | ||||
| -rw-r--r-- | src/utest/perf/perf_tc.h | 2 |
5 files changed, 19 insertions, 22 deletions
diff --git a/src/Kconfig b/src/Kconfig index efb21f2752..f57b305ca2 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -41,7 +41,7 @@ config RT_USING_SMART select RT_USING_POSIX_CLOCK select RT_USING_POSIX_FS select RT_USING_POSIX_TERMIOS - select RT_USING_KTIME + select RT_USING_CLOCK_TIME select RT_USING_STDC_ATOMIC select RT_USING_SYSTEM_WORKQUEUE select RT_USING_CPU_USAGE_TRACER diff --git a/src/utest/perf/Kconfig b/src/utest/perf/Kconfig index fe6ee640ce..9425c7b456 100644 --- a/src/utest/perf/Kconfig +++ b/src/utest/perf/Kconfig @@ -7,9 +7,9 @@ config RT_UTEST_SYS_PERF_TC_COUNT default 1000 depends on RT_UTEST_SYS_PERF -config RT_UTEST_HWTIMER_DEV_NAME - string "PerfTest: Hardware timer device name" +config RT_UTEST_CLOCK_TIMER_DEV_NAME + string "PerfTest: Clock time timer device name" default "timer0" - depends on RT_USING_HWTIMER && RT_UTEST_SYS_PERF + depends on RT_USING_CLOCK_TIME && RT_UTEST_SYS_PERF help Specify the hardware timer device name used for context switch testing (e.g., timer0). diff --git a/src/utest/perf/irq_latency_tc.c b/src/utest/perf/irq_latency_tc.c index 51eccd3df9..a6b61b1c5f 100644 --- a/src/utest/perf/irq_latency_tc.c +++ b/src/utest/perf/irq_latency_tc.c @@ -50,7 +50,7 @@ static rt_device_t hw_dev = RT_NULL; static rt_sem_t complete_sem = RT_NULL; -static rt_hwtimerval_t timeout = {0}; +static rt_clock_timerval_t timeout = {0}; static rt_perf_t *perf_local = RT_NULL; static void modify_time(rt_perf_t *perf) @@ -79,14 +79,14 @@ rt_err_t rt_perf_irq_latency(rt_perf_t *perf) rt_strcpy(perf->name,"rt_perf_irq_latency"); #endif int ret = RT_EOK; - rt_hwtimer_mode_t mode = HWTIMER_MODE_PERIOD; + rt_clock_timer_mode_t mode = CLOCK_TIMER_MODE_PERIOD; perf_local = perf; - hw_dev = rt_device_find(RT_UTEST_HWTIMER_DEV_NAME); + hw_dev = rt_device_find(RT_UTEST_CLOCK_TIMER_DEV_NAME); if (hw_dev == RT_NULL) { ret = RT_ERROR; - LOG_E("hwtimer sample run failed! can't find %s device!", RT_UTEST_HWTIMER_DEV_NAME); + LOG_E("clock_timer sample run failed! can't find %s device!", RT_UTEST_CLOCK_TIMER_DEV_NAME); return ret; } @@ -100,7 +100,7 @@ rt_err_t rt_perf_irq_latency(rt_perf_t *perf) rt_mutex_release(perf->lock); rt_device_set_rx_indicate(hw_dev, timer_callback); - rt_device_control(hw_dev, HWTIMER_CTRL_MODE_SET, (void *)&mode); + rt_device_control(hw_dev, CLOCK_TIMER_CTRL_MODE_SET, (void *)&mode); rt_perf_start_impl(perf_local, &timeout); @@ -111,4 +111,3 @@ rt_err_t rt_perf_irq_latency(rt_perf_t *perf) return RT_EOK; } - diff --git a/src/utest/perf/perf_tc.c b/src/utest/perf/perf_tc.c index 99f36733b6..65e0fa4673 100644 --- a/src/utest/perf/perf_tc.c +++ b/src/utest/perf/perf_tc.c @@ -47,7 +47,6 @@ * - Test runs via: `utest_run core.perf_test` in msh */ - #include <rtthread.h> #include <rtdevice.h> #include <rtservice.h> @@ -62,7 +61,7 @@ #define GET_DECIMALS(num) split_double(num, RET_DECIMALS) static rt_device_t hw_dev = RT_NULL; -static rt_hwtimerval_t timeout_s = { 0 }; +static rt_clock_timerval_t timeout_s = { 0 }; typedef rt_err_t (*testcase_function)(rt_perf_t *perf); testcase_function test_func_ptrs[] = { @@ -77,21 +76,21 @@ testcase_function test_func_ptrs[] = { static rt_uint32_t rt_perf_get_timer_us(void) { - rt_hwtimerval_t timer_val = { 0 }; - if (hw_dev && rt_device_read(hw_dev, 0, &timer_val, sizeof(rt_hwtimerval_t))) + rt_clock_timerval_t timer_val = { 0 }; + if (hw_dev && rt_device_read(hw_dev, 0, &timer_val, sizeof(rt_clock_timerval_t))) { return (rt_uint32_t)(timer_val.sec * 1000000u + timer_val.usec); /* return us */ } return 0; } -void rt_perf_start_impl(rt_perf_t *perf, rt_hwtimerval_t *timeout) +void rt_perf_start_impl(rt_perf_t *perf, rt_clock_timerval_t *timeout) { if (hw_dev) { if (timeout == RT_NULL) timeout = &timeout_s; - rt_device_write(hw_dev, 0, timeout, sizeof(rt_hwtimerval_t)); + rt_device_write(hw_dev, 0, timeout, sizeof(rt_clock_timerval_t)); } perf->begin_time = rt_perf_get_timer_us(); } @@ -116,7 +115,7 @@ void rt_perf_stop(rt_perf_t *perf) perf->tot_time += perf->real_time; if (hw_dev) - rt_device_control(hw_dev, HWTIMER_CTRL_STOP, NULL); + rt_device_control(hw_dev, CLOCK_TIMER_CTRL_STOP, NULL); } static rt_int32_t split_double(double num, rt_uint32_t type) @@ -206,17 +205,17 @@ static rt_err_t utest_tc_init(void) { int ret = RT_EOK; - hw_dev = rt_device_find(RT_UTEST_HWTIMER_DEV_NAME); + hw_dev = rt_device_find(RT_UTEST_CLOCK_TIMER_DEV_NAME); if (hw_dev == RT_NULL) { ret = RT_ERROR; - LOG_E("hwtimer sample run failed! can't find %s device!", RT_UTEST_HWTIMER_DEV_NAME); + LOG_E("clock_timer sample run failed! can't find %s device!", RT_UTEST_CLOCK_TIMER_DEV_NAME); return ret; } ret = rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR); if (ret != RT_EOK) { - LOG_E("open %s device failed!", RT_UTEST_HWTIMER_DEV_NAME); + LOG_E("open %s device failed!", RT_UTEST_CLOCK_TIMER_DEV_NAME); return ret; } @@ -239,4 +238,3 @@ static void testcase(void) } UTEST_TC_EXPORT(testcase, "core.perf_test", utest_tc_init, utest_tc_cleanup, 10); - diff --git a/src/utest/perf/perf_tc.h b/src/utest/perf/perf_tc.h index 06aeb5214e..0dc20e0d30 100644 --- a/src/utest/perf/perf_tc.h +++ b/src/utest/perf/perf_tc.h @@ -35,7 +35,7 @@ typedef struct rt_perf rt_bool_t dump_head; } rt_perf_t; -void rt_perf_start_impl(rt_perf_t *perf, rt_hwtimerval_t *timeout); +void rt_perf_start_impl(rt_perf_t *perf, rt_clock_timerval_t *timeout); void rt_perf_stop(rt_perf_t *perf); void rt_perf_dump( rt_perf_t *perf); |
