source: rtems/c/src/exec/rtems/src/partmp.c @ 03f2154e

4.104.114.84.95
Last change on this file since 03f2154e was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/97 at 17:20:27

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

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