source: rtems/cpukit/rtems/src/msgqsubmit.c @ e980b219

4.104.114.84.95
Last change on this file since e980b219 was e980b219, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:21:40

2004-05-06 Joel Sherrill <joel@…>

PR 618/rtems

  • rtems/include/rtems/rtems/status.h, rtems/src/clockget.c, rtems/src/clockset.c, rtems/src/dpmemcreate.c, rtems/src/dpmemexternal2internal.c, rtems/src/dpmeminternal2external.c, rtems/src/eventmp.c, rtems/src/eventreceive.c, rtems/src/eventsend.c, rtems/src/msgqbroadcast.c, rtems/src/msgqcreate.c, rtems/src/msgqflush.c, rtems/src/msgqgetnumberpending.c, rtems/src/msgqreceive.c, rtems/src/msgqsubmit.c, rtems/src/partcreate.c, rtems/src/partdelete.c, rtems/src/partgetbuffer.c, rtems/src/ratemoncancel.c, rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c, rtems/src/ratemonperiod.c, rtems/src/regioncreate.c, rtems/src/regiondelete.c, rtems/src/regionextend.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionreturnsegment.c, rtems/src/semcreate.c, rtems/src/semdelete.c, rtems/src/semflush.c, rtems/src/semident.c, rtems/src/taskcreate.c, rtems/src/taskgetnote.c, rtems/src/taskmode.c, rtems/src/taskrestart.c, rtems/src/taskresume.c, rtems/src/tasksetnote.c, rtems/src/tasksuspend.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c, rtems/src/taskvariableget.c, rtems/src/taskwakewhen.c, rtems/src/timercreate.c, rtems/src/timerdelete.c, rtems/src/timerfireafter.c, rtems/src/timerfirewhen.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c, score/include/rtems/score/object.h, score/src/coretodvalidate.c, score/src/objectnametoid.c: Add NULL checks.
  • Property mode set to 100644
File size: 4.1 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#include <rtems/system.h>
16#include <rtems/score/sysstate.h>
17#include <rtems/score/chain.h>
18#include <rtems/score/isr.h>
19#include <rtems/score/coremsg.h>
20#include <rtems/score/object.h>
21#include <rtems/score/states.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#if defined(RTEMS_MULTIPROCESSING)
25#include <rtems/score/mpci.h>
26#endif
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attr.h>
29#include <rtems/rtems/message.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33/*PAGE
34 *
35 *  _Message_queue_Submit
36 *
37 *  This routine implements the directives rtems_message_queue_send
38 *  and rtems_message_queue_urgent.  It processes a message that is
39 *  to be submitted to the designated message queue.  The message will
40 *  either be processed as a send send message which it will be inserted
41 *  at the rear of the queue or it will be processed as an urgent message
42 *  which will be inserted at the front of the queue.
43 *
44 *  Input parameters:
45 *    id          - pointer to message queue
46 *    buffer      - pointer to message buffer
47 *    size        - size in bytes of message to send
48 *    submit_type - send or urgent message
49 *
50 *  Output parameters:
51 *    RTEMS_SUCCESSFUL - if successful
52 *    error code       - if unsuccessful
53 */
54
55#if defined(RTEMS_MULTIPROCESSING)
56#define MESSAGE_QUEUE_MP_HANDLER _Message_queue_Core_message_queue_mp_support
57#else
58#define MESSAGE_QUEUE_MP_HANDLER NULL
59#endif
60
61rtems_status_code _Message_queue_Submit(
62  Objects_Id                  id,
63  void                       *buffer,
64  uint32_t                    size,
65  Message_queue_Submit_types  submit_type
66)
67{
68  register Message_queue_Control  *the_message_queue;
69  Objects_Locations                location;
70  CORE_message_queue_Status        msg_status;
71
72  if ( !buffer )
73    return RTEMS_INVALID_ADDRESS;
74
75  the_message_queue = _Message_queue_Get( id, &location );
76  switch ( location )
77  {
78    case OBJECTS_REMOTE:
79#if defined(RTEMS_MULTIPROCESSING)
80      switch ( submit_type ) {
81        case MESSAGE_QUEUE_SEND_REQUEST:
82          return _Message_queue_MP_Send_request_packet(
83              MESSAGE_QUEUE_MP_SEND_REQUEST,
84              id,
85              buffer,
86              &size,
87              0,                               /* option_set */
88              MPCI_DEFAULT_TIMEOUT
89            );
90
91        case MESSAGE_QUEUE_URGENT_REQUEST:
92          return _Message_queue_MP_Send_request_packet(
93              MESSAGE_QUEUE_MP_URGENT_REQUEST,
94              id,
95              buffer,
96              &size,
97              0,                               /* option_set */
98              MPCI_DEFAULT_TIMEOUT
99            );
100      }
101      break;
102#endif
103
104    case OBJECTS_ERROR:
105      return RTEMS_INVALID_ID;
106
107    case OBJECTS_LOCAL:
108      switch ( submit_type ) {
109        case MESSAGE_QUEUE_SEND_REQUEST:
110          msg_status = _CORE_message_queue_Send(
111            &the_message_queue->message_queue,
112            buffer,
113            size,
114            id,
115            MESSAGE_QUEUE_MP_HANDLER,
116            FALSE,   /* sender does not block */
117            0        /* no timeout */
118          );
119          break;
120        case MESSAGE_QUEUE_URGENT_REQUEST:
121          msg_status = _CORE_message_queue_Urgent(
122            &the_message_queue->message_queue,
123            buffer,
124            size,
125            id,
126            MESSAGE_QUEUE_MP_HANDLER,
127            FALSE,   /* sender does not block */
128            0        /* no timeout */
129          );
130          break;
131        default:
132          return RTEMS_INTERNAL_ERROR;   /* should never get here */
133      }
134
135      _Thread_Enable_dispatch();
136
137      /*
138       *  Since this API does not allow for blocking sends, we can directly
139       *  return the returned msg_status.
140       */
141
142      return
143        _Message_queue_Translate_core_message_queue_return_code( msg_status );
144
145  }
146  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
147}
Note: See TracBrowser for help on using the repository browser.