From baf8f4dabc12bc9ff64354e832a06dd5aa03e484 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 14 May 2013 10:12:52 +0200 Subject: smp: Simplify main CPU initialization Call _SMP_Handler_initialize() later and move bsp_smp_initialize() into _SMP_Handler_initialize(). Change bsp_smp_initialize() prototype to match integer types of calling context. --- cpukit/sapi/src/exinit.c | 10 +--------- cpukit/score/include/rtems/bspsmp.h | 23 +++++++++++++---------- cpukit/score/src/percpu.c | 12 ++++++++++-- 3 files changed, 24 insertions(+), 21 deletions(-) (limited to 'cpukit') diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c index a0abe111ab..3fb27fdfa0 100644 --- a/cpukit/sapi/src/exinit.c +++ b/cpukit/sapi/src/exinit.c @@ -119,10 +119,6 @@ void rtems_initialize_data_structures(void) _Thread_Dispatch_initialization(); - #if defined(RTEMS_SMP) - _SMP_Handler_initialize(); - #endif - _User_extensions_Handler_initialization(); _ISR_Handler_initialization(); @@ -159,12 +155,8 @@ void rtems_initialize_data_structures(void) _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_get_maximum_processors() ); + _SMP_Handler_initialize(); #endif _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING ); diff --git a/cpukit/score/include/rtems/bspsmp.h b/cpukit/score/include/rtems/bspsmp.h index e318ccadec..e1ef4882d5 100644 --- a/cpukit/score/include/rtems/bspsmp.h +++ b/cpukit/score/include/rtems/bspsmp.h @@ -50,21 +50,24 @@ extern "C" { #ifndef ASM + /** - * @brief Initialize secondary CPUs. + * @brief Performs BSP specific SMP initialization in the context of the main + * processor. + * + * This function is invoked on the main processor by RTEMS during + * initialization. All interrupt stacks are allocated at this point in case + * the CPU port allocates the interrupt stacks. * - * This method is invoked by RTEMS during initialization to bring the - * secondary CPUs out of reset. + * The BSP may start secondary processors now. * - * @param [in] maximum is the maximum number of CPU cores that RTEMS - * can handle + * @param[in] configured_cpu_count The count of processors requested by the + * application configuration. * - * @retval This method returns the number of cores available in the - * system. + * @return The count of processors available for the application in the system. + * This value is less than or equal to the configured count of processors. */ -int bsp_smp_initialize( - int maximum -); +uint32_t bsp_smp_initialize( uint32_t configured_cpu_count ); /** * @brief Obtain current CPU index. diff --git a/cpukit/score/src/percpu.c b/cpukit/score/src/percpu.c index d40b2a6154..f01d933cfe 100644 --- a/cpukit/score/src/percpu.c +++ b/cpukit/score/src/percpu.c @@ -31,13 +31,14 @@ void _SMP_Handler_initialize(void) { - int cpu; + uint32_t max_cpus = rtems_configuration_get_maximum_processors(); + uint32_t cpu; /* * Initialize per cpu pointer table */ _Per_CPU_Information_p[0] = &_Per_CPU_Information[0]; - for (cpu=1 ; cpu < rtems_configuration_get_maximum_processors(); cpu++ ) { + for ( cpu = 1 ; cpu < max_cpus; ++cpu ) { Per_CPU_Control *p = &_Per_CPU_Information[cpu]; @@ -59,6 +60,13 @@ p->state = RTEMS_BSP_SMP_CPU_INITIAL_STATE; RTEMS_COMPILER_MEMORY_BARRIER(); } + + /* + * Discover and initialize the secondary cores in an SMP system. + */ + max_cpus = bsp_smp_initialize( max_cpus ); + + _SMP_Processor_count = max_cpus; } #else /* -- cgit v1.2.3