summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-14 14:26:34 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-14 16:26:07 +0200
commitedde99bd213d20c55430dd29089e0d8a807ab6d8 (patch)
tree186fbfb97c296606a1584fd224777b3f6ed5f98e /cpukit/score
parentscore: Add and use _Thread_Dispatch_if_necessary() (diff)
downloadrtems-edde99bd213d20c55430dd29089e0d8a807ab6d8.tar.bz2
score: Rename rtems_smp_get_number_of_processors()
Rename in rtems_smp_get_processor_count(). Always provide <rtems/score/smp.h> and <rtems/rtems/smp.h>. Add _SMP_Get_processor_count(). This function will be a compile time constant defined to be one on uni-processor configurations. This allows iterations over all processors without overhead on uni-processor configurations.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/Makefile.am4
-rw-r--r--cpukit/score/include/rtems/score/smp.h60
-rw-r--r--cpukit/score/preinstall.am9
-rw-r--r--cpukit/score/src/smp.c8
-rw-r--r--cpukit/score/src/threadcreateidle.c2
5 files changed, 42 insertions, 41 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 9aa5890245..a897e60709 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -40,6 +40,7 @@ include_rtems_score_HEADERS += include/rtems/score/schedulercbs.h
include_rtems_score_HEADERS += include/rtems/score/scheduleredf.h
include_rtems_score_HEADERS += include/rtems/score/schedulerpriority.h
include_rtems_score_HEADERS += include/rtems/score/schedulersimple.h
+include_rtems_score_HEADERS += include/rtems/score/smp.h
include_rtems_score_HEADERS += include/rtems/score/smplock.h
include_rtems_score_HEADERS += include/rtems/score/stack.h
include_rtems_score_HEADERS += include/rtems/score/states.h
@@ -62,9 +63,6 @@ include_rtems_score_HEADERS += include/rtems/score/basedefs.h
include_rtems_score_HEADERS += include/rtems/score/atomic.h
include_rtems_score_HEADERS += include/rtems/score/genericcpuatomic.h
include_rtems_score_HEADERS += include/rtems/score/genericatomicops.h
-if HAS_SMP
-include_rtems_score_HEADERS += include/rtems/score/smp.h
-endif
if HAS_PTHREADS
include_rtems_score_HEADERS += include/rtems/score/corespinlock.h
diff --git a/cpukit/score/include/rtems/score/smp.h b/cpukit/score/include/rtems/score/smp.h
index c7de6d64a9..ea073ac24b 100644
--- a/cpukit/score/include/rtems/score/smp.h
+++ b/cpukit/score/include/rtems/score/smp.h
@@ -1,10 +1,9 @@
/**
- * @file rtems/score/smp.h
+ * @file
*
- * @brief Interface to the SuperCore SMP Support used Internally to RTEMS
+ * @ingroup ScoreSMP
*
- * This include file defines the interface to the SuperCore
- * SMP support that is used internally to RTEMS.
+ * @brief SuperCore SMP Support API
*/
/*
@@ -19,24 +18,22 @@
#ifndef _RTEMS_SCORE_SMP_H
#define _RTEMS_SCORE_SMP_H
-#if defined (RTEMS_SMP)
-#include <rtems/score/percpu.h>
+#include <rtems/score/cpu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
- * @defgroup SuperCoreSMP SMP Support
+ * @defgroup ScoreSMP SMP Support
+ *
+ * @ingroup Score
*
- * @ingroup Score
+ * This defines the interface of the SuperCore SMP support.
*
- * This defines the interface of the SuperCore support
- * code for SMP support.
+ * @{
*/
-/**@{*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* This defines the bit which indicates the interprocessor interrupt
* has been requested so that RTEMS will reschedule on this CPU
@@ -58,14 +55,20 @@ extern "C" {
*/
#define RTEMS_BSP_SMP_SHUTDOWN 0x04
-#ifndef ASM
-/**
- * @brief Number of CPUs in a SMP system.
- *
- * This variable is set during the SMP initialization sequence to
- * indicate the number of CPUs in this system.
- */
-SCORE_EXTERN uint32_t _SMP_Processor_count;
+#if !defined( ASM )
+
+#if defined( RTEMS_SMP )
+ SCORE_EXTERN uint32_t _SMP_Processor_count;
+
+ static inline uint32_t _SMP_Get_processor_count( void )
+ {
+ return _SMP_Processor_count;
+ }
+#else
+ #define _SMP_Get_processor_count() ( ( uint32_t ) 1 )
+#endif
+
+#if defined( RTEMS_SMP )
/**
* @brief Sends a SMP message to a processor.
@@ -114,14 +117,15 @@ void _SMP_Request_other_cores_to_dispatch(void);
*/
void _SMP_Request_other_cores_to_shutdown(void);
-#endif
+#endif /* defined( RTEMS_SMP ) */
+
+#endif /* !defined( ASM ) */
+
+/** @} */
#ifdef __cplusplus
}
#endif
#endif
-
-/**@}*/
-#endif
/* end of include file */
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 2cbbd8c0d5..dc84b216b1 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -143,6 +143,10 @@ $(PROJECT_INCLUDE)/rtems/score/schedulersimple.h: include/rtems/score/schedulers
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulersimple.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulersimple.h
+$(PROJECT_INCLUDE)/rtems/score/smp.h: include/rtems/score/smp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smp.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smp.h
+
$(PROJECT_INCLUDE)/rtems/score/smplock.h: include/rtems/score/smplock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplock.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplock.h
@@ -231,11 +235,6 @@ $(PROJECT_INCLUDE)/rtems/score/genericatomicops.h: include/rtems/score/genericat
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/genericatomicops.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/genericatomicops.h
-if HAS_SMP
-$(PROJECT_INCLUDE)/rtems/score/smp.h: include/rtems/score/smp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smp.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smp.h
-endif
if HAS_PTHREADS
$(PROJECT_INCLUDE)/rtems/score/corespinlock.h: include/rtems/score/corespinlock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlock.h
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index a8d8f4986f..10acbe25de 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -126,7 +126,7 @@ void _SMP_Send_message( int cpu, uint32_t message )
void _SMP_Broadcast_message( uint32_t message )
{
int self = bsp_smp_processor_id();
- int ncpus = _SMP_Processor_count;
+ int ncpus = _SMP_Get_processor_count();
int cpu;
for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
@@ -146,7 +146,7 @@ void _SMP_Broadcast_message( uint32_t message )
void _SMP_Request_other_cores_to_perform_first_context_switch( void )
{
int self = bsp_smp_processor_id();
- int ncpus = _SMP_Processor_count;
+ int ncpus = _SMP_Get_processor_count();
int cpu;
for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
@@ -165,7 +165,7 @@ void _SMP_Request_other_cores_to_dispatch( void )
{
if ( _System_state_Is_up( _System_state_Get() ) ) {
int self = bsp_smp_processor_id();
- int ncpus = _SMP_Processor_count;
+ int ncpus = _SMP_Get_processor_count();
int cpu;
for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
@@ -185,7 +185,7 @@ void _SMP_Request_other_cores_to_dispatch( void )
void _SMP_Request_other_cores_to_shutdown( void )
{
int self = bsp_smp_processor_id();
- int ncpus = _SMP_Processor_count;
+ int ncpus = _SMP_Get_processor_count();
int cpu;
_SMP_Broadcast_message( RTEMS_BSP_SMP_SHUTDOWN );
diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c
index e4581c8ecb..f90db795bf 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -89,7 +89,7 @@ void _Thread_Create_idle( void )
#if defined(RTEMS_SMP)
int cpu;
- for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
+ for ( cpu=0 ; cpu < _SMP_Get_processor_count() ; cpu++ ) {
_Thread_Create_idle_helper(
_Objects_Build_name( 'I', 'D', 'L', 'E' ),
cpu