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/sparc/leon3/start/cpucounter.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/sparc/leon3/start/cpucounter.c')
-rw-r--r-- | bsps/sparc/leon3/start/cpucounter.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c index 87554ce550..2df1409209 100644 --- a/bsps/sparc/leon3/start/cpucounter.c +++ b/bsps/sparc/leon3/start/cpucounter.c @@ -18,11 +18,17 @@ #include <rtems/sysinit.h> #include <rtems/score/sparcimpl.h> +static uint32_t leon3_counter_frequency = 1000000000; + +uint32_t _CPU_Counter_frequency(void) +{ + return leon3_up_counter_frequency; +} + static void leon3_counter_initialize(void) { volatile struct irqmp_timestamp_regs *irqmp_ts; volatile struct gptimer_regs *gpt; - unsigned int freq; irqmp_ts = &LEON3_IrqCtrl_Regs->timestamp[0]; gpt = LEON3_Timer_Regs; @@ -38,8 +44,7 @@ static void leon3_counter_initialize(void) NULL ); - freq = leon3_up_counter_frequency(); - rtems_counter_initialize_converter(freq); + leon3_counter_frequency = leon3_up_counter_frequency(); } else if (leon3_irqmp_has_timestamp(irqmp_ts)) { /* Use the interrupt controller timestamp counter if available */ @@ -52,8 +57,7 @@ static void leon3_counter_initialize(void) (volatile const uint32_t *) &irqmp_ts->counter ); - freq = ambapp_freq_get(&ambapp_plb, LEON3_IrqCtrl_Adev); - rtems_counter_initialize_converter(freq); + leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_IrqCtrl_Adev); } else if (gpt != NULL) { /* Fall back to the first GPTIMER if available */ @@ -66,15 +70,15 @@ static void leon3_counter_initialize(void) (volatile const uint32_t *) &gpt->timer[LEON3_CLOCK_INDEX].value ); - freq = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev); - rtems_counter_initialize_converter(freq / (gpt->scaler_reload - 1)); + leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev) / + (gpt->scaler_reload - 1); } } RTEMS_SYSINIT_ITEM( leon3_counter_initialize, - RTEMS_SYSINIT_BSP_START, - RTEMS_SYSINIT_ORDER_THIRD + RTEMS_SYSINIT_CPU_COUNTER, + RTEMS_SYSINIT_ORDER_FIRST ); SPARC_COUNTER_DEFINITION; |