[PATCH rtems] bsps/arm: Fix uninitialized value in generic timer
Christian Mauderer
christian.mauderer at embedded-brains.de
Thu Apr 16 12:21:51 UTC 2020
_CPU_Counter_frequency() can be called by the rtems_counter
initialization before arm_gt_clock_initialize() initializes the value
used in _CPU_Counter_frequency().
Update #3456.
---
bsps/arm/shared/clock/clock-generic-timer.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/bsps/arm/shared/clock/clock-generic-timer.c b/bsps/arm/shared/clock/clock-generic-timer.c
index 1f39632ba6..a0efb9c7ed 100644
--- a/bsps/arm/shared/clock/clock-generic-timer.c
+++ b/bsps/arm/shared/clock/clock-generic-timer.c
@@ -161,7 +161,6 @@ static void arm_gt_clock_initialize(void)
tc = &arm_gt_clock_instance.tc;
tc->tc_get_timecount = arm_gt_clock_get_timecount;
tc->tc_counter_mask = 0xffffffff;
- tc->tc_frequency = frequency;
tc->tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(tc);
}
@@ -178,12 +177,19 @@ CPU_Counter_ticks _CPU_Counter_read(void)
static void arm_gt_clock_early_init(void)
{
+ uint32_t frequency;
arm_gt_clock_set_control(0x3);
arm_generic_timer_get_config(
- &arm_gt_clock_instance.interval,
+ &frequency,
&arm_gt_clock_instance.irq
);
+
+ /* Used by _CPU_Counter_frequency before arm_gt_clock_initialize is called */
+ arm_gt_clock_instance.tc.tc_frequency = frequency;
+
+ /* overwritten with the calculated interval by arm_gt_clock_initialize */
+ arm_gt_clock_instance.interval = frequency;
}
RTEMS_SYSINIT_ITEM(
--
2.16.4
More information about the devel
mailing list