source: rtems/c/src/exec/rtems/include/rtems/rtems/message.h @ 3235ad9

4.104.114.84.95
Last change on this file since 3235ad9 was 3235ad9, checked in by Joel Sherrill <joel.sherrill@…>, on 08/23/95 at 19:30:23

Support for variable length names added to Object Handler. This supports
both fixed length "raw" names and strings from the API's point of view.

Both inline and macro implementations were tested.

  • Property mode set to 100644
File size: 12.5 KB
Line 
1/*  message.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Message Queue Manager.  This manager provides a mechanism for
5 *  communication and synchronization between tasks using messages.
6 *
7 *  Directives provided are:
8 *
9 *     + create a queue
10 *     + get ID of a queue
11 *     + delete a queue
12 *     + put a message at the rear of a queue
13 *     + put a message at the front of a queue
14 *     + broadcast N messages to a queue
15 *     + receive message from a queue
16 *     + flush all messages on a queue
17 *
18 *
19 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
20 *  On-Line Applications Research Corporation (OAR).
21 *  All rights assigned to U.S. Government, 1994.
22 *
23 *  This material may be reproduced by or for the U.S. Government pursuant
24 *  to the copyright license under the clause at DFARS 252.227-7013.  This
25 *  notice must appear in all copies of this file and its derivatives.
26 *
27 *  $Id$
28 */
29
30#ifndef __RTEMS_MESSAGE_QUEUE_h
31#define __RTEMS_MESSAGE_QUEUE_h
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include <rtems/types.h>
38#include <rtems/chain.h>
39#include <rtems/object.h>
40#include <rtems/threadq.h>
41
42/*
43 *  The following defines the data types needed to manipulate
44 *  the contents of message buffers.
45 *  Since msgs are variable length we just make a ptr to 1.
46 */
47
48typedef struct {
49    unsigned32  size;
50
51#ifndef __cplusplus
52                               /* NOTE:   [0] is gcc specific,
53                                *   but specifically disallowed by ANSI STD C++
54                                * g++ warns about it, so we #ifdef it out to
55                                * get rid of warnings when compiled by g++.
56                                */
57    unsigned32  buffer[0];
58#endif
59
60} Message_queue_Buffer;
61
62/*
63 *  The following records define the organization of a message
64 *  buffer.
65 */
66
67typedef struct {
68  Chain_Node           Node;
69  Message_queue_Buffer Contents;
70}   Message_queue_Buffer_control;
71
72/*
73 *  The following records define the control block used to manage
74 *  each message queue.
75 */
76
77typedef struct {
78  Objects_Control      Object;
79  Thread_queue_Control Wait_queue;
80  rtems_attribute      attribute_set;
81  unsigned32           maximum_pending_messages;
82  unsigned32           number_of_pending_messages;
83  unsigned32           maximum_message_size;
84  Chain_Control        Pending_messages;
85  Message_queue_Buffer *message_buffers;
86  Chain_Control        Inactive_messages;
87}   Message_queue_Control;
88
89/*
90 *  The following defines the information control block used to
91 *  manage this class of objects.
92 */
93
94EXTERN Objects_Information  _Message_queue_Information;
95
96/*
97 *  The following enumerated type details the modes in which a message
98 *  may be submitted to a message queue.  The message may be posted
99 *  in a send or urgent fashion.
100 */
101
102typedef enum {
103  MESSAGE_QUEUE_SEND_REQUEST   = 0,
104  MESSAGE_QUEUE_URGENT_REQUEST = 1
105}  Message_queue_Submit_types;
106
107/*
108 *  _Message_queue_Manager_initialization
109 *
110 *  DESCRIPTION:
111 *
112 *  This routine performs the initialization necessary for this manager.
113 */
114
115void _Message_queue_Manager_initialization(
116  unsigned32 maximum_message_queues
117);
118
119/*
120 *  rtems_message_queue_create
121 *
122 *  DESCRIPTION:
123 *
124 *  This routine implements the rtems_message_queue_create directive.  The
125 *  message queue will have the name name.  If the attribute_set indicates
126 *  that the message queue is to be limited in the number of messages
127 *  that can be outstanding, then count indicates the maximum number of
128 *  messages that will be held.  It returns the id of the created
129 *  message queue in ID.
130 */
131
132rtems_status_code rtems_message_queue_create(
133  rtems_name       name,
134  unsigned32       count,
135  unsigned32       max_message_size,
136  rtems_attribute  attribute_set,
137  Objects_Id      *id
138);
139
140/*
141 *  rtems_message_queue_ident
142 *
143 *  DESCRIPTION:
144 *
145 *  This routine implements the rtems_message_queue_ident directive.
146 *  This directive returns the message queue ID associated with NAME.
147 *  If more than one message queue is named name, then the message
148 *  queue to which the ID belongs is arbitrary.  node indicates the
149 *  extent of the search for the ID of the message queue named name.
150 *  The search can be limited to a particular node or allowed to
151 *  encompass all nodes.
152 */
153
154rtems_status_code rtems_message_queue_ident(
155  rtems_name    name,
156  unsigned32    node,
157  Objects_Id   *id
158);
159
160/*
161 *  rtems_message_queue_delete
162 *
163 *  DESCRIPTION:
164 *
165 *  This routine implements the rtems_message_queue_delete directive.  The
166 *  message queue indicated by ID is deleted.
167 */
168
169rtems_status_code rtems_message_queue_delete(
170  Objects_Id id
171);
172
173/*
174 *  rtems_message_queue_send
175 *
176 *  DESCRIPTION:
177 *
178 *  This routine implements the rtems_message_queue_send directive.
179 *  This directive sends the message buffer to the message queue
180 *  indicated by ID.  If one or more tasks is blocked waiting
181 *  to receive a message from this message queue, then one will
182 *  receive the message.  The task selected to receive the
183 *  message is based on the task queue discipline algorithm in
184 *  use by this particular message queue.  If no tasks are waiting,
185 *  then the message buffer will be placed at the rear of the
186 *  chain of pending messages for this message queue.
187 */
188
189rtems_status_code rtems_message_queue_send(
190  Objects_Id            id,
191  void                 *buffer,
192  unsigned32            size
193);
194
195/*
196 *  rtems_message_queue_urgent
197 *
198 *  DESCRIPTION:
199 *
200 *  This routine implements the rtems_message_queue_send directive.
201 *  This directive sends the message buffer to the message queue
202 *  indicated by ID.  If one or more tasks is blocked waiting
203 *  to receive a message from this message queue, then one will
204 *  receive the message.  The task selected to receive the
205 *  message is based on the task queue discipline algorithm in
206 *  use by this particular message queue.  If no tasks are waiting,
207 *  then the message buffer will be placed at the rear of the
208 *  chain of pending messages for this message queue.
209 */
210
211rtems_status_code rtems_message_queue_urgent(
212  Objects_Id            id,
213  void                 *buffer,
214  unsigned32            size
215);
216
217/*
218 *  rtems_message_queue_broadcast
219 *
220 *  DESCRIPTION:
221 *
222 *  This routine implements the rtems_message_queue_send directive.
223 *  This directive sends the message buffer to the message queue
224 *  indicated by ID.  If one or more tasks is blocked waiting
225 *  to receive a message from this message queue, then one will
226 *  receive the message.  The task selected to receive the
227 *  message is based on the task queue discipline algorithm in
228 *  use by this particular message queue.  If no tasks are waiting,
229 *  then the message buffer will be placed at the rear of the
230 *  chain of pending messages for this message queue.
231 */
232
233rtems_status_code rtems_message_queue_broadcast(
234  Objects_Id            id,
235  void                 *buffer,
236  unsigned32            size,
237  unsigned32           *count
238);
239
240/*
241 *  rtems_message_queue_receive
242 *
243 *  DESCRIPTION:
244 *
245 *  This routine implements the rtems_message_queue_receive directive.
246 *  This directive is invoked when the calling task wishes to receive
247 *  a message from the message queue indicated by ID.  The received
248 *  message is to be placed in buffer.  If no messages are outstanding
249 *  and the option_set indicates that the task is willing to block,
250 *  then the task will be blocked until a message arrives or until,
251 *  optionally, timeout clock ticks have passed.
252 */
253
254rtems_status_code rtems_message_queue_receive(
255  Objects_Id            id,
256  void                 *buffer,
257  unsigned32           *size_p,
258  unsigned32            option_set,
259  rtems_interval        timeout
260);
261
262/*
263 *  rtems_message_queue_flush
264 *
265 *  DESCRIPTION:
266 *
267 *  This routine implements the rtems_message_queue_flush directive.
268 *  This directive takes all outstanding messages for the message
269 *  queue indicated by ID and returns them to the inactive message
270 *  chain.  The number of messages flushed is returned in COUNT.
271 */
272
273rtems_status_code rtems_message_queue_flush(
274  Objects_Id  id,
275  unsigned32 *count
276);
277
278/*
279 *  _Message_queue_Copy_buffer
280 *
281 *  DESCRIPTION:
282 *
283 *  This routine copies the contents of the source message buffer
284 *  to the destination message buffer.
285 */
286
287STATIC INLINE void _Message_queue_Copy_buffer (
288  void      *source,
289  void      *destination,
290  unsigned32 size
291);
292
293/*
294 *  _Message_queue_Seize
295 *
296 *  DESCRIPTION:
297 *
298 *  This routine attempts to receive a message from the_message_queue.
299 *  If a message is available or if the RTEMS_NO_WAIT option is enabled in
300 *  option_set, then the routine returns.  Otherwise, the calling task
301 *  is blocked until a message is available.  If a message is returned
302 *  to the task, then buffer will contain its contents.
303 */
304
305boolean _Message_queue_Seize(
306  Message_queue_Control *the_message_queue,
307  unsigned32             option_set,
308  void                  *buffer,
309  unsigned32            *size_p
310);
311
312/*
313 *  _Message_queue_Flush_support
314 *
315 *  DESCRIPTION:
316 *
317 *  This routine flushes all outstanding messages and returns
318 *  them to the inactive message chain.
319 */
320
321unsigned32 _Message_queue_Flush_support(
322  Message_queue_Control *the_message_queue
323);
324
325/*
326 *  _Message_queue_Submit
327 *
328 *  DESCRIPTION:
329 *
330 *  This routine provides the common foundation for the
331 *  rtems_message_queue_send and rtems_message_queue_urgent directives.
332 */
333
334rtems_status_code _Message_queue_Submit(
335  Objects_Id                  id,
336  void                       *buffer,
337  unsigned32                  size,
338  Message_queue_Submit_types  submit_type
339);
340
341/*
342 *  _Message_queue_Allocate_message_buffer
343 *
344 *  DESCRIPTION:
345 *
346 *  This function allocates a message buffer from the inactive
347 *  message buffer chain.
348 */
349
350STATIC INLINE Message_queue_Buffer_control *
351  _Message_queue_Allocate_message_buffer (
352   Message_queue_Control *the_message_queue
353);
354
355/*
356 *  _Message_queue_Free_message_buffer
357 *
358 *  DESCRIPTION:
359 *
360 *  This routine frees a message buffer to the inactive
361 *  message buffer chain.
362 */
363
364STATIC INLINE void _Message_queue_Free_message_buffer (
365  Message_queue_Control        *the_message_queue,
366  Message_queue_Buffer_control *the_message
367);
368
369/*
370 *  _Message_queue_Get_pending_message
371 *
372 *  DESCRIPTION:
373 *
374 *  This function removes the first message from the_message_queue
375 *  and returns a pointer to it.
376 */
377
378STATIC INLINE
379  Message_queue_Buffer_control *_Message_queue_Get_pending_message (
380  Message_queue_Control *the_message_queue
381);
382
383/*
384 *  _Message_queue_Append
385 *
386 *  DESCRIPTION:
387 *
388 *  This routine places the_message at the rear of the outstanding
389 *  messages on the_message_queue.
390 */
391
392STATIC INLINE void _Message_queue_Append (
393  Message_queue_Control        *the_message_queue,
394  Message_queue_Buffer_control *the_message
395);
396
397/*
398 *  _Message_queue_Prepend
399 *
400 *  DESCRIPTION:
401 *
402 *  This routine places the_message at the rear of the outstanding
403 *  messages on the_message_queue.
404 */
405
406STATIC INLINE void _Message_queue_Prepend (
407  Message_queue_Control        *the_message_queue,
408  Message_queue_Buffer_control *the_message
409);
410
411/*
412 *  _Message_queue_Is_null
413 *
414 *  DESCRIPTION:
415 *
416 *  This function places the_message at the rear of the outstanding
417 *  messages on the_message_queue.
418 */
419
420STATIC INLINE boolean _Message_queue_Is_null (
421  Message_queue_Control *the_message_queue
422);
423
424/*
425 *  _Message_queue_Allocate
426 *
427 *  DESCRIPTION:
428 *
429 *  This function allocates a message queue control block from
430 *  the inactive chain of free message queue control blocks.
431 */
432
433Message_queue_Control *_Message_queue_Allocate (
434    unsigned32          count,
435    unsigned32          max_message_size
436);
437
438/*
439 *  _Message_queue_Free
440 *
441 *  DESCRIPTION:
442 *
443 *  This routine deallocates a message queue control block into
444 *  the inactive chain of free message queue control blocks.
445 */
446
447STATIC INLINE void _Message_queue_Free (
448  Message_queue_Control *the_message_queue
449);
450
451/*
452 *  _Message_queue_Get
453 *
454 *  DESCRIPTION:
455 *
456 *  This function maps message queue IDs to message queue control
457 *  blocks.  If ID corresponds to a local message queue, then it
458 *  returns the_message_queue control pointer which maps to ID
459 *  and location is set to OBJECTS_LOCAL.  If the message queue ID is
460 *  global and resides on a remote node, then location is set
461 *  to OBJECTS_REMOTE, and the_message_queue is undefined.
462 *  Otherwise, location is set to OBJECTS_ERROR and
463 *  the_message_queue is undefined.
464 */
465
466STATIC INLINE Message_queue_Control *_Message_queue_Get (
467  Objects_Id         id,
468  Objects_Locations *location
469);
470
471#include <rtems/message.inl>
472#include <rtems/msgmp.h>
473
474#ifdef __cplusplus
475}
476#endif
477
478#endif
479/* end of include file */
Note: See TracBrowser for help on using the repository browser.