source: rtems/c/src/exec/rtems/src/regionmp.c @ 4ca27cf

4.104.114.84.95
Last change on this file since 4ca27cf 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.3 KB
Line 
1/*
2 *  Multiprocessing Support for the Region 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/region.h>
22#include <rtems/thread.h>
23
24/*PAGE
25 *
26 *  _Region_MP_Send_process_packet
27 *
28 */
29
30void _Region_MP_Send_process_packet (
31  Region_MP_Remote_operations  operation,
32  Objects_Id                      region_id,
33  Objects_Name                    name,
34  Objects_Id                      proxy_id
35)
36{
37  Region_MP_Packet *the_packet;
38  unsigned32           node;
39
40  switch ( operation ) {
41
42    case REGION_MP_ANNOUNCE_CREATE:
43    case REGION_MP_ANNOUNCE_DELETE:
44    case REGION_MP_EXTRACT_PROXY:
45
46      the_packet                    = _Region_MP_Get_packet();
47      the_packet->Prefix.the_class  = RTEMS_MP_PACKET_REGION;
48      the_packet->Prefix.length     = sizeof ( Region_MP_Packet );
49      the_packet->Prefix.to_convert = sizeof ( Region_MP_Packet );
50      the_packet->operation         = operation;
51      the_packet->Prefix.id         = region_id;
52      the_packet->name              = name;
53      the_packet->proxy_id          = proxy_id;
54
55      if ( operation == REGION_MP_EXTRACT_PROXY )
56         node = rtems_get_node( region_id );
57      else
58         node = MPCI_ALL_NODES;
59
60      _MPCI_Send_process_packet( node, &the_packet->Prefix );
61      break;
62
63    case REGION_MP_GET_SEGMENT_REQUEST:
64    case REGION_MP_GET_SEGMENT_RESPONSE:
65    case REGION_MP_RETURN_SEGMENT_REQUEST:
66    case REGION_MP_RETURN_SEGMENT_RESPONSE:
67      break;
68  }
69}
70
71/*PAGE
72 *
73 *  _Region_MP_Send_request_packet
74 *
75 */
76
77rtems_status_code _Region_MP_Send_request_packet (
78  Region_MP_Remote_operations  operation,
79  Objects_Id                   region_id,
80  void                        *segment,
81  unsigned32                   size,
82  rtems_option              option_set,
83  rtems_interval            timeout
84)
85{
86  Region_MP_Packet *the_packet;
87
88  switch ( operation ) {
89
90    case REGION_MP_GET_SEGMENT_REQUEST:
91    case REGION_MP_RETURN_SEGMENT_REQUEST:
92
93      the_packet                    = _Region_MP_Get_packet();
94      the_packet->Prefix.the_class  = RTEMS_MP_PACKET_REGION;
95      the_packet->Prefix.length     = sizeof ( Region_MP_Packet );
96      the_packet->Prefix.to_convert = sizeof ( Region_MP_Packet );
97      if ( ! _Options_Is_no_wait(option_set))
98          the_packet->Prefix.timeout = timeout;
99
100      the_packet->operation         = operation;
101      the_packet->Prefix.id         = region_id;
102      the_packet->segment           = segment;
103      the_packet->size              = size;
104      the_packet->option_set        = option_set;
105
106      return _MPCI_Send_request_packet(
107          rtems_get_node( region_id ),
108          &the_packet->Prefix,
109          STATES_READY      /* Not used */
110        );
111      break;
112
113    case REGION_MP_ANNOUNCE_CREATE:
114    case REGION_MP_ANNOUNCE_DELETE:
115    case REGION_MP_EXTRACT_PROXY:
116    case REGION_MP_GET_SEGMENT_RESPONSE:
117    case REGION_MP_RETURN_SEGMENT_RESPONSE:
118      break;
119
120  }
121  /*
122   *  The following line is included to satisfy compilers which
123   *  produce warnings when a function does not end with a return.
124   */
125  return RTEMS_INTERNAL_ERROR;
126}
127
128/*PAGE
129 *
130 *  _Region_MP_Send_response_packet
131 *
132 */
133
134void _Region_MP_Send_response_packet (
135  Region_MP_Remote_operations  operation,
136  Objects_Id                   region_id,
137  Thread_Control              *the_thread
138)
139{
140  Region_MP_Packet *the_packet;
141
142  switch ( operation ) {
143
144    case REGION_MP_GET_SEGMENT_RESPONSE:
145    case REGION_MP_RETURN_SEGMENT_RESPONSE:
146
147      the_packet = ( Region_MP_Packet *) the_thread->receive_packet;
148
149/*
150 *  The packet being returned already contains the class, length, and
151 *  to_convert fields, therefore they are not set in this routine.
152 */
153      the_packet->operation = operation;
154      the_packet->Prefix.id = the_packet->Prefix.source_tid;
155
156      _MPCI_Send_response_packet(
157        rtems_get_node( the_packet->Prefix.source_tid ),
158        &the_packet->Prefix
159      );
160      break;
161
162    case REGION_MP_ANNOUNCE_CREATE:
163    case REGION_MP_ANNOUNCE_DELETE:
164    case REGION_MP_EXTRACT_PROXY:
165    case REGION_MP_GET_SEGMENT_REQUEST:
166    case REGION_MP_RETURN_SEGMENT_REQUEST:
167      break;
168
169  }
170}
171
172/*PAGE
173 *
174 *
175 *  _Region_MP_Process_packet
176 *
177 */
178
179void _Region_MP_Process_packet (
180  rtems_packet_prefix  *the_packet_prefix
181)
182{
183  Region_MP_Packet *the_packet;
184  Thread_Control   *the_thread;
185  boolean           ignored;
186
187  the_packet = (Region_MP_Packet *) the_packet_prefix;
188
189  switch ( the_packet->operation ) {
190
191    case REGION_MP_ANNOUNCE_CREATE:
192
193      ignored = _Objects_MP_Open(
194                  &_Region_Information,
195                  the_packet->name,
196                  the_packet->Prefix.id,
197                  TRUE
198                );
199
200      _MPCI_Return_packet( the_packet_prefix );
201      break;
202
203    case REGION_MP_ANNOUNCE_DELETE:
204
205      _Objects_MP_Close( &_Region_Information, the_packet->Prefix.id );
206
207      _MPCI_Return_packet( the_packet_prefix );
208      break;
209
210    case REGION_MP_EXTRACT_PROXY:
211
212      the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id );
213
214      if ( ! _Thread_Is_null( the_thread ) )
215        _Thread_queue_Extract( the_thread->Wait.queue, the_thread );
216
217      _MPCI_Return_packet( the_packet_prefix );
218      break;
219
220    case REGION_MP_GET_SEGMENT_REQUEST:
221
222      the_packet->Prefix.return_code = rtems_region_get_segment(
223        the_packet->Prefix.id,
224        the_packet->size,
225        the_packet->option_set,
226        the_packet->Prefix.timeout,
227        &the_packet->segment
228      );
229
230      _Region_MP_Send_response_packet(
231        REGION_MP_GET_SEGMENT_RESPONSE,
232        the_packet->Prefix.id,
233        _Thread_Executing
234      );
235      break;
236
237    case REGION_MP_GET_SEGMENT_RESPONSE:
238
239      the_thread = _MPCI_Process_response( the_packet_prefix );
240
241      *(void **)the_thread->Wait.return_argument = the_packet->segment;
242
243      _MPCI_Return_packet( the_packet_prefix );
244      break;
245
246    case REGION_MP_RETURN_SEGMENT_REQUEST:
247
248      the_packet->Prefix.return_code = rtems_region_return_segment(
249        the_packet->Prefix.id,
250        the_packet->segment
251      );
252
253      _Region_MP_Send_response_packet(
254        REGION_MP_RETURN_SEGMENT_RESPONSE,
255        the_packet->Prefix.id,
256        _Thread_Executing
257      );
258      break;
259
260    case REGION_MP_RETURN_SEGMENT_RESPONSE:
261
262      the_thread = _MPCI_Process_response( the_packet_prefix );
263
264      _MPCI_Return_packet( the_packet_prefix );
265      break;
266
267  }
268}
269
270/*PAGE
271 *
272 *  _Region_MP_Send_object_was_deleted
273 *
274 *  This routine is not needed by the Region since a region
275 *  cannot be deleted when segments are in use.
276 *
277 */
278
279/*PAGE
280 *
281 *  _Region_MP_Send_extract_proxy
282 *
283 */
284
285void _Region_MP_Send_extract_proxy (
286  Thread_Control *the_thread
287)
288{
289  _Region_MP_Send_process_packet(
290    REGION_MP_EXTRACT_PROXY,
291    the_thread->Wait.id,
292    (Objects_Name) 0,
293    the_thread->Object.id
294  );
295}
296
297/*PAGE
298 *
299 *  _Region_MP_Get_packet
300 *
301 */
302
303Region_MP_Packet *_Region_MP_Get_packet ( void )
304{
305  return ( (Region_MP_Packet *) _MPCI_Get_packet() );
306}
307
308/* end of file */
Note: See TracBrowser for help on using the repository browser.