diff --git a/drivers/timer/altera_avalon_timer.c b/drivers/timer/altera_avalon_timer.c index 2dec245061d..80a78b16730 100644 --- a/drivers/timer/altera_avalon_timer.c +++ b/drivers/timer/altera_avalon_timer.c @@ -96,7 +96,7 @@ int _sys_clock_driver_init(struct device *device) } -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { /* XXX Per the Altera Embedded IP Peripherals guide, you cannot * use a timer instance for both the system clock and timestamps diff --git a/drivers/timer/arcv2_timer0.c b/drivers/timer/arcv2_timer0.c index 6416a7aa6e0..3a681fb2faa 100644 --- a/drivers/timer/arcv2_timer0.c +++ b/drivers/timer/arcv2_timer0.c @@ -413,7 +413,7 @@ int sys_clock_device_ctrl(struct device *port, uint32_t ctrl_command, } #endif /* CONFIG_DEVICE_POWER_MANAGEMENT */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { return (accumulated_cycle_count + timer0_count_register_get()); } diff --git a/drivers/timer/cortex_m_systick.c b/drivers/timer/cortex_m_systick.c index 77d0a338bb5..450cdac6b75 100644 --- a/drivers/timer/cortex_m_systick.c +++ b/drivers/timer/cortex_m_systick.c @@ -557,7 +557,7 @@ int _sys_clock_driver_init(struct device *device) * systick counter is a 24-bit down counter which is reset to "reload" value * once it reaches 0. */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { return clock_accumulated_count + (SysTick->LOAD - SysTick->VAL); } diff --git a/drivers/timer/hpet.c b/drivers/timer/hpet.c index 628b29645b5..8df0126a476 100644 --- a/drivers/timer/hpet.c +++ b/drivers/timer/hpet.c @@ -593,7 +593,7 @@ int _sys_clock_driver_init(struct device *device) * it will need to call _hpetMainCounterAtomic(). */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { return (uint32_t) *_HPET_MAIN_COUNTER_VALUE; } diff --git a/drivers/timer/loapic_timer.c b/drivers/timer/loapic_timer.c index db52f6d3c52..b2400502b73 100644 --- a/drivers/timer/loapic_timer.c +++ b/drivers/timer/loapic_timer.c @@ -588,7 +588,7 @@ int sys_clock_device_ctrl(struct device *port, uint32_t ctrl_command, * * @return up counter of elapsed clock cycles */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { uint32_t val; /* system clock value */ diff --git a/drivers/timer/nrf_rtc_timer.c b/drivers/timer/nrf_rtc_timer.c index 03a7f46f73b..9f218c0f79a 100644 --- a/drivers/timer/nrf_rtc_timer.c +++ b/drivers/timer/nrf_rtc_timer.c @@ -163,7 +163,7 @@ int _sys_clock_driver_init(struct device *device) return 0; } -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { uint32_t elapsed_cycles; diff --git a/drivers/timer/pulpino_timer.c b/drivers/timer/pulpino_timer.c index 154e2c30cac..9de8243e05c 100644 --- a/drivers/timer/pulpino_timer.c +++ b/drivers/timer/pulpino_timer.c @@ -68,7 +68,7 @@ int _sys_clock_driver_init(struct device *device) * * @return up counter of elapsed clock cycles */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { return accumulated_cycle_count + timer->val; } diff --git a/drivers/timer/riscv_machine_timer.c b/drivers/timer/riscv_machine_timer.c index d944203907c..b799138ceff 100644 --- a/drivers/timer/riscv_machine_timer.c +++ b/drivers/timer/riscv_machine_timer.c @@ -89,7 +89,7 @@ int _sys_clock_driver_init(struct device *device) * * @return up counter of elapsed clock cycles */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { /* We just want a cycle count so just post what's in the low 32 * bits of the mtime real-time counter diff --git a/drivers/timer/xtensa_sys_timer.c b/drivers/timer/xtensa_sys_timer.c index 321bab87f54..3be5bcc07ad 100644 --- a/drivers/timer/xtensa_sys_timer.c +++ b/drivers/timer/xtensa_sys_timer.c @@ -345,7 +345,7 @@ int _sys_clock_driver_init(struct device *device) * * @return up counter of elapsed clock cycles */ -uint32_t k_cycle_get_32(void) +uint32_t _timer_cycle_get_32(void) { return GET_TIMER_CURRENT_TIME(); } diff --git a/include/arch/arc/v2/misc.h b/include/arch/arc/v2/misc.h index fc45ddf5945..14c711942bf 100644 --- a/include/arch/arc/v2/misc.h +++ b/include/arch/arc/v2/misc.h @@ -22,6 +22,9 @@ extern "C" { extern unsigned int k_cpu_sleep_mode; extern void k_cpu_idle(void); extern void k_cpu_atomic_idle(unsigned int key); + +extern uint32_t _timer_cycle_get_32(void); +#define _arch_k_cycle_get_32() _timer_cycle_get_32() #endif #ifdef __cplusplus diff --git a/include/arch/arm/cortex_m/misc.h b/include/arch/arm/cortex_m/misc.h index 76b3d931c29..86567e1ea64 100644 --- a/include/arch/arm/cortex_m/misc.h +++ b/include/arch/arm/cortex_m/misc.h @@ -20,6 +20,9 @@ extern "C" { #ifndef _ASMLANGUAGE extern void k_cpu_idle(void); + +extern uint32_t _timer_cycle_get_32(void); +#define _arch_k_cycle_get_32() _timer_cycle_get_32() #endif #ifdef __cplusplus diff --git a/include/arch/nios2/arch.h b/include/arch/nios2/arch.h index dbc912bf802..eb28c9c3c26 100644 --- a/include/arch/nios2/arch.h +++ b/include/arch/nios2/arch.h @@ -199,6 +199,9 @@ enum nios2_exception_cause { BIT(NIOS2_EXCEPTION_ECC_DATA_ERR)) +extern uint32_t _timer_cycle_get_32(void); +#define _arch_k_cycle_get_32() _timer_cycle_get_32() + #endif /* _ASMLANGUAGE */ #ifdef __cplusplus diff --git a/include/arch/riscv32/arch.h b/include/arch/riscv32/arch.h index 6624dc55a66..198c4f429d3 100644 --- a/include/arch/riscv32/arch.h +++ b/include/arch/riscv32/arch.h @@ -109,6 +109,9 @@ static ALWAYS_INLINE void _arch_irq_unlock(unsigned int key) : "memory"); } +extern uint32_t _timer_cycle_get_32(void); +#define _arch_k_cycle_get_32() _timer_cycle_get_32() + #endif /*_ASMLANGUAGE */ #if defined(CONFIG_SOC_RISCV32_PULPINO) diff --git a/include/arch/x86/arch.h b/include/arch/x86/arch.h index 16d8a048272..6a6a697ef23 100644 --- a/include/arch/x86/arch.h +++ b/include/arch/x86/arch.h @@ -488,6 +488,9 @@ extern void k_float_disable(k_tid_t thread); extern void k_cpu_idle(void); +extern uint32_t _timer_cycle_get_32(void); +#define _arch_k_cycle_get_32() _timer_cycle_get_32() + /** Nanokernel provided routine to report any detected fatal error. */ extern FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason, const NANO_ESF * pEsf); diff --git a/include/arch/xtensa/arch.h b/include/arch/xtensa/arch.h index e650fef22ad..acd1ed1b88b 100644 --- a/include/arch/xtensa/arch.h +++ b/include/arch/xtensa/arch.h @@ -136,6 +136,9 @@ extern void _irq_priority_set(uint32_t irq, uint32_t prio, uint32_t flags); FUNC_NORETURN void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *esf); +extern uint32_t _timer_cycle_get_32(void); +#define _arch_k_cycle_get_32() _timer_cycle_get_32() + #endif /* !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__) */ #ifdef __cplusplus } diff --git a/include/kernel.h b/include/kernel.h index 50972ad57d1..1f79343c8b6 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -1094,7 +1094,7 @@ extern uint32_t k_uptime_delta_32(int64_t *reftime); * * @return Current hardware clock up-counter (in cycles). */ -extern uint32_t k_cycle_get_32(void); +#define k_cycle_get_32() _arch_k_cycle_get_32() /** * @} end addtogroup clock_apis diff --git a/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c b/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c index 6eade5832a9..de3b168d01b 100644 --- a/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c +++ b/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c @@ -132,7 +132,6 @@ static pfunc func_array[] = { (pfunc)k_uptime_get_32, (pfunc)k_uptime_delta, (pfunc)k_uptime_delta_32, - (pfunc)k_cycle_get_32, /* thread stuff */ (pfunc)k_thread_spawn, diff --git a/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c b/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c index 0c4d8da5ac9..6a704f945fc 100644 --- a/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c +++ b/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c @@ -48,7 +48,6 @@ static pfunc func_array[] = { (pfunc)k_uptime_get_32, (pfunc)k_uptime_delta, (pfunc)k_uptime_delta_32, - (pfunc)k_cycle_get_32, /* semaphores */ (pfunc)k_sem_init,