void rtems_smp_secondary_cpu_initialize( void ) { Per_CPU_Control *self_cpu = _Per_CPU_Get(); Thread_Control *heir; #if defined(RTEMS_DEBUG) printk( "Made it to %d -- ", _Per_CPU_Get_index( self_cpu ) ); #endif _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING ); _Per_CPU_Wait_for_state( self_cpu, PER_CPU_STATE_BEGIN_MULTITASKING ); _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_UP ); /* * The Scheduler will have selected the heir thread for each CPU core. * Now we have been requested to perform the first context switch. So * force a switch to the designated heir and make it executing on * THIS core. */ heir = self_cpu->heir; heir->is_executing = true; self_cpu->executing->is_executing = false; self_cpu->executing = heir; self_cpu->dispatch_necessary = false; /* * 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 ); }
/* * Process request to switch to the first task on a secondary core. */ void rtems_smp_run_first_task(int cpu) { Thread_Control *heir; ISR_Level level; _ISR_Disable_on_this_core( level ); /* * The Scheduler will have selected the heir thread for each CPU core. * Now we have been requested to perform the first context switch. So * force a switch to the designated heir and make it executing on * THIS core. */ heir = _Thread_Heir; _Thread_Executing = heir; _CPU_Context_switch_to_first_task_smp( &heir->Registers ); }