source: rtems/c/src/exec/rtems/src/msgmp.c @ b3ac6a8d

4.104.114.84.95
Last change on this file since b3ac6a8d was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 12.3 KB
Line 
1/*
2 *  Multiprocessing Support for the Message Queue 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/rtems/status.h>
18#include <rtems/rtems/message.h>
19#include <rtems/core/mpci.h>
20#include <rtems/rtems/msgmp.h>
21#include <rtems/core/object.h>
22#include <rtems/rtems/options.h>
23#include <rtems/core/thread.h>
24#include <rtems/core/watchdog.h>
25#include <rtems/rtems/support.h>
26
27/*PAGE
28 *
29 *  _Message_queue_MP_Send_process_packet
30 *
31 */
32
33void _Message_queue_MP_Send_process_packet (
34  Message_queue_MP_Remote_operations  operation,
35  Objects_Id                          message_queue_id,
36  rtems_name                          name,
37  Objects_Id                          proxy_id
38)
39{
40  Message_queue_MP_Packet *the_packet;
41  unsigned32               node;
42
43  switch ( operation ) {
44
45    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
46    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
47    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
48
49      the_packet                    = _Message_queue_MP_Get_packet();
50      the_packet->Prefix.the_class  = MP_PACKET_MESSAGE_QUEUE;
51      the_packet->Prefix.length     = sizeof ( Message_queue_MP_Packet );
52      the_packet->Prefix.to_convert = sizeof ( Message_queue_MP_Packet );
53      the_packet->operation         = operation;
54      the_packet->Prefix.id         = message_queue_id;
55      the_packet->name              = name;
56      the_packet->proxy_id          = proxy_id;
57
58      if ( operation == MESSAGE_QUEUE_MP_EXTRACT_PROXY )
59         node = rtems_get_node( message_queue_id );
60      else
61         node = MPCI_ALL_NODES;
62
63      _MPCI_Send_process_packet( node, &the_packet->Prefix );
64      break;
65
66    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
67    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
68    case MESSAGE_QUEUE_MP_SEND_REQUEST:
69    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
70    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
71    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
72    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
73    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
74    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
75    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
76      break;
77
78  }
79}
80
81/*PAGE
82 *
83 *  _Message_queue_MP_Send_request_packet
84 *
85 */
86
87rtems_status_code _Message_queue_MP_Send_request_packet (
88  Message_queue_MP_Remote_operations  operation,
89  Objects_Id                          message_queue_id,
90  void                               *buffer,
91  unsigned32                         *size_p,
92  rtems_option                        option_set,
93  rtems_interval                      timeout
94)
95{
96  Message_queue_MP_Packet *the_packet;
97
98  switch ( operation ) {
99
100    case MESSAGE_QUEUE_MP_SEND_REQUEST:
101    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
102    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
103    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
104
105      the_packet                    = _Message_queue_MP_Get_packet();
106      the_packet->Prefix.the_class  = MP_PACKET_MESSAGE_QUEUE;
107      the_packet->Prefix.length     = sizeof(Message_queue_MP_Packet);
108      if ( size_p )
109        the_packet->Prefix.length     += *size_p;
110      the_packet->Prefix.to_convert = sizeof(Message_queue_MP_Packet);
111
112      /*
113       * make sure message is not too big for our MPCI driver
114       * We have to check it here instead of waiting for MPCI because
115       * we are about to slam in the payload
116       */
117
118      if (the_packet->Prefix.length > _MPCI_table->maximum_packet_size) {
119          _Thread_Enable_dispatch();
120          return RTEMS_INVALID_SIZE;
121      }
122
123      if ( ! _Options_Is_no_wait(option_set))
124          the_packet->Prefix.timeout = timeout;
125
126      the_packet->operation  = operation;
127      the_packet->Prefix.id  = message_queue_id;
128      the_packet->option_set = option_set;
129
130      /*
131       * Copy the data into place if needed
132       */
133     
134      if (buffer) {
135          the_packet->Buffer.size = *size_p;
136          _Message_queue_Copy_buffer(buffer,
137                                     the_packet->Buffer.buffer,
138                                     *size_p);
139      }
140
141      return _MPCI_Send_request_packet(rtems_get_node(message_queue_id),
142                                       &the_packet->Prefix,
143                                       STATES_WAITING_FOR_MESSAGE);
144      break;
145
146    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
147
148      the_packet                    = _Message_queue_MP_Get_packet();
149      the_packet->Prefix.the_class  = MP_PACKET_MESSAGE_QUEUE;
150      the_packet->Prefix.length     = sizeof(Message_queue_MP_Packet);
151      the_packet->Prefix.to_convert = sizeof(Message_queue_MP_Packet);
152
153      if ( ! _Options_Is_no_wait(option_set))
154          the_packet->Prefix.timeout = timeout;
155
156      the_packet->operation  = MESSAGE_QUEUE_MP_RECEIVE_REQUEST;
157      the_packet->Prefix.id  = message_queue_id;
158      the_packet->option_set = option_set;
159      the_packet->size       = 0;        /* just in case of an error */
160
161      _Thread_Executing->Wait.return_argument   = (unsigned32 *)buffer;
162      _Thread_Executing->Wait.return_argument_1 = size_p;
163     
164      return _MPCI_Send_request_packet(rtems_get_node(message_queue_id),
165                                       &the_packet->Prefix,
166                                       STATES_WAITING_FOR_MESSAGE);
167      break;
168
169    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
170    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
171    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
172    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
173    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
174    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
175    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
176    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
177      break;
178  }
179
180  return RTEMS_SUCCESSFUL;
181}
182
183/*PAGE
184 *
185 *  _Message_queue_MP_Send_response_packet
186 *
187 */
188
189void _Message_queue_MP_Send_response_packet (
190  Message_queue_MP_Remote_operations  operation,
191  Objects_Id                          message_queue_id,
192  Thread_Control                     *the_thread
193)
194{
195  Message_queue_MP_Packet *the_packet;
196
197  switch ( operation ) {
198
199    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
200    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
201    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
202    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
203    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
204
205      the_packet = ( Message_queue_MP_Packet *) the_thread->receive_packet;
206
207/*
208 *  The packet being returned already contains the class, length, and
209 *  to_convert fields, therefore they are not set in this routine.
210 *
211 *  Exception: MESSAGE_QUEUE_MP_RECEIVE_RESPONSE needs payload length
212 *             added to 'length'
213 */
214      the_packet->operation = operation;
215      the_packet->Prefix.id = the_packet->Prefix.source_tid;
216
217      if (operation == MESSAGE_QUEUE_MP_RECEIVE_RESPONSE)
218          the_packet->Prefix.length += the_packet->size;
219     
220      _MPCI_Send_response_packet(
221        rtems_get_node( the_packet->Prefix.source_tid ),
222        &the_packet->Prefix
223      );
224      break;
225
226    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
227    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
228    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
229    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
230    case MESSAGE_QUEUE_MP_SEND_REQUEST:
231    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
232    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
233    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
234      break;
235
236  }
237}
238
239/*PAGE
240 *
241 *
242 *  _Message_queue_MP_Process_packet
243 *
244 */
245
246void _Message_queue_MP_Process_packet (
247  rtems_packet_prefix   *the_packet_prefix
248)
249{
250  Message_queue_MP_Packet *the_packet;
251  Thread_Control          *the_thread;
252  boolean                  ignored;
253
254  the_packet = (Message_queue_MP_Packet *) the_packet_prefix;
255
256  switch ( the_packet->operation ) {
257
258    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
259
260      ignored = _Objects_MP_Allocate_and_open(
261                  &_Message_queue_Information,
262                  the_packet->name,
263                  the_packet->Prefix.id,
264                  TRUE
265                );
266
267      _MPCI_Return_packet( the_packet_prefix );
268      break;
269
270    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
271
272      _Objects_MP_Close( &_Message_queue_Information, the_packet->Prefix.id );
273
274      _MPCI_Return_packet( the_packet_prefix );
275      break;
276
277    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
278
279      the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id );
280
281      if ( ! _Thread_Is_null( the_thread ) )
282         _Thread_queue_Extract( the_thread->Wait.queue, the_thread );
283
284      _MPCI_Return_packet( the_packet_prefix );
285      break;
286
287    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
288
289      the_packet->Prefix.return_code = rtems_message_queue_receive(
290        the_packet->Prefix.id,
291        the_packet->Buffer.buffer,
292        &the_packet->size,
293        the_packet->option_set,
294        the_packet->Prefix.timeout
295      );
296
297      if ( ! _Thread_Is_proxy_blocking( the_packet->Prefix.return_code ) )
298        _Message_queue_MP_Send_response_packet(
299          MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
300          the_packet->Prefix.id,
301          _Thread_Executing
302        );
303      break;
304
305    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
306
307      the_thread = _MPCI_Process_response( the_packet_prefix );
308
309      if (the_packet->Prefix.return_code == RTEMS_SUCCESSFUL) {
310        *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 =
311           the_packet->size;
312
313        _Message_queue_Copy_buffer(
314          the_packet->Buffer.buffer,
315          the_thread->Wait.return_argument,
316          the_packet->size
317        );
318      }
319
320      _MPCI_Return_packet( the_packet_prefix );
321      break;
322
323    case MESSAGE_QUEUE_MP_SEND_REQUEST:
324
325      the_packet->Prefix.return_code = rtems_message_queue_send(
326        the_packet->Prefix.id,
327        the_packet->Buffer.buffer,
328        the_packet->Buffer.size
329      );
330
331      _Message_queue_MP_Send_response_packet(
332        MESSAGE_QUEUE_MP_SEND_RESPONSE,
333        the_packet->Prefix.id,
334        _Thread_Executing
335      );
336      break;
337
338    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
339    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
340
341      the_thread = _MPCI_Process_response( the_packet_prefix );
342
343      _MPCI_Return_packet( the_packet_prefix );
344      break;
345
346    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
347
348      the_packet->Prefix.return_code = rtems_message_queue_urgent(
349        the_packet->Prefix.id,
350        the_packet->Buffer.buffer,
351        the_packet->Buffer.size
352      );
353
354      _Message_queue_MP_Send_response_packet(
355        MESSAGE_QUEUE_MP_URGENT_RESPONSE,
356        the_packet->Prefix.id,
357        _Thread_Executing
358      );
359      break;
360
361    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
362
363      the_packet->Prefix.return_code = rtems_message_queue_broadcast(
364        the_packet->Prefix.id,
365        the_packet->Buffer.buffer,
366        the_packet->Buffer.size,
367        &the_packet->count
368      );
369
370      _Message_queue_MP_Send_response_packet(
371        MESSAGE_QUEUE_MP_BROADCAST_RESPONSE,
372        the_packet->Prefix.id,
373        _Thread_Executing
374      );
375      break;
376
377    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
378    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
379
380      the_thread = _MPCI_Process_response( the_packet_prefix );
381
382      *(unsigned32 *)the_thread->Wait.return_argument = the_packet->count;
383
384      _MPCI_Return_packet( the_packet_prefix );
385      break;
386
387    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
388
389      the_packet->Prefix.return_code = rtems_message_queue_flush(
390        the_packet->Prefix.id,
391        &the_packet->count
392      );
393
394      _Message_queue_MP_Send_response_packet(
395        MESSAGE_QUEUE_MP_FLUSH_RESPONSE,
396        the_packet->Prefix.id,
397        _Thread_Executing
398      );
399      break;
400
401  }
402}
403
404/*PAGE
405 *
406 *  _Message_queue_MP_Send_object_was_deleted
407 *
408 */
409
410void _Message_queue_MP_Send_object_was_deleted (
411  Thread_Control  *the_proxy
412)
413{
414  the_proxy->receive_packet->return_code = RTEMS_OBJECT_WAS_DELETED;
415
416  _Message_queue_MP_Send_response_packet(
417    MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
418    the_proxy->Wait.id,
419    the_proxy
420  );
421}
422
423/*PAGE
424 *
425 *  _Message_queue_MP_Send_extract_proxy
426 *
427 */
428
429void _Message_queue_MP_Send_extract_proxy (
430  Thread_Control  *the_thread
431)
432{
433  _Message_queue_MP_Send_process_packet(
434    MESSAGE_QUEUE_MP_EXTRACT_PROXY,
435    the_thread->Wait.id,
436    (rtems_name) 0,
437    the_thread->Object.id
438  );
439}
440
441/*PAGE
442 *
443 *  _Message_queue_MP_Get_packet
444 *
445 */
446
447Message_queue_MP_Packet *_Message_queue_MP_Get_packet ( void )
448{
449  return ( (Message_queue_MP_Packet *) _MPCI_Get_packet() );
450}
451
452/* end of file */
Note: See TracBrowser for help on using the repository browser.