From 7ec8d95a1e30ba2fba0a619b023dfb184703b041 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 19 Feb 2014 16:42:23 +0100 Subject: bsp/leon3: Add and use leon3_get_cpu_count() --- c/src/lib/libbsp/sparc/leon3/include/leon.h | 9 +++++++++ c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h index 1141bac9da..ccee1a381d 100644 --- a/c/src/lib/libbsp/sparc/leon3/include/leon.h +++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h @@ -334,6 +334,15 @@ void bsp_debug_uart_init(void); void leon3_power_down_loop(void) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE; +static inline uint32_t leon3_get_cpu_count( + volatile struct irqmp_regs *irqmp +) +{ + uint32_t mpstat = irqmp->mpstat; + + return ((mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1; +} + #endif /* !ASM */ #ifdef __cplusplus diff --git a/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c b/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c index 59861b344b..e8f6b6331c 100644 --- a/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c +++ b/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c @@ -55,8 +55,7 @@ uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count ) sparc_leon3_set_cctrl( 0x80000F ); - max_cpu_count = - ((LEON3_IrqCtrl_Regs->mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1; + max_cpu_count = leon3_get_cpu_count(LEON3_IrqCtrl_Regs); used_cpu_count = configured_cpu_count < max_cpu_count ? configured_cpu_count : max_cpu_count; -- cgit v1.2.3