source: rtems/cpukit/rtems/src/partmp.c @ 4f90134

4.104.114.84.95
Last change on this file since 4f90134 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

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