source: rtems/cpukit/rtems/src/msgqsubmit.c @ 8645c01c

Last change on this file since 8645c01c was 8645c01c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/06/07 at 08:58:42

Use size_t for sizes.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 *  Message Queue 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/score/sysstate.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/coremsg.h>
24#include <rtems/score/object.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#if defined(RTEMS_MULTIPROCESSING)
29#include <rtems/score/mpci.h>
30#endif
31#include <rtems/rtems/status.h>
32#include <rtems/rtems/attr.h>
33#include <rtems/rtems/message.h>
34#include <rtems/rtems/options.h>
35#include <rtems/rtems/support.h>
36
37/*PAGE
38 *
39 *  _Message_queue_Submit
40 *
41 *  This routine implements the directives rtems_message_queue_send
42 *  and rtems_message_queue_urgent.  It processes a message that is
43 *  to be submitted to the designated message queue.  The message will
44 *  either be processed as a send send message which it will be inserted
45 *  at the rear of the queue or it will be processed as an urgent message
46 *  which will be inserted at the front of the queue.
47 *
48 *  Input parameters:
49 *    id          - pointer to message queue
50 *    buffer      - pointer to message buffer
51 *    size        - size in bytes of message to send
52 *    submit_type - send or urgent message
53 *
54 *  Output parameters:
55 *    RTEMS_SUCCESSFUL - if successful
56 *    error code       - if unsuccessful
57 */
58
59#if defined(RTEMS_MULTIPROCESSING)
60#define MESSAGE_QUEUE_MP_HANDLER _Message_queue_Core_message_queue_mp_support
61#else
62#define MESSAGE_QUEUE_MP_HANDLER NULL
63#endif
64
65rtems_status_code _Message_queue_Submit(
66  Objects_Id                  id,
67  void                       *buffer,
68  size_t                      size,
69  Message_queue_Submit_types  submit_type
70)
71{
72  register Message_queue_Control  *the_message_queue;
73  Objects_Locations                location;
74  CORE_message_queue_Status        msg_status;
75
76  if ( !buffer )
77    return RTEMS_INVALID_ADDRESS;
78
79  the_message_queue = _Message_queue_Get( id, &location );
80  switch ( location )
81  {
82    case OBJECTS_REMOTE:
83#if defined(RTEMS_MULTIPROCESSING)
84      switch ( submit_type ) {
85        case MESSAGE_QUEUE_SEND_REQUEST:
86          return _Message_queue_MP_Send_request_packet(
87              MESSAGE_QUEUE_MP_SEND_REQUEST,
88              id,
89              buffer,
90              &size,
91              0,                               /* option_set */
92              MPCI_DEFAULT_TIMEOUT
93            );
94
95        case MESSAGE_QUEUE_URGENT_REQUEST:
96          return _Message_queue_MP_Send_request_packet(
97              MESSAGE_QUEUE_MP_URGENT_REQUEST,
98              id,
99              buffer,
100              &size,
101              0,                               /* option_set */
102              MPCI_DEFAULT_TIMEOUT
103            );
104      }
105      break;
106#endif
107
108    case OBJECTS_ERROR:
109      return RTEMS_INVALID_ID;
110
111    case OBJECTS_LOCAL:
112      switch ( submit_type ) {
113        case MESSAGE_QUEUE_SEND_REQUEST:
114          msg_status = _CORE_message_queue_Send(
115            &the_message_queue->message_queue,
116            buffer,
117            size,
118            id,
119            MESSAGE_QUEUE_MP_HANDLER,
120            FALSE,   /* sender does not block */
121            0        /* no timeout */
122          );
123          break;
124        case MESSAGE_QUEUE_URGENT_REQUEST:
125          msg_status = _CORE_message_queue_Urgent(
126            &the_message_queue->message_queue,
127            buffer,
128            size,
129            id,
130            MESSAGE_QUEUE_MP_HANDLER,
131            FALSE,   /* sender does not block */
132            0        /* no timeout */
133          );
134          break;
135        default:
136          return RTEMS_INTERNAL_ERROR;   /* should never get here */
137      }
138
139      _Thread_Enable_dispatch();
140
141      /*
142       *  Since this API does not allow for blocking sends, we can directly
143       *  return the returned msg_status.
144       */
145
146      return
147        _Message_queue_Translate_core_message_queue_return_code( msg_status );
148
149  }
150  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
151}
Note: See TracBrowser for help on using the repository browser.