RTEMS CPU Kit with SuperCore  4.11.2
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/fatal.h>
24 #include <rtems/rtems/cache.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
45 #define SMP_MESSAGE_SHUTDOWN 0x1UL
46 
52 #define SMP_MESSAGE_TEST 0x2UL
53 
59 #define SMP_MESSAGE_MULTICAST_ACTION 0x4UL
60 
64 typedef enum {
65  SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER,
66  SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT,
67  SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR,
68  SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR,
69  SMP_FATAL_SHUTDOWN,
70  SMP_FATAL_SHUTDOWN_RESPONSE,
71  SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
73 
74 static inline void _SMP_Fatal( SMP_Fatal_code code )
75 {
76  _Terminate( RTEMS_FATAL_SOURCE_SMP, false, code );
77 }
78 
84 #if defined( RTEMS_SMP )
85  void _SMP_Handler_initialize( void );
86 #else
87  #define _SMP_Handler_initialize() \
88  do { } while ( 0 )
89 #endif
90 
91 #if defined( RTEMS_SMP )
92 
117 void _SMP_Start_multitasking_on_secondary_processor( void )
119 
120 typedef void ( *SMP_Test_message_handler )( Per_CPU_Control *cpu_self );
121 
122 extern SMP_Test_message_handler _SMP_Test_message_handler;
123 
130 static inline void _SMP_Set_test_message_handler(
131  SMP_Test_message_handler handler
132 )
133 {
134  _SMP_Test_message_handler = handler;
135 }
136 
140 void _SMP_Multicast_actions_process( void );
141 
145 static inline void _SMP_Inter_processor_interrupt_handler( void )
146 {
147  Per_CPU_Control *cpu_self = _Per_CPU_Get();
148 
149  if ( _Atomic_Load_ulong( &cpu_self->message, ATOMIC_ORDER_RELAXED ) != 0 ) {
150  unsigned long message = _Atomic_Exchange_ulong(
151  &cpu_self->message,
152  0UL,
153  ATOMIC_ORDER_RELAXED
154  );
155 
156  if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) {
157  _SMP_Fatal( SMP_FATAL_SHUTDOWN_RESPONSE );
158  /* does not continue past here */
159  }
160 
161  if ( ( message & SMP_MESSAGE_TEST ) != 0 ) {
162  ( *_SMP_Test_message_handler )( cpu_self );
163  }
164 
165  if ( ( message & SMP_MESSAGE_MULTICAST_ACTION ) != 0 ) {
166  _SMP_Multicast_actions_process();
167  }
168  }
169 }
170 
180 bool _SMP_Should_start_processor( uint32_t cpu_index );
181 
190 void _SMP_Send_message( uint32_t cpu_index, unsigned long message );
191 
202 void _SMP_Send_message_broadcast(
203  unsigned long message
204 );
205 
215 void _SMP_Send_message_multicast(
216  const size_t setsize,
217  const cpu_set_t *cpus,
218  unsigned long message
219 );
220 
221 typedef void ( *SMP_Multicast_action_handler )( void *arg );
222 
233 void _SMP_Multicast_action(
234  const size_t setsize,
235  const cpu_set_t *cpus,
236  SMP_Multicast_action_handler handler,
237  void *arg
238 );
239 
240 #endif /* defined( RTEMS_SMP ) */
241 
246 #if defined( RTEMS_SMP )
247  void _SMP_Request_start_multitasking( void );
248 #else
249  #define _SMP_Request_start_multitasking() \
250  do { } while ( 0 )
251 #endif
252 
260 #if defined( RTEMS_SMP )
261  void _SMP_Request_shutdown( void );
262 #else
263  #define _SMP_Request_shutdown() \
264  do { } while ( 0 )
265 #endif
266 
269 #ifdef __cplusplus
270 }
271 #endif
272 
273 #endif
274 /* end of include file */
Definition: media-server.c:33
Fatal source of SMP domain.
Definition: interr.h:124
Fatal API.
void _Terminate(Internal_errors_Source the_source, bool is_internal, Internal_errors_t the_error)
Initiates system termination.
Definition: interr.c:31
#define SMP_MESSAGE_SHUTDOWN
SMP message to request a processor shutdown.
Definition: smpimpl.h:45
SuperCore SMP Support API.
#define _SMP_Handler_initialize()
Initialize SMP Handler.
Definition: smpimpl.h:87
This include file defines the per CPU information required by RTEMS.
Per CPU Core Structure.
Definition: percpu.h:233
#define SMP_MESSAGE_MULTICAST_ACTION
SMP message to request a multicast action.
Definition: smpimpl.h:59
#define _SMP_Request_shutdown()
Requests a shutdown of all processors.
Definition: smpimpl.h:263
Definition: inftrees.h:25
SMP_Fatal_code
SMP fatal codes.
Definition: smpimpl.h:64
#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE
The following macro is a compiler specific way to indicate that the method will NOT return to the cal...
Definition: basedefs.h:162
#define SMP_MESSAGE_TEST
SMP message to request a test handler invocation.
Definition: smpimpl.h:52
#define _SMP_Request_start_multitasking()
Requests a multitasking start on all configured and available processors.
Definition: smpimpl.h:249