source: rtems/c/src/exec/score/include/rtems/score/coremsg.h @ 3a96054

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