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 /cpukit/sapi/src/cpucounterconverter.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 '')
-rw-r--r-- | cpukit/sapi/src/cpucounterconverter.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/cpukit/sapi/src/cpucounterconverter.c b/cpukit/sapi/src/cpucounterconverter.c index b896e4cc7f..12d55362df 100644 --- a/cpukit/sapi/src/cpucounterconverter.c +++ b/cpukit/sapi/src/cpucounterconverter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -13,12 +13,13 @@ */ #include <rtems/counter.h> +#include <rtems/sysinit.h> RTEMS_STATIC_ASSERT(sizeof(rtems_counter_ticks) <= sizeof(uint32_t), type); -static uint64_t to_ns_scaler = UINT64_C(1) << 32; +static uint64_t to_ns_scaler; -static uint64_t from_ns_scaler = UINT64_C(1) << 32; +static uint64_t from_ns_scaler; uint64_t rtems_counter_ticks_to_nanoseconds( rtems_counter_ticks counter ) { @@ -37,3 +38,14 @@ void rtems_counter_initialize_converter( uint32_t frequency ) to_ns_scaler = ((ns_per_s << 32) + frequency - 1) / frequency; from_ns_scaler = ((UINT64_C(1) << 32) * frequency + ns_per_s - 1) / ns_per_s; } + +static void rtems_counter_sysinit( void ) +{ + rtems_counter_initialize_converter( rtems_counter_frequency() ); +} + +RTEMS_SYSINIT_ITEM( + rtems_counter_sysinit, + RTEMS_SYSINIT_CPU_COUNTER, + RTEMS_SYSINIT_ORDER_LAST +); |