source: rtems/cpukit/rtems/include/rtems/rtems/message.h @ 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: 8.6 KB
Line 
1/**
2 * @file rtems/rtems/message.h
3 */
4
5/*
6 *  This include file contains all the constants and structures associated
7 *  with the Message Queue Manager.  This manager provides a mechanism for
8 *  communication and synchronization between tasks using messages.
9 *
10 *  Directives provided are:
11 *
12 *     + create a queue
13 *     + get ID of a queue
14 *     + delete a queue
15 *     + put a message at the rear of a queue
16 *     + put a message at the front of a queue
17 *     + broadcast N messages to a queue
18 *     + receive message from a queue
19 *     + flush all messages on a queue
20 *
21 *
22 *  COPYRIGHT (c) 1989-1999.
23 *  On-Line Applications Research Corporation (OAR).
24 *
25 *  The license and distribution terms for this file may be
26 *  found in the file LICENSE in this distribution or at
27 *  http://www.rtems.com/license/LICENSE.
28 *
29 *  $Id$
30 */
31
32#ifndef _RTEMS_RTEMS_MESSAGE_H
33#define _RTEMS_RTEMS_MESSAGE_H
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include <rtems/rtems/types.h>
40#include <rtems/score/chain.h>
41#include <rtems/score/object.h>
42#include <rtems/rtems/attr.h>
43#include <rtems/score/coremsg.h>
44
45/*
46 *  The following enumerated type details the modes in which a message
47 *  may be submitted to a message queue.  The message may be posted
48 *  in a send or urgent fashion.
49 */
50
51typedef enum {
52  MESSAGE_QUEUE_SEND_REQUEST   = 0,
53  MESSAGE_QUEUE_URGENT_REQUEST = 1
54}  Message_queue_Submit_types;
55
56/*
57 *  The following records define the control block used to manage
58 *  each message queue.
59 */
60
61typedef struct {
62  Objects_Control             Object;
63  rtems_attribute             attribute_set;
64  CORE_message_queue_Control  message_queue;
65}   Message_queue_Control;
66
67/*
68 *  The following defines the information control block used to
69 *  manage this class of objects.
70 */
71
72RTEMS_EXTERN Objects_Information  _Message_queue_Information;
73
74/*
75 *  _Message_queue_Manager_initialization
76 *
77 *  DESCRIPTION:
78 *
79 *  This routine performs the initialization necessary for this manager.
80 */
81
82void _Message_queue_Manager_initialization(
83  uint32_t   maximum_message_queues
84);
85
86/*
87 *  rtems_message_queue_create
88 *
89 *  DESCRIPTION:
90 *
91 *  This routine implements the rtems_message_queue_create directive.  The
92 *  message queue will have the name name.  If the attribute_set indicates
93 *  that the message queue is to be limited in the number of messages
94 *  that can be outstanding, then count indicates the maximum number of
95 *  messages that will be held.  It returns the id of the created
96 *  message queue in ID.
97 */
98
99rtems_status_code rtems_message_queue_create(
100  rtems_name       name,
101  uint32_t         count,
102  uint32_t         max_message_size,
103  rtems_attribute  attribute_set,
104  Objects_Id      *id
105);
106
107/*
108 *  rtems_message_queue_ident
109 *
110 *  DESCRIPTION:
111 *
112 *  This routine implements the rtems_message_queue_ident directive.
113 *  This directive returns the message queue ID associated with NAME.
114 *  If more than one message queue is named name, then the message
115 *  queue to which the ID belongs is arbitrary.  node indicates the
116 *  extent of the search for the ID of the message queue named name.
117 *  The search can be limited to a particular node or allowed to
118 *  encompass all nodes.
119 */
120
121rtems_status_code rtems_message_queue_ident(
122  rtems_name    name,
123  uint32_t      node,
124  Objects_Id   *id
125);
126
127/*
128 *  rtems_message_queue_delete
129 *
130 *  DESCRIPTION:
131 *
132 *  This routine implements the rtems_message_queue_delete directive.  The
133 *  message queue indicated by ID is deleted.
134 */
135
136rtems_status_code rtems_message_queue_delete(
137  Objects_Id id
138);
139
140/*
141 *  rtems_message_queue_send
142 *
143 *  DESCRIPTION:
144 *
145 *  This routine implements the rtems_message_queue_send directive.
146 *  This directive sends the message buffer to the message queue
147 *  indicated by ID.  If one or more tasks is blocked waiting
148 *  to receive a message from this message queue, then one will
149 *  receive the message.  The task selected to receive the
150 *  message is based on the task queue discipline algorithm in
151 *  use by this particular message queue.  If no tasks are waiting,
152 *  then the message buffer will be placed at the REAR of the
153 *  chain of pending messages for this message queue.
154 */
155
156rtems_status_code rtems_message_queue_send(
157  Objects_Id            id,
158  void                 *buffer,
159  uint32_t              size
160);
161
162/*
163 *  rtems_message_queue_urgent
164 *
165 *  DESCRIPTION:
166 *
167 *  This routine implements the rtems_message_queue_urgent directive.
168 *  This directive has the same behavior as rtems_message_queue_send
169 *  except that if no tasks are waiting, the message buffer will
170 *  be placed at the FRONT of the chain of pending messages rather
171 *  than at the REAR.
172 */
173
174rtems_status_code rtems_message_queue_urgent(
175  Objects_Id            id,
176  void                 *buffer,
177  uint32_t              size
178);
179
180/*
181 *  rtems_message_queue_broadcast
182 *
183 *  DESCRIPTION:
184 *
185 *  This routine implements the rtems_message_queue_broadcast directive.
186 *  This directive sends the message buffer to all of the tasks blocked
187 *  waiting for a message on the message queue indicated by ID.
188 *  If no tasks are waiting, then the message buffer will not be queued.
189 */
190
191rtems_status_code rtems_message_queue_broadcast(
192  Objects_Id            id,
193  void                 *buffer,
194  size_t                size,
195  uint32_t             *count
196);
197
198/*
199 *  rtems_message_queue_receive
200 *
201 *  DESCRIPTION:
202 *
203 *  This routine implements the rtems_message_queue_receive directive.
204 *  This directive is invoked when the calling task wishes to receive
205 *  a message from the message queue indicated by ID.  The received
206 *  message is to be placed in buffer.  If no messages are outstanding
207 *  and the option_set indicates that the task is willing to block,
208 *  then the task will be blocked until a message arrives or until,
209 *  optionally, timeout clock ticks have passed.
210 */
211
212rtems_status_code rtems_message_queue_receive(
213  Objects_Id            id,
214  void                 *buffer,
215  size_t               *size,
216  uint32_t              option_set,
217  rtems_interval        timeout
218);
219
220/*
221 *  rtems_message_queue_flush
222 *
223 *  DESCRIPTION:
224 *
225 *  This routine implements the rtems_message_queue_flush directive.
226 *  This directive takes all outstanding messages for the message
227 *  queue indicated by ID and returns them to the inactive message
228 *  chain.  The number of messages flushed is returned in COUNT.
229 */
230
231rtems_status_code rtems_message_queue_flush(
232  Objects_Id  id,
233  uint32_t   *count
234);
235
236/*
237 *  rtems_message_queue_get_number_pending
238 *
239 *  DESCRIPTION:
240 *
241 *  This routine implements the rtems_message_queue_get_number_pending
242 *  directive.  This directive returns the number of pending
243 *  messages for the message queue indicated by ID
244 *  chain.  The number of messages pending is returned in COUNT.
245 */
246
247rtems_status_code rtems_message_queue_get_number_pending(
248  Objects_Id  id,
249  uint32_t   *count
250);
251
252
253/*
254 *  _Message_queue_Submit
255 *
256 *  DESCRIPTION:
257 *
258 *  This routine implements the directives rtems_message_queue_send
259 *  and rtems_message_queue_urgent.  It processes a message that is
260 *  to be submitted to the designated message queue.  The message will
261 *  either be processed as a send send message which it will be inserted
262 *  at the rear of the queue or it will be processed as an urgent message
263 *  which will be inserted at the front of the queue.
264 */
265
266rtems_status_code _Message_queue_Submit(
267  Objects_Id                  id,
268  void                       *buffer,
269  size_t                      size,
270  Message_queue_Submit_types  submit_type
271);
272
273/*
274 *  _Message_queue_Allocate
275 *
276 *  DESCRIPTION:
277 *
278 *  This function allocates a message queue control block from
279 *  the inactive chain of free message queue control blocks.
280 */
281
282Message_queue_Control *_Message_queue_Allocate (
283    uint32_t            count,
284    uint32_t            max_message_size
285);
286
287/*
288 *  _Message_queue_Translate_core_message_queue_return_code
289 *
290 *  DESCRIPTION:
291 *
292 *  This function returns a RTEMS status code based on the core message queue
293 *  status code specified.
294 */
295
296rtems_status_code _Message_queue_Translate_core_message_queue_return_code (
297  uint32_t   the_message_queue_status
298);
299
300/*
301 *
302 *  _Message_queue_Core_message_queue_mp_support
303 *
304 *  Input parameters:
305 *    the_thread - the remote thread the message was submitted to
306 *    id         - id of the message queue
307 *
308 *  Output parameters: NONE
309 */
310
311#if defined(RTEMS_MULTIPROCESSING)
312void  _Message_queue_Core_message_queue_mp_support (
313  Thread_Control *the_thread,
314  Objects_Id      id
315);
316#endif
317
318#ifndef __RTEMS_APPLICATION__
319#include <rtems/rtems/message.inl>
320#endif
321#if defined(RTEMS_MULTIPROCESSING)
322#include <rtems/rtems/msgmp.h>
323#endif
324
325#ifdef __cplusplus
326}
327#endif
328
329#endif
330/* end of include file */
Note: See TracBrowser for help on using the repository browser.