diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-08-01 15:20:17 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-08-05 13:45:36 +0200 |
commit | b4b309c55940da12cbf099ffe19bc74179505fda (patch) | |
tree | 716a05c54f35a421305ff14d7451f3805d55994f /cpukit/score/src/threadstartmultitasking.c | |
parent | score: Delete SYSTEM_STATE_BEGIN_MULTITASKING (diff) | |
download | rtems-b4b309c55940da12cbf099ffe19bc74179505fda.tar.bz2 |
smp: Generalize _Thread_Start_multitasking()
Add context parameter to _Thread_Start_multitasking() and use this
function in rtems_smp_secondary_cpu_initialize(). This avoids
duplication of code.
Fix missing floating point context initialization in
rtems_smp_secondary_cpu_initialize(). Now performed via
_Thread_Start_multitasking().
Diffstat (limited to 'cpukit/score/src/threadstartmultitasking.c')
-rw-r--r-- | cpukit/score/src/threadstartmultitasking.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/cpukit/score/src/threadstartmultitasking.c b/cpukit/score/src/threadstartmultitasking.c index 459d0d6f9b..b6ff073404 100644 --- a/cpukit/score/src/threadstartmultitasking.c +++ b/cpukit/score/src/threadstartmultitasking.c @@ -19,26 +19,21 @@ #endif #include <rtems/score/threadimpl.h> -#include <rtems/score/sysstate.h> -void _Thread_Start_multitasking( void ) +void _Thread_Start_multitasking( Context_Control *context ) { - /* - * The system is now multitasking and completely initialized. - * This system thread now "hides" in a single processor until - * the system is shut down. - */ + Per_CPU_Control *self_cpu = _Per_CPU_Get(); + Thread_Control *heir = self_cpu->heir; - _System_state_Set( SYSTEM_STATE_UP ); +#if defined(RTEMS_SMP) + _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_UP ); - _Thread_Dispatch_necessary = false; - - #if defined(RTEMS_SMP) - _Thread_Executing->is_executing = false; - _Thread_Heir->is_executing = true; - #endif + self_cpu->executing->is_executing = false; + heir->is_executing = true; +#endif - _Thread_Executing = _Thread_Heir; + self_cpu->dispatch_necessary = false; + self_cpu->executing = heir; /* * Get the init task(s) running. @@ -58,13 +53,29 @@ void _Thread_Start_multitasking( void ) * don't need to worry about saving BSP's floating point state */ - if ( _Thread_Heir->fp_context != NULL ) - _Context_Restore_fp( &_Thread_Heir->fp_context ); + if ( heir->fp_context != NULL ) + _Context_Restore_fp( &heir->fp_context ); +#endif + +#if defined(RTEMS_SMP) + if ( context != NULL ) { #endif #if defined(_CPU_Start_multitasking) - _CPU_Start_multitasking( &_Thread_BSP_context, &_Thread_Heir->Registers ); + _CPU_Start_multitasking( context, &heir->Registers ); #else - _Context_Switch( &_Thread_BSP_context, &_Thread_Heir->Registers ); + _Context_Switch( context, &heir->Registers ); +#endif + +#if defined(RTEMS_SMP) + } else { + /* + * Threads begin execution in the _Thread_Handler() function. This function + * will call _Thread_Enable_dispatch(). + */ + _Thread_Disable_dispatch(); + + _CPU_Context_switch_to_first_task_smp( &heir->Registers ); + } #endif } |