source: rtems/cpukit/rtems/src/msgqsubmit.c @ 17bbadd

Last change on this file since 17bbadd was 17bbadd, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:20:04

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

PR 618/rtems

  • include/rtems/rtems/status.h, src/clockget.c, src/clockset.c, src/dpmemcreate.c, src/dpmemexternal2internal.c, src/dpmeminternal2external.c, src/eventmp.c, src/eventreceive.c, src/eventsend.c, src/msgqbroadcast.c, src/msgqcreate.c, src/msgqflush.c, src/msgqgetnumberpending.c, src/msgqreceive.c, src/msgqsubmit.c, src/partcreate.c, src/partdelete.c, src/partgetbuffer.c, src/ratemoncancel.c, src/ratemoncreate.c, src/ratemondelete.c, src/ratemongetstatus.c, src/ratemonident.c, src/ratemonperiod.c, src/regioncreate.c, src/regiondelete.c, src/regionextend.c, src/regiongetsegment.c, src/regiongetsegmentsize.c, src/regionreturnsegment.c, src/semcreate.c, src/semdelete.c, src/semflush.c, src/semident.c, src/taskcreate.c, src/taskgetnote.c, src/taskmode.c, src/taskrestart.c, src/taskresume.c, src/tasksetnote.c, src/tasksuspend.c, src/taskvariableadd.c, src/taskvariabledelete.c, src/taskvariableget.c, src/taskwakewhen.c, src/timercreate.c, src/timerdelete.c, src/timerfireafter.c, src/timerfirewhen.c, src/timerserverfireafter.c, src/timerserverfirewhen.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  unsigned32                  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.