1 | /** |
---|
2 | * @file rtems/rtems/message.h |
---|
3 | * |
---|
4 | * @defgroup ClassicMessageQueue Message Queues |
---|
5 | * |
---|
6 | * @ingroup ClassicRTEMS |
---|
7 | * @brief Message Queue Manager |
---|
8 | * |
---|
9 | * This include file contains all the constants and structures associated |
---|
10 | * with the Message Queue Manager. This manager provides a mechanism for |
---|
11 | * communication and synchronization between tasks using messages. |
---|
12 | * |
---|
13 | * Directives provided are: |
---|
14 | * |
---|
15 | * - create a queue |
---|
16 | * - get ID of a queue |
---|
17 | * - delete a queue |
---|
18 | * - put a message at the rear of a queue |
---|
19 | * - put a message at the front of a queue |
---|
20 | * - broadcast N messages to a queue |
---|
21 | * - receive message from a queue |
---|
22 | * - flush all messages on a queue |
---|
23 | */ |
---|
24 | |
---|
25 | /* COPYRIGHT (c) 1989-2013. |
---|
26 | * On-Line Applications Research Corporation (OAR). |
---|
27 | * |
---|
28 | * The license and distribution terms for this file may be |
---|
29 | * found in the file LICENSE in this distribution or at |
---|
30 | * http://www.rtems.org/license/LICENSE. |
---|
31 | */ |
---|
32 | |
---|
33 | #ifndef _RTEMS_RTEMS_MESSAGE_H |
---|
34 | #define _RTEMS_RTEMS_MESSAGE_H |
---|
35 | |
---|
36 | #include <rtems/rtems/types.h> |
---|
37 | #include <rtems/rtems/status.h> |
---|
38 | #include <rtems/rtems/options.h> |
---|
39 | #include <rtems/rtems/attr.h> |
---|
40 | #include <rtems/score/object.h> |
---|
41 | #include <rtems/score/coremsg.h> |
---|
42 | |
---|
43 | #ifdef __cplusplus |
---|
44 | extern "C" { |
---|
45 | #endif |
---|
46 | |
---|
47 | /** |
---|
48 | * @ingroup ClassicMessageQueueImpl |
---|
49 | * |
---|
50 | * The following records define the control block used to manage |
---|
51 | * each message queue. |
---|
52 | */ |
---|
53 | typedef struct { |
---|
54 | /** This field is the inherited object characteristics. */ |
---|
55 | Objects_Control Object; |
---|
56 | /** This field is the instance of the SuperCore Message Queue. */ |
---|
57 | CORE_message_queue_Control message_queue; |
---|
58 | /** This field is the attribute set as defined by the API. */ |
---|
59 | rtems_attribute attribute_set; |
---|
60 | } Message_queue_Control; |
---|
61 | |
---|
62 | /** |
---|
63 | * @defgroup ClassicMessageQueue Message Queues |
---|
64 | * |
---|
65 | * @ingroup ClassicRTEMS |
---|
66 | * |
---|
67 | * This encapsulates functionality related to the Classic API Message Queue |
---|
68 | * Manager. |
---|
69 | */ |
---|
70 | /**@{*/ |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief RTEMS Create Message Queue |
---|
74 | * |
---|
75 | * This routine implements the rtems_message_queue_create directive. The |
---|
76 | * message queue will have the @a name. If the @a attribute_set indicates |
---|
77 | * that the message queue is to be limited in the number of messages |
---|
78 | * that can be outstanding, then @a count indicates the maximum number of |
---|
79 | * messages that will be held. It returns the id of the created |
---|
80 | * message queue in @a id. |
---|
81 | * |
---|
82 | * @param[in] name is the user defined queue name |
---|
83 | * @param[in] count is the maximum message and reserved buffer count |
---|
84 | * @param[in] max_message_size is the maximum size of each message |
---|
85 | * @param[in] attribute_set is the process method |
---|
86 | * @param[in] id is the pointer to queue |
---|
87 | * |
---|
88 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
89 | * error. Otherwise, a status code is returned indicating the |
---|
90 | * source of the error. If successful, the @a id will |
---|
91 | * be filled in with the queue id. |
---|
92 | */ |
---|
93 | rtems_status_code rtems_message_queue_create( |
---|
94 | rtems_name name, |
---|
95 | uint32_t count, |
---|
96 | size_t max_message_size, |
---|
97 | rtems_attribute attribute_set, |
---|
98 | rtems_id *id |
---|
99 | ); |
---|
100 | |
---|
101 | /** |
---|
102 | * @brief RTEMS Message Queue Name to Id |
---|
103 | * |
---|
104 | * This routine implements the rtems_message_queue_ident directive. |
---|
105 | * This directive returns the message queue ID associated with NAME. |
---|
106 | * If more than one message queue is named name, then the message |
---|
107 | * queue to which the ID belongs is arbitrary. node indicates the |
---|
108 | * extent of the search for the ID of the message queue named name. |
---|
109 | * The search can be limited to a particular node or allowed to |
---|
110 | * encompass all nodes. |
---|
111 | * |
---|
112 | * @param[in] name is the user defined message queue name |
---|
113 | * @param[in] node is the node(s) to be searched |
---|
114 | * @param[in] id is the pointer to message queue id |
---|
115 | * |
---|
116 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and |
---|
117 | * *id filled with the message queue id |
---|
118 | */ |
---|
119 | rtems_status_code rtems_message_queue_ident( |
---|
120 | rtems_name name, |
---|
121 | uint32_t node, |
---|
122 | rtems_id *id |
---|
123 | ); |
---|
124 | |
---|
125 | /** |
---|
126 | * @brief RTEMS Delete Message Queue |
---|
127 | * |
---|
128 | * This routine implements the rtems_message_queue_delete directive. The |
---|
129 | * message queue indicated by ID is deleted. |
---|
130 | * |
---|
131 | * @param[in] id is the queue id |
---|
132 | * |
---|
133 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful |
---|
134 | */ |
---|
135 | rtems_status_code rtems_message_queue_delete( |
---|
136 | rtems_id id |
---|
137 | ); |
---|
138 | |
---|
139 | /** |
---|
140 | * @brief rtems_message_queue_send |
---|
141 | * |
---|
142 | * Message Queue Manager - rtems_message_queue_send |
---|
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, |
---|
151 | * then the message buffer will be placed at the REAR of the |
---|
152 | * chain of pending messages for this message queue. |
---|
153 | */ |
---|
154 | rtems_status_code rtems_message_queue_send( |
---|
155 | rtems_id id, |
---|
156 | const void *buffer, |
---|
157 | size_t size |
---|
158 | ); |
---|
159 | |
---|
160 | /** |
---|
161 | * @brief RTEMS Urgent Message Queue |
---|
162 | * |
---|
163 | * This routine implements the rtems_message_queue_urgent directive. |
---|
164 | * This directive has the same behavior as rtems_message_queue_send |
---|
165 | * except that if no tasks are waiting, the message buffer will |
---|
166 | * be placed at the FRONT of the chain of pending messages rather |
---|
167 | * than at the REAR. |
---|
168 | * |
---|
169 | * @param[in] id is the pointer to message queue |
---|
170 | * @param[in] buffer is the pointer to message buffer |
---|
171 | * @param[in] size is the size of message to send urgently |
---|
172 | * |
---|
173 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful |
---|
174 | */ |
---|
175 | rtems_status_code rtems_message_queue_urgent( |
---|
176 | rtems_id id, |
---|
177 | const void *buffer, |
---|
178 | size_t size |
---|
179 | ); |
---|
180 | |
---|
181 | /** |
---|
182 | * @brief RTEMS Broadcast Message Queue |
---|
183 | * |
---|
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. |
---|
188 | * |
---|
189 | * @param[in] id is the pointer to message queue |
---|
190 | * @param[in] buffer is the pointer to message buffer |
---|
191 | * @param[in] size is the size of message to broadcast |
---|
192 | * @param[in] count pointer to area to store number of threads made ready |
---|
193 | * |
---|
194 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and |
---|
195 | * *count filled in with number of threads made ready |
---|
196 | */ |
---|
197 | rtems_status_code rtems_message_queue_broadcast( |
---|
198 | rtems_id id, |
---|
199 | const void *buffer, |
---|
200 | size_t size, |
---|
201 | uint32_t *count |
---|
202 | ); |
---|
203 | |
---|
204 | /** |
---|
205 | * @brief RTEMS Message Queue Receive |
---|
206 | * |
---|
207 | * This routine implements the rtems_message_queue_receive directive. |
---|
208 | * This directive is invoked when the calling task wishes to receive |
---|
209 | * a message from the message queue indicated by ID. The received |
---|
210 | * message is to be placed in buffer. If no messages are outstanding |
---|
211 | * and the option_set indicates that the task is willing to block, |
---|
212 | * then the task will be blocked until a message arrives or until, |
---|
213 | * optionally, timeout clock ticks have passed. |
---|
214 | * |
---|
215 | * @param[in] id is the queue id |
---|
216 | * @param[in] buffer is the pointer to message buffer |
---|
217 | * @param[in] size is the size of message receive |
---|
218 | * @param[in] option_set is the options on receive |
---|
219 | * @param[in] timeout is the number of ticks to wait |
---|
220 | * |
---|
221 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
222 | * error. Otherwise, a status code is returned indicating the |
---|
223 | * source of the error. |
---|
224 | */ |
---|
225 | rtems_status_code rtems_message_queue_receive( |
---|
226 | rtems_id id, |
---|
227 | void *buffer, |
---|
228 | size_t *size, |
---|
229 | rtems_option option_set, |
---|
230 | rtems_interval timeout |
---|
231 | ); |
---|
232 | |
---|
233 | /** |
---|
234 | * @brief rtems_message_queue_flush |
---|
235 | * |
---|
236 | * This routine implements the rtems_message_queue_flush directive. |
---|
237 | * This directive takes all outstanding messages for the message |
---|
238 | * queue indicated by ID and returns them to the inactive message |
---|
239 | * chain. The number of messages flushed is returned in COUNT. |
---|
240 | * |
---|
241 | * Message Queue Manager |
---|
242 | */ |
---|
243 | rtems_status_code rtems_message_queue_flush( |
---|
244 | rtems_id id, |
---|
245 | uint32_t *count |
---|
246 | ); |
---|
247 | |
---|
248 | /** |
---|
249 | * @brief RTEMS Message Queue Get Number Pending |
---|
250 | * |
---|
251 | * Message Queue Manager |
---|
252 | * |
---|
253 | * This routine implements the rtems_message_queue_get_number_pending |
---|
254 | * directive. This directive returns the number of pending |
---|
255 | * messages for the message queue indicated by ID |
---|
256 | * chain. The number of messages pending is returned in COUNT. |
---|
257 | */ |
---|
258 | rtems_status_code rtems_message_queue_get_number_pending( |
---|
259 | rtems_id id, |
---|
260 | uint32_t *count |
---|
261 | ); |
---|
262 | |
---|
263 | /**@}*/ |
---|
264 | |
---|
265 | #ifdef __cplusplus |
---|
266 | } |
---|
267 | #endif |
---|
268 | |
---|
269 | #endif |
---|
270 | /* end of include file */ |
---|