source: rtems/cpukit/rtems/src/regionmp.c @ 98e4ebf

4.104.114.84.95
Last change on this file since 98e4ebf was 98e4ebf, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 8, 1997 at 3:45:54 PM

Fixed typo in the pointer to the license terms.

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