[rtems commit] bsps/leon3: Statically initialize get timecount

Sebastian Huber sebh at rtems.org
Fri Oct 20 08:56:39 UTC 2023


Module:    rtems
Branch:    master
Commit:    ffa29bac30cd5009cd94f39de6a52619b412a48f
Changeset: http://git.rtems.org/rtems/commit/?id=ffa29bac30cd5009cd94f39de6a52619b412a48f

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Sep 21 07:34:51 2023 +0200

bsps/leon3: Statically initialize get timecount

Update #4954.

---

 bsps/sparc/leon3/include/bsp/leon3.h |  2 +-
 bsps/sparc/leon3/start/cpucounter.c  | 30 ++++++++++++++++++------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h
index 06d73cffe3..650e2db744 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -358,12 +358,12 @@ typedef struct {
    */
   struct timecounter base;
 
+#if !defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
   /**
    * @brief This member provides a software fall-back counter.
    */
   uint32_t software_counter;
 
-#if !defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
   /**
    * @brief This member may reference a hardware counter register.
    */
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c
index a923c2fe63..3f135d6d6c 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -51,7 +51,9 @@ static uint32_t leon3_timecounter_get_asr_22_23_up_counter(
 
 static void leon3_counter_use_asr_22_23_up_counter(leon3_timecounter *tc)
 {
+#if !defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
   tc->base.tc_get_timecount = leon3_timecounter_get_asr_22_23_up_counter;
+#endif
   tc->base.tc_frequency = leon3_up_counter_frequency();
 }
 #endif
@@ -73,6 +75,8 @@ CPU_Counter_ticks _CPU_Counter_read(void)
 
 RTEMS_ALIAS(_CPU_Counter_read) uint32_t _SPARC_Counter_read_ISR_disabled(void);
 
+#define LEON3_GET_TIMECOUNT_INIT leon3_timecounter_get_asr_22_23_up_counter
+
 #else /* !LEON3_HAS_ASR_22_23_UP_COUNTER */
 
 /*
@@ -97,6 +101,19 @@ __asm__ (
   "\t.previous\n"
 );
 
+static uint32_t leon3_timecounter_get_dummy(struct timecounter *base)
+{
+  leon3_timecounter *tc;
+  uint32_t counter;
+
+  tc = (leon3_timecounter *) base;
+  counter = tc->software_counter + 1;
+  tc->software_counter = counter;
+  return counter;
+}
+
+#define LEON3_GET_TIMECOUNT_INIT leon3_timecounter_get_dummy
+
 static uint32_t leon3_timecounter_get_counter_down(struct timecounter *base)
 {
   leon3_timecounter *tc;
@@ -158,20 +175,9 @@ static void leon3_counter_use_irqamp_timestamp(
 #endif /* LEON3_IRQAMP_PROBE_TIMESTAMP */
 #endif /* LEON3_HAS_ASR_22_23_UP_COUNTER */
 
-static uint32_t leon3_timecounter_get_dummy(struct timecounter *base)
-{
-  leon3_timecounter *tc;
-  uint32_t counter;
-
-  tc = (leon3_timecounter *) base;
-  counter = tc->software_counter + 1;
-  tc->software_counter = counter;
-  return counter;
-}
-
 leon3_timecounter leon3_timecounter_instance = {
   .base = {
-    .tc_get_timecount = leon3_timecounter_get_dummy,
+    .tc_get_timecount = LEON3_GET_TIMECOUNT_INIT,
     .tc_counter_mask = 0xffffffff,
     .tc_frequency = 1000000000,
     .tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER



More information about the vc mailing list