source: rtems/cpukit/rtems/include/rtems/rtems/message.h @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

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