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

4.104.114.84.95
Last change on this file since ee4ddd83 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • 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.OARcorp.com/rtems/license.html.
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
55rtems_status_code _Message_queue_Submit(
56  Objects_Id                  id,
57  void                       *buffer,
58  unsigned32                  size,
59  Message_queue_Submit_types  submit_type
60)
61{
62  register Message_queue_Control  *the_message_queue;
63  Objects_Locations                location;
64  CORE_message_queue_Status        core_status;
65
66  the_message_queue = _Message_queue_Get( id, &location );
67  switch ( location )
68  {
69    case OBJECTS_REMOTE:
70#if defined(RTEMS_MULTIPROCESSING)
71      switch ( submit_type ) {
72        case MESSAGE_QUEUE_SEND_REQUEST:
73          return _Message_queue_MP_Send_request_packet(
74              MESSAGE_QUEUE_MP_SEND_REQUEST,
75              id,
76              buffer,
77              &size,
78              0,                               /* option_set */
79              MPCI_DEFAULT_TIMEOUT
80            );
81
82        case MESSAGE_QUEUE_URGENT_REQUEST:
83          return _Message_queue_MP_Send_request_packet(
84              MESSAGE_QUEUE_MP_URGENT_REQUEST,
85              id,
86              buffer,
87              &size,
88              0,                               /* option_set */
89              MPCI_DEFAULT_TIMEOUT
90            );
91      }
92      break;
93#endif
94
95    case OBJECTS_ERROR:
96      return RTEMS_INVALID_ID;
97
98    case OBJECTS_LOCAL:
99      switch ( submit_type ) {
100        case MESSAGE_QUEUE_SEND_REQUEST:
101          core_status = _CORE_message_queue_Send(
102                          &the_message_queue->message_queue,
103                          buffer,
104                          size,
105                          id,
106#if defined(RTEMS_MULTIPROCESSING)
107                          _Message_queue_Core_message_queue_mp_support
108#else
109                          NULL
110#endif
111                        );
112          break;
113        case MESSAGE_QUEUE_URGENT_REQUEST:
114          core_status = _CORE_message_queue_Urgent(
115                          &the_message_queue->message_queue,
116                          buffer,
117                          size,
118                          id,
119#if defined(RTEMS_MULTIPROCESSING)
120                          _Message_queue_Core_message_queue_mp_support
121#else
122                          NULL
123#endif
124                        );
125          break;
126        default:
127          core_status = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
128          return RTEMS_INTERNAL_ERROR;   /* should never get here */
129      }
130
131      _Thread_Enable_dispatch();
132      return _Message_queue_Translate_core_message_queue_return_code(
133                core_status );
134         
135  }
136  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
137}
Note: See TracBrowser for help on using the repository browser.