[PATCH] score: Add _CPU_SMP_Prepare_start_multitasking()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Feb 16 10:55:03 UTC 2015


Update #2268.
---
 c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c  |  5 +++++
 c/src/lib/libbsp/powerpc/qoriq/startup/bspsmp.c |  5 +++++
 c/src/lib/libbsp/shared/bspsmp.c                |  4 ++++
 c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c   | 13 +++++--------
 cpukit/score/cpu/arm/rtems/score/cpu.h          |  2 ++
 cpukit/score/cpu/i386/rtems/score/cpu.h         |  2 ++
 cpukit/score/cpu/no_cpu/rtems/score/cpu.h       | 12 ++++++++++++
 cpukit/score/cpu/powerpc/rtems/score/cpu.h      |  2 ++
 cpukit/score/cpu/sparc/rtems/score/cpu.h        |  8 ++------
 cpukit/score/src/threadstartmultitasking.c      |  2 ++
 testsuites/smptests/smpfatal08/init.c           | 12 +++++-------
 11 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c b/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
index f755621..f2c0201 100644
--- a/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
+++ b/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
@@ -55,6 +55,11 @@ void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
   }
 }
 
+void _CPU_SMP_Prepare_start_multitasking( void )
+{
+  /* Do nothing */
+}
+
 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index )
 {
   arm_gic_irq_generate_software_irq(
diff --git a/c/src/lib/libbsp/powerpc/qoriq/startup/bspsmp.c b/c/src/lib/libbsp/powerpc/qoriq/startup/bspsmp.c
index 80764fe..0b0743b 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/startup/bspsmp.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/startup/bspsmp.c
@@ -228,6 +228,11 @@ void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
   }
 }
 
+void _CPU_SMP_Prepare_start_multitasking(void)
+{
+  /* Do nothing */
+}
+
 void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
 {
   qoriq.pic.ipidr [IPI_INDEX].reg = 1U << target_processor_index;
diff --git a/c/src/lib/libbsp/shared/bspsmp.c b/c/src/lib/libbsp/shared/bspsmp.c
index 3dc44b1..f243940 100644
--- a/c/src/lib/libbsp/shared/bspsmp.c
+++ b/c/src/lib/libbsp/shared/bspsmp.c
@@ -26,6 +26,10 @@ void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
 {
 }
 
+void _CPU_SMP_Prepare_start_multitasking( void )
+{
+}
+
 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index )
 {
 }
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c b/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
index ec83e31..ef9cd39 100644
--- a/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
@@ -86,16 +86,13 @@ void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
   /* Nothing to do */
 }
 
-void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
+void _CPU_SMP_Prepare_start_multitasking( void )
 {
-  /* send interrupt to destination CPU */
-  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
+  _CPU_cache_invalidate_entire_instruction();
 }
 
-void _LEON3_Start_multitasking(
-  Context_Control *heir
-)
+void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
 {
-  _CPU_cache_invalidate_entire_instruction();
-  _CPU_Context_Restart_self( heir );
+  /* send interrupt to destination CPU */
+  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
 }
diff --git a/cpukit/score/cpu/arm/rtems/score/cpu.h b/cpukit/score/cpu/arm/rtems/score/cpu.h
index 869ab1c..f0573c2 100644
--- a/cpukit/score/cpu/arm/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/rtems/score/cpu.h
@@ -504,6 +504,8 @@ void _CPU_Context_validate( uintptr_t pattern );
 
   void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
 
+  void _CPU_SMP_Prepare_start_multitasking( void );
+
   static inline uint32_t _CPU_SMP_Get_current_processor( void )
   {
     uint32_t mpidr;
diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
index 13d31a4..5639fdf 100644
--- a/cpukit/score/cpu/i386/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
@@ -494,6 +494,8 @@ uint32_t   _CPU_ISR_Get_level( void );
 
   void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
 
+  void _CPU_SMP_Prepare_start_multitasking( void );
+
   uint32_t _CPU_SMP_Get_current_processor( void );
 
   void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
index 0a0cc41..c4e838b 100644
--- a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
+++ b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
@@ -1574,6 +1574,18 @@ register struct Per_CPU_Control *_CPU_Per_CPU_current asm( "rX" );
   void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
 
   /**
+   * @brief Prepares a CPU to start multitasking in terms of SMP.
+   *
+   * This function is invoked on all processors requested by the application
+   * during system initialization.
+   *
+   * This function will be called after all processors requested by the
+   * application have been started right before the context switch to the first
+   * thread takes place.
+   */
+  void _CPU_SMP_Prepare_start_multitasking( void );
+
+  /**
    * @brief Returns the index of the current processor.
    *
    * An architecture specific method must be used to obtain the index of the
diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
index c305c77..6250c56 100644
--- a/cpukit/score/cpu/powerpc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
@@ -1123,6 +1123,8 @@ void _CPU_Context_validate( uintptr_t pattern );
 
   void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
 
+  void _CPU_SMP_Prepare_start_multitasking( void );
+
   static inline uint32_t _CPU_SMP_Get_current_processor( void )
   {
     uint32_t pir;
diff --git a/cpukit/score/cpu/sparc/rtems/score/cpu.h b/cpukit/score/cpu/sparc/rtems/score/cpu.h
index 6ce065c..c3348f0 100644
--- a/cpukit/score/cpu/sparc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sparc/rtems/score/cpu.h
@@ -1186,6 +1186,8 @@ register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" );
 
   void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
 
+  void _CPU_SMP_Prepare_start_multitasking( void );
+
   #if defined(__leon__) && !defined(RTEMS_PARAVIRT)
     static inline uint32_t _CPU_SMP_Get_current_processor( void )
     {
@@ -1197,12 +1199,6 @@ register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" );
 
   void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
 
-  #if defined(__leon__)
-  void _LEON3_Start_multitasking( Context_Control *heir )
-    RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
-  #define _CPU_Start_multitasking _LEON3_Start_multitasking
-  #endif
-
   static inline void _CPU_SMP_Processor_event_broadcast( void )
   {
     __asm__ volatile ( "" : : : "memory" );
diff --git a/cpukit/score/src/threadstartmultitasking.c b/cpukit/score/src/threadstartmultitasking.c
index bd120d2..7fbdd84 100644
--- a/cpukit/score/src/threadstartmultitasking.c
+++ b/cpukit/score/src/threadstartmultitasking.c
@@ -62,6 +62,8 @@ void _Thread_Start_multitasking( void )
   _Profiling_Thread_dispatch_disable( cpu_self, 0 );
 
 #if defined(RTEMS_SMP)
+  _CPU_SMP_Prepare_start_multitasking();
+
   /*
    * The _CPU_Context_Restart_self() implementations usually assume that self
    * context is executing.
diff --git a/testsuites/smptests/smpfatal08/init.c b/testsuites/smptests/smpfatal08/init.c
index 0c51ef0..b0fc52a 100644
--- a/testsuites/smptests/smpfatal08/init.c
+++ b/testsuites/smptests/smpfatal08/init.c
@@ -56,6 +56,11 @@ void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
   assert(0);
 }
 
+void _CPU_SMP_Prepare_start_multitasking(void)
+{
+  assert(0);
+}
+
 #if defined(RTEMS_PARAVIRT) \
   || (!defined(__leon__) && !defined(__PPC__) && !defined(__arm__))
 uint32_t _CPU_SMP_Get_current_processor(void)
@@ -64,13 +69,6 @@ uint32_t _CPU_SMP_Get_current_processor(void)
 }
 #endif
 
-#if defined(__leon__)
-void _LEON3_Start_multitasking(Context_Control *heir)
-{
-  assert(0);
-}
-#endif
-
 void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
 {
   (void) target_processor_index;
-- 
1.8.4.5



More information about the devel mailing list