bsps/leon3: Statically initialize get timecount

Update #4954.
This commit is contained in:
Sebastian Huber
2023-09-21 07:34:51 +02:00
parent 8266a8a335
commit ffa29bac30
2 changed files with 19 additions and 13 deletions

View File

@@ -358,12 +358,12 @@ typedef struct {
*/ */
struct timecounter base; struct timecounter base;
#if !defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
/** /**
* @brief This member provides a software fall-back counter. * @brief This member provides a software fall-back counter.
*/ */
uint32_t software_counter; uint32_t software_counter;
#if !defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
/** /**
* @brief This member may reference a hardware counter register. * @brief This member may reference a hardware counter register.
*/ */

View File

@@ -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) 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; tc->base.tc_get_timecount = leon3_timecounter_get_asr_22_23_up_counter;
#endif
tc->base.tc_frequency = leon3_up_counter_frequency(); tc->base.tc_frequency = leon3_up_counter_frequency();
} }
#endif #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); 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 */ #else /* !LEON3_HAS_ASR_22_23_UP_COUNTER */
/* /*
@@ -97,6 +101,19 @@ __asm__ (
"\t.previous\n" "\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) static uint32_t leon3_timecounter_get_counter_down(struct timecounter *base)
{ {
leon3_timecounter *tc; leon3_timecounter *tc;
@@ -158,20 +175,9 @@ static void leon3_counter_use_irqamp_timestamp(
#endif /* LEON3_IRQAMP_PROBE_TIMESTAMP */ #endif /* LEON3_IRQAMP_PROBE_TIMESTAMP */
#endif /* LEON3_HAS_ASR_22_23_UP_COUNTER */ #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 = { leon3_timecounter leon3_timecounter_instance = {
.base = { .base = {
.tc_get_timecount = leon3_timecounter_get_dummy, .tc_get_timecount = LEON3_GET_TIMECOUNT_INIT,
.tc_counter_mask = 0xffffffff, .tc_counter_mask = 0xffffffff,
.tc_frequency = 1000000000, .tc_frequency = 1000000000,
.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER .tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER