source: rtems/cpukit/score/include/rtems/score/coremsg.h @ 9693fdac

4.104.114.84.95
Last change on this file since 9693fdac was 9693fdac, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 15:57:58

Added support for message priority as required by POSIX.

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/*  coremsg.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Message queue Handler.
5 *
6 *  COPYRIGHT (c) 1989-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16 
17#ifndef __RTEMS_CORE_MESSAGE_QUEUE_h
18#define __RTEMS_CORE_MESSAGE_QUEUE_h
19 
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#include <rtems/score/priority.h>
27#include <rtems/score/watchdog.h>
28 
29/*
30 *  The following type defines the callout which the API provides
31 *  to support global/multiprocessor operations on message_queues.
32 */
33 
34typedef void ( *CORE_message_queue_API_mp_support_callout )(
35                 Thread_Control *,
36                 Objects_Id
37             );
38
39/*
40 *  The following defines the data types needed to manipulate
41 *  the contents of message buffers.
42 *
43 *  NOTE:  The buffer field is normally longer than a single unsigned32.
44 *         but since messages are variable length we just make a ptr to 1. 
45 */
46 
47typedef struct {
48    unsigned32  size;
49    unsigned32  buffer[1];
50} CORE_message_queue_Buffer;
51 
52/*
53 *  The following records define the organization of a message
54 *  buffer.
55 */
56 
57typedef struct {
58  Chain_Node                 Node;
59  int                        priority;
60  CORE_message_queue_Buffer  Contents;
61}   CORE_message_queue_Buffer_control;
62
63/*
64 *  Blocking disciplines for a message_queue.
65 */
66
67typedef enum {
68  CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
69  CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY
70}   CORE_message_queue_Disciplines;
71
72/*
73 *  The following enumerated type details the modes in which a message
74 *  may be submitted to a message queue.  The message may be posted
75 *  in a send or urgent fashion.
76 *
77 *  NOTE:  All other values are message priorities.  Numerically smaller
78 *         priorities indicate higher priority messages.
79 *
80 *  XXX these constants should be changed to be compiler dependent.
81 */
82 
83#define  CORE_MESSAGE_QUEUE_SEND_REQUEST   0x7fffffff
84#define  CORE_MESSAGE_QUEUE_URGENT_REQUEST -(0x7fffffff)
85
86typedef int CORE_message_queue_Submit_types;
87
88/*
89 *  Core Message queue handler return statuses.
90 */
91 
92typedef enum {
93  CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL,
94  CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE,
95  CORE_MESSAGE_QUEUE_STATUS_TOO_MANY,
96  CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED,
97  CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT,
98  CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED,
99  CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
100}   CORE_message_queue_Status;
101
102/*
103 *  The following defines the control block used to manage the
104 *  attributes of each message queue.
105 */
106
107typedef struct {
108  CORE_message_queue_Disciplines  discipline;
109}   CORE_message_queue_Attributes;
110 
111/*
112 *  The following defines the type for a Notification handler.  A notification
113 *  handler is invoked when the message queue makes a 0->1 transition on
114 *  pending messages.
115 */
116
117typedef void (*CORE_message_queue_Notify_Handler)( void * );
118
119/*
120 *  The following defines the control block used to manage each
121 *  counting message_queue.
122 */
123 
124typedef struct {
125  Thread_queue_Control               Wait_queue;
126  CORE_message_queue_Attributes      Attributes;
127  unsigned32                         maximum_pending_messages;
128  unsigned32                         number_of_pending_messages;
129  unsigned32                         maximum_message_size;
130  Chain_Control                      Pending_messages;
131  CORE_message_queue_Buffer         *message_buffers;
132  CORE_message_queue_Notify_Handler  notify_handler;
133  void                              *notify_argument;
134  Chain_Control                      Inactive_messages;
135}   CORE_message_queue_Control;
136
137/*
138 *  _CORE_message_queue_Initialize
139 *
140 *  DESCRIPTION:
141 *
142 *  This routine initializes the message_queue based on the parameters passed.
143 */
144
145boolean _CORE_message_queue_Initialize(
146  CORE_message_queue_Control    *the_message_queue,
147  Objects_Classes                the_class,
148  CORE_message_queue_Attributes *the_message_queue_attributes,
149  unsigned32                     maximum_pending_messages,
150  unsigned32                     maximum_message_size,
151  Thread_queue_Extract_callout   proxy_extract_callout
152);
153 
154/*
155 *  _CORE_message_queue_Close
156 *
157 *  DESCRIPTION:
158 *
159 *  This function closes a message by returning all allocated space and
160 *  flushing the message_queue's task wait queue.
161 */
162 
163void _CORE_message_queue_Close(
164  CORE_message_queue_Control *the_message_queue,
165  Thread_queue_Flush_callout  remote_extract_callout,
166  unsigned32                  status
167);
168
169/*
170 *
171 *  _CORE_message_queue_Flush
172 *
173 *  DESCRIPTION:
174 *
175 *  This function flushes the message_queue's task wait queue.  The number
176 *  messages flushed from the queue is returned.
177 *
178 */
179
180unsigned32 _CORE_message_queue_Flush(
181  CORE_message_queue_Control *the_message_queue
182);
183
184/*
185 *  _CORE_message_queue_Flush_support
186 *
187 *  DESCRIPTION:
188 *
189 *  This routine flushes all outstanding messages and returns
190 *  them to the inactive message chain.
191 */
192 
193unsigned32 _CORE_message_queue_Flush_support(
194  CORE_message_queue_Control *the_message_queue
195);
196 
197/*
198 *
199 *  _CORE_message_queue_Broadcast
200 *
201 *  DESCRIPTION:
202 *
203 *  This function sends a message for every thread waiting on the queue and
204 *  returns the number of threads made ready by the message.
205 *
206 */
207 
208CORE_message_queue_Status _CORE_message_queue_Broadcast(
209  CORE_message_queue_Control                *the_message_queue,
210  void                                      *buffer,
211  unsigned32                                 size,
212  Objects_Id                                 id,
213  CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
214  unsigned32                                *count
215);
216
217/*
218 *
219 *  _CORE_message_queue_Submit
220 *
221 *  DESCRIPTION:
222 *
223 *  This routine implements the send and urgent message functions. It
224 *  processes a message that is to be submitted to the designated
225 *  message queue.  The message will either be processed as a
226 *  send message which it will be inserted at the rear of the queue
227 *  or it will be processed as an urgent message which will be inserted
228 *  at the front of the queue.
229 *
230 */
231 
232CORE_message_queue_Status _CORE_message_queue_Submit(
233  CORE_message_queue_Control                *the_message_queue,
234  void                                      *buffer,
235  unsigned32                                 size,
236  Objects_Id                                 id,
237  CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
238  CORE_message_queue_Submit_types            submit_type
239);
240
241/*
242 *
243 *  _CORE_message_queue_Seize
244 *
245 *  DESCRIPTION:
246 *
247 *  This kernel routine dequeues a message, copies the message buffer to
248 *  a given destination buffer, and frees the message buffer to the
249 *  inactive message pool.  The thread will be blocked if wait is TRUE,
250 *  otherwise an error will be given to the thread if no messages are available.
251 *
252 */
253 
254void _CORE_message_queue_Seize(
255  CORE_message_queue_Control *the_message_queue,
256  Objects_Id                  id,
257  void                       *buffer,
258  unsigned32                 *size,
259  boolean                     wait,
260  Watchdog_Interval           timeout
261);
262
263#ifndef __RTEMS_APPLICATION__
264#include <rtems/score/coremsg.inl>
265#endif
266
267#ifdef __cplusplus
268}
269#endif
270 
271#endif
272/*  end of include file */
273
Note: See TracBrowser for help on using the repository browser.