1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreMPCI |
---|
5 | * |
---|
6 | * @brief MPCI Layer Implementation |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2009. |
---|
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_MPCIIMPL_H |
---|
19 | #define _RTEMS_SCORE_MPCIIMPL_H |
---|
20 | |
---|
21 | #include <rtems/score/mpci.h> |
---|
22 | |
---|
23 | #ifdef __cplusplus |
---|
24 | extern "C" { |
---|
25 | #endif |
---|
26 | |
---|
27 | /** |
---|
28 | * @addtogroup ScoreMPCI |
---|
29 | * |
---|
30 | * @{ |
---|
31 | */ |
---|
32 | |
---|
33 | /** |
---|
34 | * For packets associated with requests that don't already have a timeout, |
---|
35 | * use the one specified by this MPCI driver. The value specified by |
---|
36 | * the MPCI driver sets an upper limit on how long a remote request |
---|
37 | * should take to complete. |
---|
38 | */ |
---|
39 | #define MPCI_DEFAULT_TIMEOUT 0xFFFFFFFF |
---|
40 | |
---|
41 | /** |
---|
42 | * The following defines the type for packet processing routines |
---|
43 | * invoked by the MPCI Receive server. |
---|
44 | */ |
---|
45 | typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * ); |
---|
46 | |
---|
47 | /** |
---|
48 | * The following enumerated type defines the list of |
---|
49 | * internal MP operations. |
---|
50 | */ |
---|
51 | typedef enum { |
---|
52 | MPCI_PACKETS_SYSTEM_VERIFY = 0 |
---|
53 | } MPCI_Internal_Remote_operations; |
---|
54 | |
---|
55 | /** |
---|
56 | * The following data structure defines the packet used to perform |
---|
57 | * remote event operations. |
---|
58 | */ |
---|
59 | typedef struct { |
---|
60 | /** This field is the general header for all packets. */ |
---|
61 | MP_packet_Prefix Prefix; |
---|
62 | /** This value specifies the operation. */ |
---|
63 | MPCI_Internal_Remote_operations operation; |
---|
64 | /** This is the maximum number of nodes in the system. It must agree |
---|
65 | * on all nodes. |
---|
66 | */ |
---|
67 | uint32_t maximum_nodes; |
---|
68 | /** This field is the maximum number of concurrently existent |
---|
69 | * globally offered objects. |
---|
70 | */ |
---|
71 | uint32_t maximum_global_objects; |
---|
72 | } MPCI_Internal_packet; |
---|
73 | |
---|
74 | /** |
---|
75 | * The following thread queue is used to maintain a list of tasks |
---|
76 | * which currently have outstanding remote requests. |
---|
77 | */ |
---|
78 | extern Thread_queue_Control _MPCI_Remote_blocked_threads; |
---|
79 | |
---|
80 | /** |
---|
81 | * The following define the internal pointers to the user's |
---|
82 | * configuration information. |
---|
83 | */ |
---|
84 | extern MPCI_Control *_MPCI_table; |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief Pointer to MP thread control block. |
---|
88 | * |
---|
89 | * The following is used to determine when the multiprocessing receive |
---|
90 | * thread is executing so that a proxy can be allocated instead of |
---|
91 | * blocking the multiprocessing receive thread. |
---|
92 | */ |
---|
93 | extern Thread_Control *_MPCI_Receive_server_tcb; |
---|
94 | |
---|
95 | /** |
---|
96 | * The following table contains the process packet routines provided |
---|
97 | * by each object that supports MP operations. |
---|
98 | */ |
---|
99 | extern MPCI_Packet_processor |
---|
100 | _MPCI_Packet_processors[ MP_PACKET_CLASSES_LAST + 1 ]; |
---|
101 | |
---|
102 | /** |
---|
103 | * This routine registers the MPCI packet processor for the |
---|
104 | * designated object class. |
---|
105 | * |
---|
106 | * @param[in] the_class is the class indicator for packets which will |
---|
107 | * be processed by @a the_packet_processor method. |
---|
108 | * @param[in] the_packet_processor is a pointer to a method which is |
---|
109 | * invoked when packets with @a the_class are received. |
---|
110 | */ |
---|
111 | void _MPCI_Register_packet_processor( |
---|
112 | MP_packet_Classes the_class, |
---|
113 | MPCI_Packet_processor the_packet_processor |
---|
114 | |
---|
115 | ); |
---|
116 | |
---|
117 | /** |
---|
118 | * This function obtains a packet by invoking the user provided |
---|
119 | * MPCI get packet callout. |
---|
120 | * |
---|
121 | * @retval This method returns a pointer to a MPCI packet which can be |
---|
122 | * filled in by the caller and used to perform a subsequent |
---|
123 | * remote operation. |
---|
124 | */ |
---|
125 | MP_packet_Prefix *_MPCI_Get_packet ( void ); |
---|
126 | |
---|
127 | /** |
---|
128 | * @brief Deallocate a packet. |
---|
129 | * |
---|
130 | * This routine deallocates a packet by invoking the user provided |
---|
131 | * MPCI return packet callout. |
---|
132 | * |
---|
133 | * @param[in] the_packet is the MP packet to deallocate. |
---|
134 | */ |
---|
135 | void _MPCI_Return_packet ( |
---|
136 | MP_packet_Prefix *the_packet |
---|
137 | ); |
---|
138 | |
---|
139 | /** |
---|
140 | * @brief Send a process packet. |
---|
141 | * |
---|
142 | * This routine sends a process packet by invoking the user provided |
---|
143 | * MPCI send callout. |
---|
144 | * |
---|
145 | * @param[in] destination is the node which should receive this packet. |
---|
146 | * @param[in] the_packet is the packet to be sent. |
---|
147 | */ |
---|
148 | void _MPCI_Send_process_packet ( |
---|
149 | uint32_t destination, |
---|
150 | MP_packet_Prefix *the_packet |
---|
151 | ); |
---|
152 | |
---|
153 | /** |
---|
154 | * @brief Send a request packet. |
---|
155 | * |
---|
156 | * This routine sends a request packet by invoking the user provided |
---|
157 | * MPCI send callout. |
---|
158 | * |
---|
159 | * @param[in] destination is the node which should receive this packet. |
---|
160 | * @param[in] the_packet is the packet to be sent. |
---|
161 | * @param[in] extra_state is the extra thread state bits which should be |
---|
162 | * set in addition to the remote operation pending state. It |
---|
163 | * may indicate the caller is blocking on a message queue |
---|
164 | * operation. |
---|
165 | * @param[in] timeout_code is the timeout code |
---|
166 | * |
---|
167 | * @retval This method returns the operation status from the remote node. |
---|
168 | */ |
---|
169 | uint32_t _MPCI_Send_request_packet ( |
---|
170 | uint32_t destination, |
---|
171 | MP_packet_Prefix *the_packet, |
---|
172 | States_Control extra_state, |
---|
173 | uint32_t timeout_code |
---|
174 | ); |
---|
175 | |
---|
176 | /** |
---|
177 | * @brief Send a response packet. |
---|
178 | * |
---|
179 | * This routine sends a response packet by invoking the user provided |
---|
180 | * MPCI send callout. |
---|
181 | * |
---|
182 | * @param[in] destination is the node which should receive this packet. |
---|
183 | * @param[in] the_packet is the packet to be sent. |
---|
184 | */ |
---|
185 | void _MPCI_Send_response_packet ( |
---|
186 | uint32_t destination, |
---|
187 | MP_packet_Prefix *the_packet |
---|
188 | ); |
---|
189 | |
---|
190 | /** |
---|
191 | * @brief Receive a packet. |
---|
192 | * |
---|
193 | * This routine receives a packet by invoking the user provided |
---|
194 | * MPCI receive callout. |
---|
195 | * |
---|
196 | * @retval This method returns the packet received. |
---|
197 | */ |
---|
198 | MP_packet_Prefix *_MPCI_Receive_packet ( void ); |
---|
199 | |
---|
200 | /** |
---|
201 | * @brief Pass a packet to the thread. |
---|
202 | * |
---|
203 | * This routine is responsible for passing @a the_packet to the thread |
---|
204 | * waiting on the remote operation to complete. The unblocked thread is |
---|
205 | * responsible for eventually freeing @a the_packet. |
---|
206 | * |
---|
207 | * @param[in] the_packet is the response packet to be processed. |
---|
208 | * |
---|
209 | * @retval This method returns a pointer to the thread which was if unblocked |
---|
210 | * or NULL if the waiting thread no longer exists. |
---|
211 | */ |
---|
212 | Thread_Control *_MPCI_Process_response ( |
---|
213 | MP_packet_Prefix *the_packet |
---|
214 | ); |
---|
215 | |
---|
216 | /** |
---|
217 | * @brief Receive and process all packets. |
---|
218 | * |
---|
219 | * This is the server thread which receives and processes all MCPI packets. |
---|
220 | * |
---|
221 | * @param[in] ignored is the thread argument. It is not used. |
---|
222 | */ |
---|
223 | void _MPCI_Receive_server( |
---|
224 | Thread_Entry_numeric_type ignored |
---|
225 | ); |
---|
226 | |
---|
227 | /** |
---|
228 | * @brief Announce the availability of a packet. |
---|
229 | * |
---|
230 | * This routine informs RTEMS of the availability of an MPCI packet. |
---|
231 | */ |
---|
232 | void _MPCI_Announce ( void ); |
---|
233 | |
---|
234 | /** |
---|
235 | * @brief Perform a process on another node. |
---|
236 | * |
---|
237 | * This routine performs a remote procedure call so that a |
---|
238 | * process operation can be performed on another node. |
---|
239 | * |
---|
240 | * @param[in] operation is the remote operation to perform. |
---|
241 | */ |
---|
242 | void _MPCI_Internal_packets_Send_process_packet ( |
---|
243 | MPCI_Internal_Remote_operations operation |
---|
244 | ); |
---|
245 | |
---|
246 | /** |
---|
247 | * _MPCI_Internal_packets_Send_request_packet |
---|
248 | * |
---|
249 | * This routine performs a remote procedure call so that a |
---|
250 | * directive operation can be initiated on another node. |
---|
251 | * |
---|
252 | * This routine is not needed since there are no request |
---|
253 | * packets to be sent by this manager. |
---|
254 | */ |
---|
255 | |
---|
256 | /** |
---|
257 | * _MPCI_Internal_packets_Send_response_packet |
---|
258 | * |
---|
259 | * This routine performs a remote procedure call so that a |
---|
260 | * directive can be performed on another node. |
---|
261 | * |
---|
262 | * This routine is not needed since there are no response |
---|
263 | * packets to be sent by this manager. |
---|
264 | */ |
---|
265 | |
---|
266 | /** |
---|
267 | * @brief Perform requested action from another node. |
---|
268 | * |
---|
269 | * This routine performs the actions specific to this package for |
---|
270 | * the request from another node. |
---|
271 | */ |
---|
272 | void _MPCI_Internal_packets_Process_packet ( |
---|
273 | MP_packet_Prefix *the_packet_prefix |
---|
274 | ); |
---|
275 | |
---|
276 | /** |
---|
277 | * _MPCI_Internal_packets_Send_object_was_deleted |
---|
278 | * |
---|
279 | * This routine is invoked indirectly by the thread queue |
---|
280 | * when a proxy has been removed from the thread queue and |
---|
281 | * the remote node must be informed of this. |
---|
282 | * |
---|
283 | * This routine is not needed since there are no objects |
---|
284 | * deleted by this manager. |
---|
285 | */ |
---|
286 | |
---|
287 | /** |
---|
288 | * _MPCI_Internal_packets_Send_extract_proxy |
---|
289 | * |
---|
290 | * This routine is invoked when a task is deleted and it |
---|
291 | * has a proxy which must be removed from a thread queue and |
---|
292 | * the remote node must be informed of this. |
---|
293 | * |
---|
294 | * This routine is not needed since there are no objects |
---|
295 | * deleted by this manager. |
---|
296 | */ |
---|
297 | |
---|
298 | /** |
---|
299 | * @brief Obtain an internal thread. |
---|
300 | * |
---|
301 | * This routine is used to obtain an internal threads MP packet. |
---|
302 | */ |
---|
303 | MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void ); |
---|
304 | |
---|
305 | /** |
---|
306 | * This function returns true if the the_packet_class is valid, |
---|
307 | * and false otherwise. |
---|
308 | * |
---|
309 | * @note Check for lower bounds (MP_PACKET_CLASSES_FIRST ) is unnecessary |
---|
310 | * because this enum starts at lower bound of zero. |
---|
311 | */ |
---|
312 | |
---|
313 | RTEMS_INLINE_ROUTINE bool _Mp_packet_Is_valid_packet_class ( |
---|
314 | MP_packet_Classes the_packet_class |
---|
315 | ) |
---|
316 | { |
---|
317 | return ( the_packet_class <= MP_PACKET_CLASSES_LAST ); |
---|
318 | } |
---|
319 | |
---|
320 | /**@}*/ |
---|
321 | |
---|
322 | #ifdef __cplusplus |
---|
323 | } |
---|
324 | #endif |
---|
325 | |
---|
326 | #endif |
---|
327 | /* end of include file */ |
---|