[PATCH v2 08/15] score: Introduce _SMP_Get_online_processors()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jul 7 13:54:45 UTC 2017


Update #3059.
---
 c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c | 2 +-
 c/src/lib/libbsp/shared/clockdrv_shell.h            | 6 ++++--
 c/src/lib/libbsp/sparc/shared/timer/gptimer.c       | 2 +-
 cpukit/score/include/rtems/score/smpimpl.h          | 9 +++++++++
 cpukit/score/src/smpmulticastaction.c               | 2 +-
 cpukit/score/src/threadinitialize.c                 | 5 ++++-
 testsuites/smptests/smpipi01/init.c                 | 4 ++--
 7 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c b/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c
index c85a6b831d..3558334fbd 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c
@@ -100,7 +100,7 @@ static void restart_interrupt(void *arg)
 static void raise_restart_interrupt(void)
 {
   qoriq.pic.ipidr[RESTART_IPI_INDEX].reg =
-    _Processor_mask_To_uint32_t(&_SMP_Online_processors, 0);
+    _Processor_mask_To_uint32_t(_SMP_Get_online_processors(), 0);
   ppc_synchronize_data();
   ppc_synchronize_instructions();
 }
diff --git a/c/src/lib/libbsp/shared/clockdrv_shell.h b/c/src/lib/libbsp/shared/clockdrv_shell.h
index bf741339ae..a4d1b2df91 100644
--- a/c/src/lib/libbsp/shared/clockdrv_shell.h
+++ b/c/src/lib/libbsp/shared/clockdrv_shell.h
@@ -80,7 +80,7 @@ static void Clock_driver_timecounter_tick( void )
 
     if ( _Per_CPU_Is_boot_processor( cpu ) ) {
       rtems_timecounter_tick();
-    } else if ( _Processor_mask_Is_set( &_SMP_Online_processors, cpu_index ) ) {
+    } else if ( _Processor_mask_Is_set( _SMP_Get_online_processors(), cpu_index ) ) {
       _Watchdog_Tick( cpu );
     }
   }
@@ -227,7 +227,9 @@ rtems_device_driver Clock_initialize(
   Clock_driver_support_install_isr( Clock_isr, Old_ticker );
 
   #ifdef RTEMS_SMP
-    Clock_driver_support_set_interrupt_affinity( &_SMP_Online_processors );
+    Clock_driver_support_set_interrupt_affinity(
+      _SMP_Get_online_processors()
+    );
   #endif
 
   /*
diff --git a/c/src/lib/libbsp/sparc/shared/timer/gptimer.c b/c/src/lib/libbsp/sparc/shared/timer/gptimer.c
index 014bd7cd68..b982822ede 100644
--- a/c/src/lib/libbsp/sparc/shared/timer/gptimer.c
+++ b/c/src/lib/libbsp/sparc/shared/timer/gptimer.c
@@ -451,7 +451,7 @@ static void gptimer_tlib_irq_reg(struct tlib_dev *hand, tlib_isr_t func, void *d
 			tindex = timer->tindex;
 		}
 		drvmgr_interrupt_set_affinity(priv->dev, tindex,
-					      _SMP_Online_processors);
+					      _SMP_Get_online_processors());
 	}
 #endif
 
diff --git a/cpukit/score/include/rtems/score/smpimpl.h b/cpukit/score/include/rtems/score/smpimpl.h
index bc800b9e42..950f83a149 100644
--- a/cpukit/score/include/rtems/score/smpimpl.h
+++ b/cpukit/score/include/rtems/score/smpimpl.h
@@ -335,6 +335,15 @@ bool _SMP_Before_multitasking_action_broadcast(
     do { } while ( 0 )
 #endif
 
+RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void )
+{
+#if defined(RTEMS_SMP)
+  return &_SMP_Online_processors;
+#else
+  return &_Processor_mask_The_one_and_only.
+#endif
+}
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/score/src/smpmulticastaction.c b/cpukit/score/src/smpmulticastaction.c
index 73b15001ab..455fbd7d34 100644
--- a/cpukit/score/src/smpmulticastaction.c
+++ b/cpukit/score/src/smpmulticastaction.c
@@ -106,7 +106,7 @@ void _SMP_Multicast_action(
   }
 
   if( cpus == NULL ) {
-    _Processor_mask_Assign( &targets, &_SMP_Online_processors );
+    _Processor_mask_Assign( &targets, _SMP_Get_online_processors() );
   } else {
     _Processor_mask_Zero( &targets );
 
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 803ee7b646..3230eac2fe 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -248,7 +248,10 @@ bool _Thread_Initialize(
   RTEMS_STATIC_ASSERT( THREAD_SCHEDULER_BLOCKED == 0, Scheduler_state );
   the_thread->Scheduler.home = scheduler;
   _ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" );
-  _Processor_mask_Assign( &the_thread->Scheduler.Affinity, &_SMP_Online_processors );
+  _Processor_mask_Assign(
+    &the_thread->Scheduler.Affinity,
+    _SMP_Get_online_processors()
+   );
   _ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait Default" );
   _Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer );
   _RBTree_Initialize_node( &the_thread->Wait.Link.Registry_node );
diff --git a/testsuites/smptests/smpipi01/init.c b/testsuites/smptests/smpipi01/init.c
index 59f8771a86..cc85388f7c 100644
--- a/testsuites/smptests/smpipi01/init.c
+++ b/testsuites/smptests/smpipi01/init.c
@@ -162,7 +162,7 @@ static void test_send_message_flood(
 
   for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
     rtems_test_assert(
-      _Processor_mask_Is_set(&_SMP_Online_processors, cpu_index)
+      _Processor_mask_Is_set(_SMP_Get_online_processors(), cpu_index)
     );
 
     printf(
@@ -176,7 +176,7 @@ static void test_send_message_flood(
 
   for (; cpu_index < CPU_COUNT; ++cpu_index) {
     rtems_test_assert(
-      !_Processor_mask_Is_set(&_SMP_Online_processors, cpu_index)
+      !_Processor_mask_Is_set(_SMP_Get_online_processors(), cpu_index)
     );
   }
 }
-- 
2.12.3




More information about the devel mailing list