void _SMP_Handler_initialize(void) { uint32_t max_cpus = rtems_configuration_get_maximum_processors(); uint32_t cpu; /* * Initialize per cpu pointer table */ _Per_CPU_Information_p[0] = _Per_CPU_Get_by_index( 0 ); for ( cpu = 1 ; cpu < max_cpus; ++cpu ) { Per_CPU_Control *p = _Per_CPU_Get_by_index( cpu ); _Per_CPU_Information_p[cpu] = p; #if CPU_ALLOCATE_INTERRUPT_STACK == TRUE { size_t size = rtems_configuration_get_interrupt_stack_size(); uintptr_t ptr; p->interrupt_stack_low = _Workspace_Allocate_or_fatal_error( size ); ptr = (uintptr_t) _Addresses_Add_offset( p->interrupt_stack_low, size ); ptr &= ~(CPU_STACK_ALIGNMENT - 1); p->interrupt_stack_high = (void *)ptr; } #endif } /* * Discover and initialize the secondary cores in an SMP system. */ max_cpus = bsp_smp_initialize( max_cpus ); _SMP_Processor_count = max_cpus; for ( cpu = 1 ; cpu < max_cpus; ++cpu ) { const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); _Per_CPU_Wait_for_state( per_cpu, PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING ); } }
void rtems_initialize_data_structures(void) { /* * Dispatching and interrupts are disabled until the end of the * initialization sequence. This prevents an inadvertent context * switch before the executive is initialized. * * WARNING: Interrupts should have been disabled by the BSP and * are disabled by boot_card(). */ #if defined(RTEMS_MULTIPROCESSING) /* * Initialize the system state based on whether this is an MP system. * In an MP configuration, internally we view single processor * systems as a very restricted multiprocessor system. */ _Configuration_MP_table = Configuration.User_multiprocessing_table; if ( _Configuration_MP_table == NULL ) { _Configuration_MP_table = (void *)&_Initialization_Default_multiprocessing_table; _System_state_Handler_initialization( FALSE ); } else { _System_state_Handler_initialization( TRUE ); } #else _System_state_Handler_initialization( FALSE ); #endif /* * Initialize any target architecture specific support as early as possible */ _CPU_Initialize(); #if defined(RTEMS_MULTIPROCESSING) _Objects_MP_Handler_early_initialization(); #endif /* * Do this as early as possible to ensure no debugging output * is even attempted to be printed. */ _Debug_Manager_initialization(); _API_extensions_Initialization(); _Thread_Dispatch_initialization(); /* * Before this is called, we are not allowed to allocate memory * from the Workspace because it is not initialized. */ _Workspace_Handler_initialization(); #if defined(RTEMS_SMP) _SMP_Handler_initialize(); #endif _User_extensions_Handler_initialization(); _ISR_Handler_initialization(); /* * Initialize the internal support API and allocator Mutex */ _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects; _API_Mutex_Initialization( 1 ); _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex ); _Priority_bit_map_Handler_initialization(); _Watchdog_Handler_initialization(); _TOD_Handler_initialization(); _Thread_Handler_initialization(); _Scheduler_Handler_initialization(); #if defined(RTEMS_MULTIPROCESSING) _Objects_MP_Handler_initialization(); _MPCI_Handler_initialization( RTEMS_TIMEOUT ); #endif /* MANAGERS */ _RTEMS_API_Initialize(); _Extension_Manager_initialization(); _IO_Manager_initialization(); #ifdef RTEMS_POSIX_API _POSIX_API_Initialize(); #endif /* * Discover and initialize the secondary cores in an SMP system. */ #if defined(RTEMS_SMP) _SMP_Processor_count = bsp_smp_initialize( rtems_configuration_smp_maximum_processors ); #endif _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING ); /* * No threads should be created before this point!!! * _Thread_Executing and _Thread_Heir are not set. * * At this point all API extensions are in place. After the call to * _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set. */ _Thread_Create_idle(); /* * Scheduling can properly occur now as long as we avoid dispatching. */ }