diff options
Diffstat (limited to 'cpukit/include/rtems/score/smpimpl.h')
-rw-r--r-- | cpukit/include/rtems/score/smpimpl.h | 124 |
1 files changed, 78 insertions, 46 deletions
diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h index 32704d7288..a8e3a3be15 100644 --- a/cpukit/include/rtems/score/smpimpl.h +++ b/cpukit/include/rtems/score/smpimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _RTEMS_SCORE_SMPIMPL_H @@ -21,7 +40,7 @@ #include <rtems/score/smp.h> #include <rtems/score/percpu.h> -#include <rtems/score/processormask.h> +#include <rtems/score/processormaskimpl.h> #include <rtems/fatal.h> #ifdef __cplusplus @@ -51,6 +70,16 @@ extern "C" { #define SMP_MESSAGE_PERFORM_JOBS 0x2UL /** + * @brief SMP message to force the message processing in + * _SMP_Try_to_process_message(). + * + * This message bit is never sent to a processor. It is only used to force the + * message processing in _SMP_Try_to_process_message(). Any non-zero value + * would do it. + */ +#define SMP_MESSAGE_FORCE_PROCESSING 0x4UL + +/** * @brief SMP fatal codes. */ typedef enum { @@ -62,7 +91,9 @@ typedef enum { SMP_FATAL_SHUTDOWN_RESPONSE, SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED, SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED, - SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS + SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS, + SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR, + SMP_FATAL_MULTITASKING_START_ON_NOT_ONLINE_PROCESSOR } SMP_Fatal_code; /** @@ -130,13 +161,44 @@ RTEMS_NO_RETURN void _SMP_Start_multitasking_on_secondary_processor( ); /** - * @brief Interrupts handler for inter-processor interrupts. + * @brief Processes the SMP message. * - * @param[in, out] cpu_self The cpu control for the operation. + * @param[in, out] cpu_self is the processor control of the processor executing + * this function. * - * @return The received message. + * @param message is the message to process. */ -static inline long unsigned _SMP_Inter_processor_interrupt_handler( +void _SMP_Process_message( Per_CPU_Control *cpu_self, long unsigned message ); + +/** + * @brief Tries to process the current SMP message. + * + * This function may be used in busy wait loops. + * + * @param cpu_self is the processor control of the processor executing this + * function. + * + * @param message is used to check if the SMP message processing should be + * carried out. If it is not equal to zero, then _SMP_Process_message() is + * called with a newly fetched message. This parameter is not used to process + * the message. It is only used to check if the processing is necessary. + * Use #SMP_MESSAGE_FORCE_PROCESSING to force the message processing. + */ +void _SMP_Try_to_process_message( + Per_CPU_Control *cpu_self, + unsigned long message +); + +/** + * @brief Processes an inter-processor interrupt. + * + * Use this function for the inter-processor interrupt handler. Never call + * this function in a tight loop. + * + * @param[in, out] cpu_self is the processor control of the processor executing + * this function. + */ +static inline void _SMP_Inter_processor_interrupt_handler( Per_CPU_Control *cpu_self ) { @@ -155,17 +217,8 @@ static inline long unsigned _SMP_Inter_processor_interrupt_handler( ); if ( RTEMS_PREDICT_FALSE( message != 0 ) ) { - if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) { - _SMP_Fatal( SMP_FATAL_SHUTDOWN_RESPONSE ); - /* does not continue past here */ - } - - if ( ( message & SMP_MESSAGE_PERFORM_JOBS ) != 0 ) { - _Per_CPU_Perform_jobs( cpu_self ); - } + _SMP_Process_message( cpu_self, message ); } - - return message; } /** @@ -179,36 +232,15 @@ static inline long unsigned _SMP_Inter_processor_interrupt_handler( bool _SMP_Should_start_processor( uint32_t cpu_index ); /** - * @brief Sends an SMP message to a processor. + * @brief Sends the SMP message to the processor. * * The target processor may be the sending processor. * - * @param cpu_index The target processor of the message. - * @param message The message to send. - */ -void _SMP_Send_message( uint32_t cpu_index, unsigned long message ); - -/** - * @brief Sends an SMP message to all other online processors. - * - * @param message The message to send. - */ -void _SMP_Send_message_broadcast( - unsigned long message -); - -/** - * @brief Sends an SMP message to a set of processors. + * @param[in, out] cpu is the processor control of the target processor. * - * The sending processor may be part of the set. - * - * @param targets The set of processors to send the message. - * @param message The message to send. + * @param message is the message to send. */ -void _SMP_Send_message_multicast( - const Processor_mask *targets, - unsigned long message -); +void _SMP_Send_message( Per_CPU_Control *cpu, unsigned long message ); typedef void ( *SMP_Action_handler )( void *arg ); @@ -316,7 +348,7 @@ void _SMP_Synchronize( void ); * * @return The processor mask with all online processors. */ -RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void ) +static inline const Processor_mask *_SMP_Get_online_processors( void ) { #if defined(RTEMS_SMP) return &_SMP_Online_processors; @@ -331,7 +363,7 @@ RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void ) * @return True if inter-processor interrupts are needed for the correct system * operation, otherwise false. */ -RTEMS_INLINE_ROUTINE bool _SMP_Need_inter_processor_interrupts( void ) +static inline bool _SMP_Need_inter_processor_interrupts( void ) { /* * Use the configured processor maximum instead of the actual to allow |