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