[PATCH 2/3] bsp/leon3: Add and use leon3_get_cpu_count()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Feb 19 15:45:04 UTC 2014


---
 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 1141bac..ccee1a3 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 6bc2dd3..426dc46 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;
 
-- 
1.7.7




More information about the devel mailing list