source: rtems/cpukit/rtems/src/regionmp.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

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