source: rtems/cpukit/score/include/rtems/score/smpimpl.h @ 64939bc

4.115
Last change on this file since 64939bc was c952ecab, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/14 at 08:28:08

score: Delete SMP_FATAL_SHUTDOWN_EARLY

Sort enum lexicographically.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSMPImpl
5 *
6 * @brief SuperCore SMP Implementation
7 */
8
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
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @defgroup ScoreSMP SMP Support
31 *
32 * @ingroup Score
33 *
34 * This defines the interface of the SuperCore SMP support.
35 *
36 * @{
37 */
38
39/**
40 * @brief SMP message to request a processor shutdown.
41 *
42 * @see _SMP_Send_message().
43 */
44#define SMP_MESSAGE_SHUTDOWN 0x1UL
45
46/**
47 * @brief SMP message to request a test handler invocation.
48 *
49 * @see _SMP_Send_message().
50 */
51#define SMP_MESSAGE_TEST 0x2UL
52
53/**
54 * @brief SMP fatal codes.
55 */
56typedef enum {
57  SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER,
58  SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT,
59  SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR,
60  SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR,
61  SMP_FATAL_SHUTDOWN,
62  SMP_FATAL_SHUTDOWN_RESPONSE,
63  SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
64} SMP_Fatal_code;
65
66static inline void _SMP_Fatal( SMP_Fatal_code code )
67{
68  _Terminate( RTEMS_FATAL_SOURCE_SMP, false, code );
69}
70
71/**
72 *  @brief Initialize SMP Handler
73 *
74 *  This method initialize the SMP Handler.
75 */
76#if defined( RTEMS_SMP )
77  void _SMP_Handler_initialize( void );
78#else
79  #define _SMP_Handler_initialize() \
80    do { } while ( 0 )
81#endif
82
83#if defined( RTEMS_SMP )
84
85/**
86 * @brief Performs high-level initialization of a secondary processor and runs
87 * the application threads.
88 *
89 * The low-level initialization code must call this function to hand over the
90 * control of this processor to RTEMS.  Interrupts must be disabled.  It must
91 * be possible to send inter-processor interrupts to this processor.  Since
92 * interrupts are disabled the inter-processor interrupt delivery is postponed
93 * until interrupts are enabled the first time.  Interrupts are enabled during
94 * the execution begin of threads in case they have interrupt level zero (this
95 * is the default).
96 *
97 * The pre-requisites for the call to this function are
98 * - disabled interrupts,
99 * - delivery of inter-processor interrupts is possible,
100 * - a valid stack pointer and enough stack space,
101 * - a valid code memory, and
102 * - a valid BSS section.
103 *
104 * This function must not be called by the main processor.  The main processor
105 * uses _Thread_Start_multitasking() instead.
106 *
107 * This function does not return to the caller.
108 */
109void _SMP_Start_multitasking_on_secondary_processor( void )
110  RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
111
112typedef void ( *SMP_Test_message_handler )( Per_CPU_Control *cpu_self );
113
114extern SMP_Test_message_handler _SMP_Test_message_handler;
115
116/**
117 * @brief Sets the handler for test messages.
118 *
119 * This handler can be used to test the inter-processor interrupt
120 * implementation.
121 */
122static inline void _SMP_Set_test_message_handler(
123  SMP_Test_message_handler handler
124)
125{
126  _SMP_Test_message_handler = handler;
127}
128
129/**
130 * @brief Interrupt handler for inter-processor interrupts.
131 */
132static inline void _SMP_Inter_processor_interrupt_handler( void )
133{
134  Per_CPU_Control *cpu_self = _Per_CPU_Get();
135
136  if ( _Atomic_Load_ulong( &cpu_self->message, ATOMIC_ORDER_RELAXED ) != 0 ) {
137    unsigned long message = _Atomic_Exchange_ulong(
138      &cpu_self->message,
139      0UL,
140      ATOMIC_ORDER_RELAXED
141    );
142
143    if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) {
144      _SMP_Fatal( SMP_FATAL_SHUTDOWN_RESPONSE );
145      /* does not continue past here */
146    }
147
148    if ( ( message & SMP_MESSAGE_TEST ) != 0 ) {
149      ( *_SMP_Test_message_handler )( cpu_self );
150    }
151  }
152}
153
154/**
155 *  @brief Sends a SMP message to a processor.
156 *
157 *  The target processor may be the sending processor.
158 *
159 *  @param[in] cpu_index The target processor of the message.
160 *  @param[in] message The message.
161 */
162void _SMP_Send_message( uint32_t cpu_index, unsigned long message );
163
164/**
165 *  @brief Request of others CPUs.
166 *
167 *  This method is invoked by RTEMS when it needs to make a request
168 *  of the other CPUs.  It should be implemented using some type of
169 *  interprocessor interrupt. CPUs not including the originating
170 *  CPU should receive the message.
171 *
172 *  @param [in] message is message to send
173 */
174void _SMP_Broadcast_message(
175  uint32_t  message
176);
177
178#endif /* defined( RTEMS_SMP ) */
179
180/**
181 * @brief Requests a multitasking start on all configured and available
182 * processors.
183 */
184#if defined( RTEMS_SMP )
185  void _SMP_Request_start_multitasking( void );
186#else
187  #define _SMP_Request_start_multitasking() \
188    do { } while ( 0 )
189#endif
190
191/**
192 * @brief Requests a shutdown of all processors.
193 *
194 * This function is a part of the system termination procedure.
195 *
196 * @see _Terminate().
197 */
198#if defined( RTEMS_SMP )
199  void _SMP_Request_shutdown( void );
200#else
201  #define _SMP_Request_shutdown() \
202    do { } while ( 0 )
203#endif
204
205/** @} */
206
207#ifdef __cplusplus
208}
209#endif
210
211#endif
212/* end of include file */
Note: See TracBrowser for help on using the repository browser.