[PATCH 15/17] score: Add and use <rtems/score/smpimpl.h>

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Feb 17 15:51:40 UTC 2014


Collect SMP implementation specific parts in the
<rtems/score/smpimpl.h> header file.
---
 cpukit/sapi/src/exinit.c                   |   12 +--
 cpukit/score/Makefile.am                   |    1 +
 cpukit/score/include/rtems/score/percpu.h  |    7 --
 cpukit/score/include/rtems/score/smp.h     |   66 +--------------
 cpukit/score/include/rtems/score/smpimpl.h |  123 ++++++++++++++++++++++++++++
 cpukit/score/preinstall.am                 |    4 +
 cpukit/score/src/interr.c                  |    2 +-
 cpukit/score/src/smp.c                     |    2 +-
 8 files changed, 134 insertions(+), 83 deletions(-)
 create mode 100644 cpukit/score/include/rtems/score/smpimpl.h

diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index e8b009b..d265455 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -45,6 +45,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/priority.h>
 #include <rtems/score/schedulerimpl.h>
+#include <rtems/score/smpimpl.h>
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/todimpl.h>
 #include <rtems/score/userextimpl.h>
@@ -59,11 +60,6 @@
   #include <rtems/posix/posixapi.h>
 #endif
 
-#if defined(RTEMS_SMP)
-  #include <rtems/score/smp.h>
-  #include <rtems/score/percpu.h>
-#endif
-
 Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
 
 void rtems_initialize_data_structures(void)
@@ -150,9 +146,7 @@ void rtems_initialize_data_structures(void)
     _POSIX_API_Initialize();
   #endif
 
-  #if defined(RTEMS_SMP)
-    _SMP_Handler_initialize();
-  #endif
+  _SMP_Handler_initialize();
 
   _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
 
@@ -216,9 +210,7 @@ void rtems_initialize_start_multitasking(void)
 {
   _System_state_Set( SYSTEM_STATE_UP );
 
-#if defined(RTEMS_SMP)
   _SMP_Request_other_cores_to_perform_first_context_switch();
-#endif
 
   _Thread_Start_multitasking();
 
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 482e78d..b247af6 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -61,6 +61,7 @@ include_rtems_score_HEADERS += include/rtems/score/schedulersmpimpl.h
 include_rtems_score_HEADERS += include/rtems/score/smp.h
 include_rtems_score_HEADERS += include/rtems/score/smpbarrier.h
 include_rtems_score_HEADERS += include/rtems/score/smplock.h
+include_rtems_score_HEADERS += include/rtems/score/smpimpl.h
 include_rtems_score_HEADERS += include/rtems/score/stack.h
 include_rtems_score_HEADERS += include/rtems/score/stackimpl.h
 include_rtems_score_HEADERS += include/rtems/score/states.h
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
index 8acd867..4c46b50 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -307,13 +307,6 @@ static inline void _Per_CPU_Send_interrupt( const Per_CPU_Control *per_cpu )
 }
 
 /**
- *  @brief Initialize SMP Handler
- *
- *  This method initialize the SMP Handler.
- */
-void _SMP_Handler_initialize(void);
-
-/**
  *  @brief Allocate and Initialize Per CPU Structures
  *
  *  This method allocates and initialize the per CPU structure.
diff --git a/cpukit/score/include/rtems/score/smp.h b/cpukit/score/include/rtems/score/smp.h
index 3c60baa..521cd7b 100644
--- a/cpukit/score/include/rtems/score/smp.h
+++ b/cpukit/score/include/rtems/score/smp.h
@@ -34,20 +34,6 @@ extern "C" {
  * @{
  */
 
-/**
- * @brief SMP message to request a processor shutdown.
- *
- * @see _SMP_Send_message().
- */
-#define SMP_MESSAGE_SHUTDOWN UINT32_C(0x1)
-
-/**
- * @brief SMP fatal codes.
- */
-typedef enum {
-  SMP_FATAL_SHUTDOWN
-} SMP_Fatal_code;
-
 #if defined( RTEMS_SMP )
   SCORE_EXTERN uint32_t _SMP_Processor_count;
 
@@ -60,56 +46,6 @@ typedef enum {
 #endif
 
 #if defined( RTEMS_SMP )
-
-/**
- *  @brief Sends a SMP message to a processor.
- *
- *  The target processor may be the sending processor.
- *
- *  @param[in] cpu The target processor of the message.
- *  @param[in] message The message.
- */
-void _SMP_Send_message( uint32_t cpu, uint32_t message );
-
-/**
- *  @brief Request of others CPUs.
- *
- *  This method is invoked by RTEMS when it needs to make a request
- *  of the other CPUs.  It should be implemented using some type of
- *  interprocessor interrupt. CPUs not including the originating
- *  CPU should receive the message.
- *
- *  @param [in] message is message to send
- */
-void _SMP_Broadcast_message(
-  uint32_t  message
-);
-
-/**
- *  @brief Request other cores to perform first context switch.
- *
- *  Send message to other cores requesting them to perform
- *  their first context switch operation.
- */
-void _SMP_Request_other_cores_to_perform_first_context_switch(void);
-
-#endif /* defined( RTEMS_SMP ) */
-
-/**
- *  @brief Request other cores to shutdown.
- *
- *  Send message to other cores requesting them to shutdown.
- */
-#if defined( RTEMS_SMP )
-  void _SMP_Request_other_cores_to_shutdown( void );
-#else
-  #define _SMP_Request_other_cores_to_shutdown() \
-    do { } while ( 0 )
-#endif
-
-/** @} */
-
-#if defined( RTEMS_SMP )
   RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
     _SMP_Get_current_processor( void )
   {
@@ -119,6 +55,8 @@ void _SMP_Request_other_cores_to_perform_first_context_switch(void);
   #define _SMP_Get_current_processor() UINT32_C(0)
 #endif
 
+/** @} */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/cpukit/score/include/rtems/score/smpimpl.h b/cpukit/score/include/rtems/score/smpimpl.h
new file mode 100644
index 0000000..59f2b10
--- /dev/null
+++ b/cpukit/score/include/rtems/score/smpimpl.h
@@ -0,0 +1,123 @@
+/**
+ * @file
+ *
+ * @ingroup ScoreSMPImpl
+ *
+ * @brief SuperCore SMP Implementation
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_SMPIMPL_H
+#define _RTEMS_SCORE_SMPIMPL_H
+
+#include <rtems/score/smp.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup ScoreSMP SMP Support
+ *
+ * @ingroup Score
+ *
+ * This defines the interface of the SuperCore SMP support.
+ *
+ * @{
+ */
+
+/**
+ * @brief SMP message to request a processor shutdown.
+ *
+ * @see _SMP_Send_message().
+ */
+#define SMP_MESSAGE_SHUTDOWN UINT32_C(0x1)
+
+/**
+ * @brief SMP fatal codes.
+ */
+typedef enum {
+  SMP_FATAL_SHUTDOWN
+} SMP_Fatal_code;
+
+/**
+ *  @brief Initialize SMP Handler
+ *
+ *  This method initialize the SMP Handler.
+ */
+#if defined( RTEMS_SMP )
+  void _SMP_Handler_initialize( void );
+#else
+  #define _SMP_Handler_initialize() \
+    do { } while ( 0 )
+#endif
+
+#if defined( RTEMS_SMP )
+
+/**
+ *  @brief Sends a SMP message to a processor.
+ *
+ *  The target processor may be the sending processor.
+ *
+ *  @param[in] cpu The target processor of the message.
+ *  @param[in] message The message.
+ */
+void _SMP_Send_message( uint32_t cpu, uint32_t message );
+
+/**
+ *  @brief Request of others CPUs.
+ *
+ *  This method is invoked by RTEMS when it needs to make a request
+ *  of the other CPUs.  It should be implemented using some type of
+ *  interprocessor interrupt. CPUs not including the originating
+ *  CPU should receive the message.
+ *
+ *  @param [in] message is message to send
+ */
+void _SMP_Broadcast_message(
+  uint32_t  message
+);
+
+#endif /* defined( RTEMS_SMP ) */
+
+/**
+ *  @brief Request other cores to perform first context switch.
+ *
+ *  Send message to other cores requesting them to perform
+ *  their first context switch operation.
+ */
+#if defined( RTEMS_SMP )
+  void _SMP_Request_other_cores_to_perform_first_context_switch( void );
+#else
+  #define _SMP_Request_other_cores_to_perform_first_context_switch() \
+    do { } while ( 0 )
+#endif
+
+/**
+ *  @brief Request other cores to shutdown.
+ *
+ *  Send message to other cores requesting them to shutdown.
+ */
+#if defined( RTEMS_SMP )
+  void _SMP_Request_other_cores_to_shutdown( void );
+#else
+  #define _SMP_Request_other_cores_to_shutdown() \
+    do { } while ( 0 )
+#endif
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index ceefbe7..c9d0ab9 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -227,6 +227,10 @@ $(PROJECT_INCLUDE)/rtems/score/smplock.h: include/rtems/score/smplock.h $(PROJEC
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplock.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplock.h
 
+$(PROJECT_INCLUDE)/rtems/score/smpimpl.h: include/rtems/score/smpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smpimpl.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smpimpl.h
+
 $(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h
diff --git a/cpukit/score/src/interr.c b/cpukit/score/src/interr.c
index d00a032..30e6af0 100644
--- a/cpukit/score/src/interr.c
+++ b/cpukit/score/src/interr.c
@@ -20,7 +20,7 @@
 
 #include <rtems/score/interr.h>
 #include <rtems/score/isrlevel.h>
-#include <rtems/score/smp.h>
+#include <rtems/score/smpimpl.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/userextimpl.h>
 
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index f3aa25f..6c2f78b 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -19,10 +19,10 @@
 #endif
 
 #include <rtems/bspsmp.h>
+#include <rtems/score/smpimpl.h>
 #include <rtems/score/assert.h>
 #include <rtems/score/threaddispatch.h>
 #include <rtems/score/threadimpl.h>
-#include <rtems/score/smp.h>
 #include <rtems/config.h>
 #include <rtems/fatal.h>
 
-- 
1.7.7




More information about the devel mailing list