[PATCH v2 7/9] bsps/leon3: Statically initialize get timecount
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Sep 21 15:19:32 UTC 2023
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 4ee5531941..9376ab4ec0 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -321,12 +321,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..dcf8d15a65 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_processor_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
--
2.35.3
More information about the devel
mailing list