diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-05-23 14:17:25 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-06-15 13:02:44 +0200 |
commit | 65f868cac6f7fd5c3ad02046574c19f8f4673255 (patch) | |
tree | 15103fb87ed2e7161c17006e2c077f35e3506a95 /bsps/arm/shared/cpucounter/cpucounter-armv7m.c | |
parent | Add RTEMS_SYSINIT_CPU_COUNTER (diff) | |
download | rtems-65f868cac6f7fd5c3ad02046574c19f8f4673255.tar.bz2 |
Add _CPU_Counter_frequency()
Add rtems_counter_frequency() API function. Use it to initialize the
counter value converter via the new system initialization step
(RTEMS_SYSINIT_CPU_COUNTER). This decouples the counter implementation
and the counter converter. It avoids an unnecessary pull in of the
64-bit integer division from libgcc.
Update #3456.
Diffstat (limited to 'bsps/arm/shared/cpucounter/cpucounter-armv7m.c')
-rw-r--r-- | bsps/arm/shared/cpucounter/cpucounter-armv7m.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/bsps/arm/shared/cpucounter/cpucounter-armv7m.c b/bsps/arm/shared/cpucounter/cpucounter-armv7m.c index 7d2581879f..b7593602ed 100644 --- a/bsps/arm/shared/cpucounter/cpucounter-armv7m.c +++ b/bsps/arm/shared/cpucounter/cpucounter-armv7m.c @@ -19,6 +19,16 @@ #include <bsp.h> #include <bsp/fatal.h> +uint32_t _CPU_Counter_frequency(void) +{ +#ifdef BSP_ARMV7M_SYSTICK_FREQUENCY + return = BSP_ARMV7M_SYSTICK_FREQUENCY; +#else + volatile ARMV7M_Systick *systick = _ARMV7M_Systick; + return ARMV7M_SYSTICK_CALIB_TENMS_GET(systick->calib) * 100; +#endif +} + CPU_Counter_ticks _CPU_Counter_read(void) { volatile ARMV7M_DWT *dwt = _ARMV7M_DWT; @@ -32,22 +42,13 @@ static void armv7m_cpu_counter_initialize(void) cyccnt_enabled = _ARMV7M_DWT_Enable_CYCCNT(); - if (cyccnt_enabled) { - #ifdef BSP_ARMV7M_SYSTICK_FREQUENCY - uint64_t freq = BSP_ARMV7M_SYSTICK_FREQUENCY; - #else - volatile ARMV7M_Systick *systick = _ARMV7M_Systick; - uint64_t freq = ARMV7M_SYSTICK_CALIB_TENMS_GET(systick->calib) * 100ULL; - #endif - - rtems_counter_initialize_converter(freq); - } else { + if (!cyccnt_enabled) { bsp_fatal(BSP_ARM_ARMV7M_CPU_COUNTER_INIT); } } RTEMS_SYSINIT_ITEM( armv7m_cpu_counter_initialize, - RTEMS_SYSINIT_BSP_START, + RTEMS_SYSINIT_CPU_COUNTER, RTEMS_SYSINIT_ORDER_FIRST ); |