diff options
Diffstat (limited to 'cpukit/sapi/src/cpucounterconverter.c')
-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 +); |