mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 23:23:13 +00:00
bsps/sparc/leon3: Fix GPTIMER timer index logic
The old logic would lead to an error when multiprocessing was enabled and `LEON3_GPTIMER_BASE` was defined due to `leon3_timer_core_index` being undefined. The new logic fixes this and keeps the same intent: - If multiprocessing is not enabled, the timer index is 0 - If multiprocessing is enabled and `LEON3_GPTIMER_BASE` is defined, the timer index is twice the CPU boot index - If multiprocessing is enabled and `LEON3_GPTIMER_BASE` is not defined, we fallback to the old logic using the GPTIMER core index. Close #5258
This commit is contained in:
committed by
Kinsey Moore
parent
df1d85c0f8
commit
ae361faeba
@@ -21,14 +21,6 @@
|
||||
#include <leon.h>
|
||||
#include <rtems/btimer.h>
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
#define LEON3_TIMER_INDEX \
|
||||
((rtems_configuration_get_user_multiprocessing_table()) ? \
|
||||
(rtems_configuration_get_user_multiprocessing_table()->node) - 1 : 1)
|
||||
#else
|
||||
#define LEON3_TIMER_INDEX 0
|
||||
#endif
|
||||
|
||||
bool benchmark_timer_find_average_overhead;
|
||||
|
||||
bool benchmark_timer_is_initialized = false;
|
||||
@@ -39,7 +31,7 @@ void benchmark_timer_initialize(void)
|
||||
* Timer runs long and accurate enough not to require an interrupt.
|
||||
*/
|
||||
if (LEON3_Timer_Regs) {
|
||||
gptimer_timer *timer = &LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX];
|
||||
gptimer_timer *timer = &LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX];
|
||||
if ( benchmark_timer_is_initialized == false ) {
|
||||
/* approximately 1 us per countdown */
|
||||
grlib_store_32( &timer->trldval, 0xffffff );
|
||||
@@ -61,7 +53,7 @@ benchmark_timer_t benchmark_timer_read(void)
|
||||
|
||||
if (LEON3_Timer_Regs) {
|
||||
total =
|
||||
grlib_load_32( &LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].tcntval );
|
||||
grlib_load_32( &LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].tcntval );
|
||||
|
||||
total = 0xffffff - total;
|
||||
|
||||
|
||||
@@ -216,11 +216,12 @@ extern unsigned int leon3_timer_prescaler;
|
||||
* @brief This constant defines the index of the GPTIMER timer used by the
|
||||
* clock driver.
|
||||
*/
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
#define LEON3_CLOCK_INDEX \
|
||||
( leon3_timer_core_index != 0 ? 0 : 2 * LEON3_Cpu_Index )
|
||||
#else
|
||||
#if !defined(RTEMS_MULTIPROCESSING)
|
||||
#define LEON3_CLOCK_INDEX 0
|
||||
#elif defined(LEON3_GPTIMER_BASE)
|
||||
#define LEON3_CLOCK_INDEX ( 2 * LEON3_Cpu_Index )
|
||||
#else
|
||||
#define LEON3_CLOCK_INDEX ( leon3_timer_core_index != 0 ? 0 : 2 * LEON3_Cpu_Index )
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user