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.com/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 |
---|
26 | extern "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 UINT32_C(0x1) |
---|
45 | |
---|
46 | /** |
---|
47 | * @brief SMP fatal codes. |
---|
48 | */ |
---|
49 | typedef enum { |
---|
50 | SMP_FATAL_SHUTDOWN |
---|
51 | } SMP_Fatal_code; |
---|
52 | |
---|
53 | /** |
---|
54 | * @brief Initialize SMP Handler |
---|
55 | * |
---|
56 | * This method initialize the SMP Handler. |
---|
57 | */ |
---|
58 | #if defined( RTEMS_SMP ) |
---|
59 | void _SMP_Handler_initialize( void ); |
---|
60 | #else |
---|
61 | #define _SMP_Handler_initialize() \ |
---|
62 | do { } while ( 0 ) |
---|
63 | #endif |
---|
64 | |
---|
65 | #if defined( RTEMS_SMP ) |
---|
66 | |
---|
67 | /** |
---|
68 | * @brief Performs high-level initialization of a secondary processor and runs |
---|
69 | * the application threads. |
---|
70 | * |
---|
71 | * The low-level initialization code must call this function to hand over the |
---|
72 | * control of this processor to RTEMS. Interrupts must be disabled. It must |
---|
73 | * be possible to send inter-processor interrupts to this processor. Since |
---|
74 | * interrupts are disabled the inter-processor interrupt delivery is postponed |
---|
75 | * until interrupts are enabled the first time. Interrupts are enabled during |
---|
76 | * the execution begin of threads in case they have interrupt level zero (this |
---|
77 | * is the default). |
---|
78 | * |
---|
79 | * The pre-requisites for the call to this function are |
---|
80 | * - disabled interrupts, |
---|
81 | * - delivery of inter-processor interrupts is possible, |
---|
82 | * - a valid stack pointer and enough stack space, |
---|
83 | * - a valid code memory, and |
---|
84 | * - a valid BSS section. |
---|
85 | * |
---|
86 | * This function must not be called by the main processor. The main processor |
---|
87 | * uses _Thread_Start_multitasking() instead. |
---|
88 | * |
---|
89 | * This function does not return to the caller. |
---|
90 | */ |
---|
91 | void _SMP_Start_multitasking_on_secondary_processor( void ) |
---|
92 | RTEMS_COMPILER_NO_RETURN_ATTRIBUTE; |
---|
93 | |
---|
94 | /** |
---|
95 | * @brief Interrupt handler for inter-processor interrupts. |
---|
96 | */ |
---|
97 | static inline void _SMP_Inter_processor_interrupt_handler( void ) |
---|
98 | { |
---|
99 | Per_CPU_Control *self_cpu = _Per_CPU_Get(); |
---|
100 | |
---|
101 | if ( self_cpu->message != 0 ) { |
---|
102 | uint32_t message; |
---|
103 | ISR_Level level; |
---|
104 | |
---|
105 | _Per_CPU_ISR_disable_and_acquire( self_cpu, level ); |
---|
106 | message = self_cpu->message; |
---|
107 | self_cpu->message = 0; |
---|
108 | _Per_CPU_Release_and_ISR_enable( self_cpu, level ); |
---|
109 | |
---|
110 | if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) { |
---|
111 | _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_SHUTDOWN ); |
---|
112 | |
---|
113 | rtems_fatal( RTEMS_FATAL_SOURCE_SMP, SMP_FATAL_SHUTDOWN ); |
---|
114 | /* does not continue past here */ |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | /** |
---|
120 | * @brief Sends a SMP message to a processor. |
---|
121 | * |
---|
122 | * The target processor may be the sending processor. |
---|
123 | * |
---|
124 | * @param[in] cpu The target processor of the message. |
---|
125 | * @param[in] message The message. |
---|
126 | */ |
---|
127 | void _SMP_Send_message( uint32_t cpu, uint32_t message ); |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief Request of others CPUs. |
---|
131 | * |
---|
132 | * This method is invoked by RTEMS when it needs to make a request |
---|
133 | * of the other CPUs. It should be implemented using some type of |
---|
134 | * interprocessor interrupt. CPUs not including the originating |
---|
135 | * CPU should receive the message. |
---|
136 | * |
---|
137 | * @param [in] message is message to send |
---|
138 | */ |
---|
139 | void _SMP_Broadcast_message( |
---|
140 | uint32_t message |
---|
141 | ); |
---|
142 | |
---|
143 | #endif /* defined( RTEMS_SMP ) */ |
---|
144 | |
---|
145 | /** |
---|
146 | * @brief Request other cores to perform first context switch. |
---|
147 | * |
---|
148 | * Send message to other cores requesting them to perform |
---|
149 | * their first context switch operation. |
---|
150 | */ |
---|
151 | #if defined( RTEMS_SMP ) |
---|
152 | void _SMP_Request_other_cores_to_perform_first_context_switch( void ); |
---|
153 | #else |
---|
154 | #define _SMP_Request_other_cores_to_perform_first_context_switch() \ |
---|
155 | do { } while ( 0 ) |
---|
156 | #endif |
---|
157 | |
---|
158 | /** |
---|
159 | * @brief Request other cores to shutdown. |
---|
160 | * |
---|
161 | * Send message to other cores requesting them to shutdown. |
---|
162 | */ |
---|
163 | #if defined( RTEMS_SMP ) |
---|
164 | void _SMP_Request_other_cores_to_shutdown( void ); |
---|
165 | #else |
---|
166 | #define _SMP_Request_other_cores_to_shutdown() \ |
---|
167 | do { } while ( 0 ) |
---|
168 | #endif |
---|
169 | |
---|
170 | /** @} */ |
---|
171 | |
---|
172 | #ifdef __cplusplus |
---|
173 | } |
---|
174 | #endif |
---|
175 | |
---|
176 | #endif |
---|
177 | /* end of include file */ |
---|