From 65f868cac6f7fd5c3ad02046574c19f8f4673255 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 23 May 2018 14:17:25 +0200 Subject: 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. --- cpukit/sapi/src/cpucounterconverter.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'cpukit/sapi/src/cpucounterconverter.c') 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 +#include 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 +); -- cgit v1.2.3