summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-09-21 07:34:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-10-20 11:16:54 +0200
commitffa29bac30cd5009cd94f39de6a52619b412a48f (patch)
treecd3f926e879195fa65949cabd1cccb799cef61c2
parent8266a8a33539dec10ec258a5196fd4d331f8bb16 (diff)
bsps/leon3: Statically initialize get timecount
Update #4954.
-rw-r--r--bsps/sparc/leon3/include/bsp/leon3.h2
-rw-r--r--bsps/sparc/leon3/start/cpucounter.c30
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