1 | /* |
---|
2 | * Multiprocessing Support for the Partition Manager |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-2008. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/rtems/status.h> |
---|
21 | #include <rtems/score/mpci.h> |
---|
22 | #include <rtems/score/mppkt.h> |
---|
23 | #include <rtems/score/object.h> |
---|
24 | #include <rtems/rtems/options.h> |
---|
25 | #include <rtems/rtems/part.h> |
---|
26 | #include <rtems/score/thread.h> |
---|
27 | #include <rtems/rtems/support.h> |
---|
28 | |
---|
29 | /*PAGE |
---|
30 | * |
---|
31 | * _Partition_MP_Send_process_packet |
---|
32 | * |
---|
33 | */ |
---|
34 | |
---|
35 | void _Partition_MP_Send_process_packet ( |
---|
36 | Partition_MP_Remote_operations operation, |
---|
37 | Objects_Id partition_id, |
---|
38 | rtems_name name, |
---|
39 | Objects_Id proxy_id |
---|
40 | ) |
---|
41 | { |
---|
42 | Partition_MP_Packet *the_packet; |
---|
43 | uint32_t node; |
---|
44 | |
---|
45 | switch ( operation ) { |
---|
46 | |
---|
47 | case PARTITION_MP_ANNOUNCE_CREATE: |
---|
48 | case PARTITION_MP_ANNOUNCE_DELETE: |
---|
49 | case PARTITION_MP_EXTRACT_PROXY: |
---|
50 | |
---|
51 | the_packet = _Partition_MP_Get_packet(); |
---|
52 | the_packet->Prefix.the_class = MP_PACKET_PARTITION; |
---|
53 | the_packet->Prefix.length = sizeof ( Partition_MP_Packet ); |
---|
54 | the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet ); |
---|
55 | the_packet->operation = operation; |
---|
56 | the_packet->Prefix.id = partition_id; |
---|
57 | the_packet->name = name; |
---|
58 | the_packet->proxy_id = proxy_id; |
---|
59 | |
---|
60 | if ( operation == PARTITION_MP_EXTRACT_PROXY ) |
---|
61 | node = _Objects_Get_node( partition_id ); |
---|
62 | else |
---|
63 | node = MPCI_ALL_NODES; |
---|
64 | |
---|
65 | _MPCI_Send_process_packet( node, &the_packet->Prefix ); |
---|
66 | break; |
---|
67 | |
---|
68 | case PARTITION_MP_GET_BUFFER_REQUEST: |
---|
69 | case PARTITION_MP_GET_BUFFER_RESPONSE: |
---|
70 | case PARTITION_MP_RETURN_BUFFER_REQUEST: |
---|
71 | case PARTITION_MP_RETURN_BUFFER_RESPONSE: |
---|
72 | break; |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | /*PAGE |
---|
77 | * |
---|
78 | * _Partition_MP_Send_request_packet |
---|
79 | * |
---|
80 | */ |
---|
81 | |
---|
82 | rtems_status_code _Partition_MP_Send_request_packet ( |
---|
83 | Partition_MP_Remote_operations operation, |
---|
84 | Objects_Id partition_id, |
---|
85 | void *buffer |
---|
86 | ) |
---|
87 | { |
---|
88 | Partition_MP_Packet *the_packet; |
---|
89 | |
---|
90 | switch ( operation ) { |
---|
91 | |
---|
92 | case PARTITION_MP_GET_BUFFER_REQUEST: |
---|
93 | case PARTITION_MP_RETURN_BUFFER_REQUEST: |
---|
94 | |
---|
95 | the_packet = _Partition_MP_Get_packet(); |
---|
96 | the_packet->Prefix.the_class = MP_PACKET_PARTITION; |
---|
97 | the_packet->Prefix.length = sizeof ( Partition_MP_Packet ); |
---|
98 | the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet ); |
---|
99 | the_packet->operation = operation; |
---|
100 | the_packet->Prefix.id = partition_id; |
---|
101 | the_packet->buffer = buffer; |
---|
102 | |
---|
103 | return |
---|
104 | _MPCI_Send_request_packet( |
---|
105 | _Objects_Get_node( partition_id ), |
---|
106 | &the_packet->Prefix, |
---|
107 | STATES_READY /* Not used */ |
---|
108 | ); |
---|
109 | |
---|
110 | break; |
---|
111 | |
---|
112 | case PARTITION_MP_ANNOUNCE_CREATE: |
---|
113 | case PARTITION_MP_ANNOUNCE_DELETE: |
---|
114 | case PARTITION_MP_EXTRACT_PROXY: |
---|
115 | case PARTITION_MP_GET_BUFFER_RESPONSE: |
---|
116 | case PARTITION_MP_RETURN_BUFFER_RESPONSE: |
---|
117 | break; |
---|
118 | |
---|
119 | } |
---|
120 | /* |
---|
121 | * The following line is included to satisfy compilers which |
---|
122 | * produce warnings when a function does not end with a return. |
---|
123 | */ |
---|
124 | return RTEMS_SUCCESSFUL; |
---|
125 | } |
---|
126 | |
---|
127 | /*PAGE |
---|
128 | * |
---|
129 | * _Partition_MP_Send_response_packet |
---|
130 | * |
---|
131 | */ |
---|
132 | |
---|
133 | void _Partition_MP_Send_response_packet ( |
---|
134 | Partition_MP_Remote_operations operation, |
---|
135 | Objects_Id partition_id, |
---|
136 | Thread_Control *the_thread |
---|
137 | ) |
---|
138 | { |
---|
139 | Partition_MP_Packet *the_packet; |
---|
140 | |
---|
141 | switch ( operation ) { |
---|
142 | |
---|
143 | case PARTITION_MP_GET_BUFFER_RESPONSE: |
---|
144 | case PARTITION_MP_RETURN_BUFFER_RESPONSE: |
---|
145 | |
---|
146 | the_packet = ( Partition_MP_Packet *) the_thread->receive_packet; |
---|
147 | |
---|
148 | /* |
---|
149 | * The packet being returned already contains the class, length, and |
---|
150 | * to_convert fields, therefore they are not set in this routine. |
---|
151 | */ |
---|
152 | the_packet->operation = operation; |
---|
153 | the_packet->Prefix.id = the_packet->Prefix.source_tid; |
---|
154 | |
---|
155 | _MPCI_Send_response_packet( |
---|
156 | _Objects_Get_node( the_packet->Prefix.source_tid ), |
---|
157 | &the_packet->Prefix |
---|
158 | ); |
---|
159 | break; |
---|
160 | |
---|
161 | case PARTITION_MP_ANNOUNCE_CREATE: |
---|
162 | case PARTITION_MP_ANNOUNCE_DELETE: |
---|
163 | case PARTITION_MP_EXTRACT_PROXY: |
---|
164 | case PARTITION_MP_GET_BUFFER_REQUEST: |
---|
165 | case PARTITION_MP_RETURN_BUFFER_REQUEST: |
---|
166 | break; |
---|
167 | |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | /*PAGE |
---|
172 | * |
---|
173 | * |
---|
174 | * _Partition_MP_Process_packet |
---|
175 | * |
---|
176 | */ |
---|
177 | |
---|
178 | void _Partition_MP_Process_packet ( |
---|
179 | rtems_packet_prefix *the_packet_prefix |
---|
180 | ) |
---|
181 | { |
---|
182 | Partition_MP_Packet *the_packet; |
---|
183 | Thread_Control *the_thread; |
---|
184 | boolean ignored; |
---|
185 | |
---|
186 | the_packet = (Partition_MP_Packet *) the_packet_prefix; |
---|
187 | |
---|
188 | switch ( the_packet->operation ) { |
---|
189 | |
---|
190 | case PARTITION_MP_ANNOUNCE_CREATE: |
---|
191 | |
---|
192 | ignored = _Objects_MP_Allocate_and_open( |
---|
193 | &_Partition_Information, |
---|
194 | the_packet->name, |
---|
195 | the_packet->Prefix.id, |
---|
196 | TRUE |
---|
197 | ); |
---|
198 | |
---|
199 | _MPCI_Return_packet( the_packet_prefix ); |
---|
200 | break; |
---|
201 | |
---|
202 | case PARTITION_MP_ANNOUNCE_DELETE: |
---|
203 | |
---|
204 | _Objects_MP_Close( &_Partition_Information, the_packet->Prefix.id ); |
---|
205 | |
---|
206 | _MPCI_Return_packet( the_packet_prefix ); |
---|
207 | break; |
---|
208 | |
---|
209 | case PARTITION_MP_EXTRACT_PROXY: |
---|
210 | |
---|
211 | the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id ); |
---|
212 | |
---|
213 | if ( ! _Thread_Is_null( the_thread ) ) |
---|
214 | _Thread_queue_Extract( the_thread->Wait.queue, the_thread ); |
---|
215 | |
---|
216 | _MPCI_Return_packet( the_packet_prefix ); |
---|
217 | break; |
---|
218 | |
---|
219 | case PARTITION_MP_GET_BUFFER_REQUEST: |
---|
220 | |
---|
221 | the_packet->Prefix.return_code = rtems_partition_get_buffer( |
---|
222 | the_packet->Prefix.id, |
---|
223 | &the_packet->buffer |
---|
224 | ); |
---|
225 | |
---|
226 | _Partition_MP_Send_response_packet( |
---|
227 | PARTITION_MP_GET_BUFFER_RESPONSE, |
---|
228 | the_packet->Prefix.id, |
---|
229 | _Thread_Executing |
---|
230 | ); |
---|
231 | break; |
---|
232 | |
---|
233 | case PARTITION_MP_GET_BUFFER_RESPONSE: |
---|
234 | |
---|
235 | the_thread = _MPCI_Process_response( the_packet_prefix ); |
---|
236 | |
---|
237 | *(void **)the_thread->Wait.return_argument = the_packet->buffer; |
---|
238 | |
---|
239 | _MPCI_Return_packet( the_packet_prefix ); |
---|
240 | break; |
---|
241 | |
---|
242 | case PARTITION_MP_RETURN_BUFFER_REQUEST: |
---|
243 | |
---|
244 | the_packet->Prefix.return_code = rtems_partition_return_buffer( |
---|
245 | the_packet->Prefix.id, |
---|
246 | the_packet->buffer |
---|
247 | ); |
---|
248 | |
---|
249 | _Partition_MP_Send_response_packet( |
---|
250 | PARTITION_MP_RETURN_BUFFER_RESPONSE, |
---|
251 | the_packet->Prefix.id, |
---|
252 | _Thread_Executing |
---|
253 | ); |
---|
254 | break; |
---|
255 | |
---|
256 | case PARTITION_MP_RETURN_BUFFER_RESPONSE: |
---|
257 | |
---|
258 | the_thread = _MPCI_Process_response( the_packet_prefix ); |
---|
259 | |
---|
260 | _MPCI_Return_packet( the_packet_prefix ); |
---|
261 | break; |
---|
262 | |
---|
263 | } |
---|
264 | } |
---|
265 | |
---|
266 | /*PAGE |
---|
267 | * |
---|
268 | * _Partition_MP_Send_object_was_deleted |
---|
269 | * |
---|
270 | * This routine is not needed by the Partition since a partition |
---|
271 | * cannot be deleted when buffers are in use. |
---|
272 | * |
---|
273 | */ |
---|
274 | |
---|
275 | /*PAGE |
---|
276 | * |
---|
277 | * _Partition_MP_Send_extract_proxy |
---|
278 | * |
---|
279 | */ |
---|
280 | |
---|
281 | void _Partition_MP_Send_extract_proxy ( |
---|
282 | void *argument |
---|
283 | ) |
---|
284 | { |
---|
285 | Thread_Control *the_thread = (Thread_Control *)argument; |
---|
286 | |
---|
287 | _Partition_MP_Send_process_packet( |
---|
288 | PARTITION_MP_EXTRACT_PROXY, |
---|
289 | the_thread->Wait.id, |
---|
290 | (rtems_name) 0, |
---|
291 | the_thread->Object.id |
---|
292 | ); |
---|
293 | |
---|
294 | } |
---|
295 | |
---|
296 | /*PAGE |
---|
297 | * |
---|
298 | * _Partition_MP_Get_packet |
---|
299 | * |
---|
300 | */ |
---|
301 | |
---|
302 | Partition_MP_Packet *_Partition_MP_Get_packet ( void ) |
---|
303 | { |
---|
304 | return ( (Partition_MP_Packet *) _MPCI_Get_packet() ); |
---|
305 | } |
---|
306 | |
---|
307 | /* end of file */ |
---|