RTEMS
smpimpl.h
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-2011.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifndef _RTEMS_SCORE_SMPIMPL_H
19 #define _RTEMS_SCORE_SMPIMPL_H
20 
21 #include <rtems/score/smp.h>
22 #include <rtems/score/percpu.h>
24 #include <rtems/fatal.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
43 #define SMP_MESSAGE_SHUTDOWN 0x1UL
44 
50 #define SMP_MESSAGE_PERFORM_JOBS 0x2UL
51 
55 typedef enum {
56  SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER,
57  SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT,
58  SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR,
59  SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR,
60  SMP_FATAL_SHUTDOWN,
61  SMP_FATAL_SHUTDOWN_RESPONSE,
62  SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED,
63  SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED,
64  SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS
66 
72 static inline void _SMP_Fatal( SMP_Fatal_code code )
73 {
75 }
76 
82 #if defined( RTEMS_SMP )
83  void _SMP_Handler_initialize( void );
84 #else
85  #define _SMP_Handler_initialize() \
86  do { } while ( 0 )
87 #endif
88 
89 #if defined( RTEMS_SMP )
90 
99 extern Processor_mask _SMP_Online_processors;
100 
128  Per_CPU_Control *cpu_self
130 
138 static inline long unsigned _SMP_Inter_processor_interrupt_handler(
139  Per_CPU_Control *cpu_self
140 )
141 {
142  unsigned long message;
143 
144  /*
145  * In the common case the inter-processor interrupt is issued to carry out a
146  * thread dispatch.
147  */
148  cpu_self->dispatch_necessary = true;
149 
150  message = _Atomic_Exchange_ulong(
151  &cpu_self->message,
152  0,
153  ATOMIC_ORDER_ACQUIRE
154  );
155 
156  if ( RTEMS_PREDICT_FALSE( message != 0 ) ) {
157  if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) {
158  _SMP_Fatal( SMP_FATAL_SHUTDOWN_RESPONSE );
159  /* does not continue past here */
160  }
161 
162  if ( ( message & SMP_MESSAGE_PERFORM_JOBS ) != 0 ) {
163  _Per_CPU_Perform_jobs( cpu_self );
164  }
165  }
166 
167  return message;
168 }
169 
178 bool _SMP_Should_start_processor( uint32_t cpu_index );
179 
188 void _SMP_Send_message( uint32_t cpu_index, unsigned long message );
189 
196  unsigned long message
197 );
198 
208  const Processor_mask *targets,
209  unsigned long message
210 );
211 
212 typedef void ( *SMP_Action_handler )( void *arg );
213 
228  const Processor_mask *targets,
229  SMP_Action_handler handler,
230  void *arg
231 );
232 
244  SMP_Action_handler handler,
245  void *arg
246 );
247 
259  SMP_Action_handler handler,
260  void *arg
261 );
262 
273  uint32_t cpu_index,
274  SMP_Action_handler handler,
275  void *arg
276 );
277 
284 void _SMP_Synchronize( void );
285 
286 #endif /* defined( RTEMS_SMP ) */
287 
292 #if defined( RTEMS_SMP )
293  void _SMP_Request_start_multitasking( void );
294 #else
295  #define _SMP_Request_start_multitasking() \
296  do { } while ( 0 )
297 #endif
298 
306 #if defined( RTEMS_SMP )
307  void _SMP_Request_shutdown( void );
308 #else
309  #define _SMP_Request_shutdown() \
310  do { } while ( 0 )
311 #endif
312 
319 {
320 #if defined(RTEMS_SMP)
321  return &_SMP_Online_processors;
322 #else
323  return &_Processor_mask_The_one_and_only;
324 #endif
325 }
326 
334 {
335  /*
336  * Use the configured processor maximum instead of the actual to allow
337  * testing on uni-processor systems.
338  */
340 }
341 
344 #ifdef __cplusplus
345 }
346 #endif
347 
348 #endif
349 /* end of include file */
void _Per_CPU_Perform_jobs(Per_CPU_Control *cpu)
Performs the jobs of the specified processor in FIFO order.
void _SMP_Handler_initialize(void)
Initializes SMP Handler.
Definition: smp.c:113
void _SMP_Unicast_action(uint32_t cpu_index, SMP_Action_handler handler, void *arg)
Initiates an SMP action on the specified target processor.
Fatal source of SMP domain.
Definition: interr.h:126
bool _SMP_Should_start_processor(uint32_t cpu_index)
Checks if the processor with the specified index should be started.
Definition: smp.c:176
void _SMP_Start_multitasking_on_secondary_processor(Per_CPU_Control *cpu_self) RTEMS_NO_RETURN
Performs high-level initialization of a secondary processor and runs the application threads...
Definition: smp.c:184
#define RTEMS_PREDICT_FALSE(_exp)
Returns the value of the specified integral expression and tells the compiler that the predicted valu...
Definition: basedefs.h:747
static __inline__ const bool _SMP_Need_inter_processor_interrupts(void)
Indicate if inter-processor interrupts are needed.
Definition: smpimpl.h:333
void _Terminate(Internal_errors_Source the_source, Internal_errors_t the_error) RTEMS_NO_RETURN
Initiates system termination.
Definition: interr.c:31
static __inline__ const Processor_mask * _SMP_Get_online_processors(void)
Gets all online processors.
Definition: smpimpl.h:318
void _SMP_Send_message_multicast(const Processor_mask *targets, unsigned long message)
Sends an SMP message to a set of processors.
Definition: smp.c:244
void _SMP_Send_message_broadcast(unsigned long message)
Sends an SMP message to all other online processors.
Definition: smp.c:224
SuperCore SMP Support API.
#define SMP_MESSAGE_PERFORM_JOBS
SMP message to perform per-processor jobs.
Definition: smpimpl.h:50
#define RTEMS_NO_RETURN
Tells the compiler in a function declaration that this function does not return.
Definition: basedefs.h:207
Per CPU Core Structure.
Definition: percpu.h:347
static void _SMP_Fatal(SMP_Fatal_code code)
Terminates with the given code.
Definition: smpimpl.h:72
void _SMP_Request_shutdown(void)
Requests a shutdown of all processors.
Definition: smp.c:205
#define SMP_MESSAGE_SHUTDOWN
SMP message to request a processor shutdown.
Definition: smpimpl.h:43
volatile bool dispatch_necessary
This is set to true when this processor needs to run the thread dispatcher.
Definition: percpu.h:400
void _SMP_Request_start_multitasking(void)
Requests a multitasking start on all configured and available processors.
Definition: smp.c:154
const uint32_t _SMP_Processor_configured_maximum
The configured processor maximum.
void _SMP_Synchronize(void)
Ensures that all store operations issued by the current processor before the call this function are v...
Processor_mask _SMP_Online_processors
Set of online processors.
Definition: smp.c:36
Processor Mask API.
void _SMP_Othercast_action(SMP_Action_handler handler, void *arg)
Initiates an SMP multicast action to the set of all online processors excluding the current processor...
Atomic_Ulong message
Bit field for SMP messages.
Definition: percpu.h:505
void _SMP_Broadcast_action(SMP_Action_handler handler, void *arg)
Initiates an SMP multicast action to the set of all online processors.
#define RTEMS_INLINE_ROUTINE
Gives a hint to the compiler in a function declaration to inline this function.
Definition: basedefs.h:683
void _SMP_Multicast_action(const Processor_mask *targets, SMP_Action_handler handler, void *arg)
Initiates an SMP multicast action to the set of target processors.
This header file defines the Fatal Error Manager API.
static long unsigned _SMP_Inter_processor_interrupt_handler(Per_CPU_Control *cpu_self)
Interrupts handler for inter-processor interrupts.
Definition: smpimpl.h:138
SMP_Fatal_code
SMP fatal codes.
Definition: smpimpl.h:55
void _SMP_Send_message(uint32_t cpu_index, unsigned long message)
Sends an SMP message to a processor.
Definition: smp.c:215