RTEMS: cpukit/include/rtems/score/smpimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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>
23#include <rtems/score/processormask.h>
24#include <rtems/fatal.h>
25
26#ifdef __cplusplus
27extern "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
65} SMP_Fatal_code;
66
72static inline void _SMP_Fatal( SMP_Fatal_code code )
73{
74 _Terminate( RTEMS_FATAL_SOURCE_SMP, code );
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
99extern Processor_mask _SMP_Online_processors;
100
127void _SMP_Start_multitasking_on_secondary_processor(
128 Per_CPU_Control *cpu_self
129) RTEMS_NO_RETURN;
130
138static 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
178bool _SMP_Should_start_processor( uint32_t cpu_index );
179
188void _SMP_Send_message( uint32_t cpu_index, unsigned long message );
189
195void _SMP_Send_message_broadcast(
196 unsigned long message
197);
198
207void _SMP_Send_message_multicast(
208 const Processor_mask *targets,
209 unsigned long message
210);
211
212typedef void ( *SMP_Action_handler )( void *arg );
213
227void _SMP_Multicast_action(
228 const Processor_mask *targets,
229 SMP_Action_handler handler,
230 void *arg
231);
232
243void _SMP_Broadcast_action(
244 SMP_Action_handler handler,
245 void *arg
246);
247
258void _SMP_Othercast_action(
259 SMP_Action_handler handler,
260 void *arg
261);
262
272void _SMP_Unicast_action(
273 uint32_t cpu_index,
274 SMP_Action_handler handler,
275 void *arg
276);
277
284void _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
318 RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void )
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
333 RTEMS_INLINE_ROUTINE const bool _SMP_Need_inter_processor_interrupts( void )
334{
335 /*
336 * Use the configured processor maximum instead of the actual to allow
337 * testing on uni-processor systems.
338 */
339 return _SMP_Processor_configured_maximum > 1;
340}
341
344#ifdef __cplusplus
345}
346#endif
347
348#endif
349/* end of include file */
fatal.h
Fatal API.
RTEMS_PREDICT_FALSE
#define RTEMS_PREDICT_FALSE(_exp)
Returns the value of the specified integral expression and tells the compiler that the predicted valu...
Definition: basedefs.h:388
RTEMS_NO_RETURN
#define RTEMS_NO_RETURN
Definition: basedefs.h:102
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Terminate
void _Terminate(Internal_errors_Source the_source, Internal_errors_t the_error) RTEMS_NO_RETURN
Initiates system termination.
Definition: interr.c:31
RTEMS_FATAL_SOURCE_SMP
@ RTEMS_FATAL_SOURCE_SMP
Fatal source of SMP domain.
Definition: interr.h:126
_SMP_Get_online_processors
RTEMS_INLINE_ROUTINE const Processor_mask * _SMP_Get_online_processors(void)
Gets all online processors.
Definition: smpimpl.h:318
_SMP_Handler_initialize
#define _SMP_Handler_initialize()
Initializes SMP Handler.
Definition: smpimpl.h:85
_SMP_Need_inter_processor_interrupts
RTEMS_INLINE_ROUTINE const bool _SMP_Need_inter_processor_interrupts(void)
Indicate if inter-processor interrupts are needed.
Definition: smpimpl.h:333
SMP_Fatal_code
SMP_Fatal_code
SMP fatal codes.
Definition: smpimpl.h:55
_SMP_Request_shutdown
#define _SMP_Request_shutdown()
Requests a shutdown of all processors.
Definition: smpimpl.h:309
_SMP_Request_start_multitasking
#define _SMP_Request_start_multitasking()
Requests a multitasking start on all configured and available processors.
Definition: smpimpl.h:295
SMP_MESSAGE_PERFORM_JOBS
#define SMP_MESSAGE_PERFORM_JOBS
SMP message to perform per-processor jobs.
Definition: smpimpl.h:50
SMP_MESSAGE_SHUTDOWN
#define SMP_MESSAGE_SHUTDOWN
SMP message to request a processor shutdown.
Definition: smpimpl.h:43
_SMP_Processor_configured_maximum
#define _SMP_Processor_configured_maximum
The configured processor maximum.
Definition: smp.h:49
processormask.h
Processor Mask API.
percpu.h
smp.h
SuperCore SMP Support API.
Per_CPU_Control
Per CPU Core Structure.
Definition: percpu.h:347
Per_CPU_Control::dispatch_necessary
volatile bool dispatch_necessary
This is set to true when this processor needs to run the thread dispatcher.
Definition: percpu.h:400
code
Definition: inftrees.h:24
message
Definition: media-server.c:33