1 | /* coremsg.inl |
---|
2 | * |
---|
3 | * This include file contains the static inline implementation of all |
---|
4 | * inlined routines in the Core Message 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.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef __CORE_MESSAGE_QUEUE_inl |
---|
17 | #define __CORE_MESSAGE_QUEUE_inl |
---|
18 | |
---|
19 | #include <string.h> /* needed for memcpy */ |
---|
20 | |
---|
21 | /*PAGE |
---|
22 | * |
---|
23 | * _CORE_message_queue_Send |
---|
24 | * |
---|
25 | * DESCRIPTION: |
---|
26 | * |
---|
27 | * This routine sends a message to the end of the specified message queue. |
---|
28 | */ |
---|
29 | |
---|
30 | RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send( |
---|
31 | CORE_message_queue_Control *the_message_queue, |
---|
32 | void *buffer, |
---|
33 | uint32_t size, |
---|
34 | Objects_Id id, |
---|
35 | CORE_message_queue_API_mp_support_callout api_message_queue_mp_support, |
---|
36 | boolean wait, |
---|
37 | Watchdog_Interval timeout |
---|
38 | ) |
---|
39 | { |
---|
40 | return _CORE_message_queue_Submit( |
---|
41 | the_message_queue, |
---|
42 | buffer, |
---|
43 | size, |
---|
44 | id, |
---|
45 | #if defined(RTEMS_MULTIPROCESSING) |
---|
46 | api_message_queue_mp_support, |
---|
47 | #else |
---|
48 | NULL, |
---|
49 | #endif |
---|
50 | CORE_MESSAGE_QUEUE_SEND_REQUEST, |
---|
51 | wait, /* sender may block */ |
---|
52 | timeout /* timeout interval */ |
---|
53 | ); |
---|
54 | } |
---|
55 | |
---|
56 | /*PAGE |
---|
57 | * |
---|
58 | * _CORE_message_queue_Urgent |
---|
59 | * |
---|
60 | * DESCRIPTION: |
---|
61 | * |
---|
62 | * This routine sends a message to the front of the specified message queue. |
---|
63 | */ |
---|
64 | |
---|
65 | RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent( |
---|
66 | CORE_message_queue_Control *the_message_queue, |
---|
67 | void *buffer, |
---|
68 | uint32_t size, |
---|
69 | Objects_Id id, |
---|
70 | CORE_message_queue_API_mp_support_callout api_message_queue_mp_support, |
---|
71 | boolean wait, |
---|
72 | Watchdog_Interval timeout |
---|
73 | ) |
---|
74 | { |
---|
75 | return _CORE_message_queue_Submit( |
---|
76 | the_message_queue, |
---|
77 | buffer, |
---|
78 | size, |
---|
79 | id, |
---|
80 | #if defined(RTEMS_MULTIPROCESSING) |
---|
81 | api_message_queue_mp_support, |
---|
82 | #else |
---|
83 | NULL, |
---|
84 | #endif |
---|
85 | CORE_MESSAGE_QUEUE_URGENT_REQUEST, |
---|
86 | wait, /* sender may block */ |
---|
87 | timeout /* timeout interval */ |
---|
88 | ); |
---|
89 | } |
---|
90 | |
---|
91 | /*PAGE |
---|
92 | * |
---|
93 | * _CORE_message_queue_Copy_buffer |
---|
94 | * |
---|
95 | * DESCRIPTION: |
---|
96 | * |
---|
97 | * This routine copies the contents of the source message buffer |
---|
98 | * to the destination message buffer. |
---|
99 | */ |
---|
100 | |
---|
101 | RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer ( |
---|
102 | void *source, |
---|
103 | void *destination, |
---|
104 | uint32_t size |
---|
105 | ) |
---|
106 | { |
---|
107 | memcpy(destination, source, size); |
---|
108 | } |
---|
109 | |
---|
110 | /*PAGE |
---|
111 | * |
---|
112 | * _CORE_message_queue_Allocate_message_buffer |
---|
113 | * |
---|
114 | * DESCRIPTION: |
---|
115 | * |
---|
116 | * This function allocates a message buffer from the inactive |
---|
117 | * message buffer chain. |
---|
118 | */ |
---|
119 | |
---|
120 | RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control * |
---|
121 | _CORE_message_queue_Allocate_message_buffer ( |
---|
122 | CORE_message_queue_Control *the_message_queue |
---|
123 | ) |
---|
124 | { |
---|
125 | return (CORE_message_queue_Buffer_control *) |
---|
126 | _Chain_Get( &the_message_queue->Inactive_messages ); |
---|
127 | } |
---|
128 | |
---|
129 | /*PAGE |
---|
130 | * |
---|
131 | * _CORE_message_queue_Free_message_buffer |
---|
132 | * |
---|
133 | * DESCRIPTION: |
---|
134 | * |
---|
135 | * This routine frees a message buffer to the inactive |
---|
136 | * message buffer chain. |
---|
137 | */ |
---|
138 | |
---|
139 | RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer ( |
---|
140 | CORE_message_queue_Control *the_message_queue, |
---|
141 | CORE_message_queue_Buffer_control *the_message |
---|
142 | ) |
---|
143 | { |
---|
144 | _Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node ); |
---|
145 | } |
---|
146 | |
---|
147 | /*PAGE |
---|
148 | * |
---|
149 | * _CORE_message_queue_Get_pending_message |
---|
150 | * |
---|
151 | * DESCRIPTION: |
---|
152 | * |
---|
153 | * This function removes the first message from the_message_queue |
---|
154 | * and returns a pointer to it. |
---|
155 | */ |
---|
156 | |
---|
157 | RTEMS_INLINE_ROUTINE |
---|
158 | CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message ( |
---|
159 | CORE_message_queue_Control *the_message_queue |
---|
160 | ) |
---|
161 | { |
---|
162 | return (CORE_message_queue_Buffer_control *) |
---|
163 | _Chain_Get_unprotected( &the_message_queue->Pending_messages ); |
---|
164 | } |
---|
165 | |
---|
166 | /*PAGE |
---|
167 | * |
---|
168 | * _CORE_message_queue_Is_priority |
---|
169 | * |
---|
170 | * DESCRIPTION: |
---|
171 | * |
---|
172 | * This function returns TRUE if the priority attribute is |
---|
173 | * enabled in the attribute_set and FALSE otherwise. |
---|
174 | */ |
---|
175 | |
---|
176 | RTEMS_INLINE_ROUTINE boolean _CORE_message_queue_Is_priority( |
---|
177 | CORE_message_queue_Attributes *the_attribute |
---|
178 | ) |
---|
179 | { |
---|
180 | return (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY); |
---|
181 | } |
---|
182 | |
---|
183 | /*PAGE |
---|
184 | * |
---|
185 | * _CORE_message_queue_Append |
---|
186 | * |
---|
187 | * DESCRIPTION: |
---|
188 | * |
---|
189 | * This routine places the_message at the rear of the outstanding |
---|
190 | * messages on the_message_queue. |
---|
191 | */ |
---|
192 | |
---|
193 | RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append ( |
---|
194 | CORE_message_queue_Control *the_message_queue, |
---|
195 | CORE_message_queue_Buffer_control *the_message |
---|
196 | ) |
---|
197 | { |
---|
198 | _Chain_Append( &the_message_queue->Pending_messages, &the_message->Node ); |
---|
199 | } |
---|
200 | |
---|
201 | /*PAGE |
---|
202 | * |
---|
203 | * _CORE_message_queue_Prepend |
---|
204 | * |
---|
205 | * DESCRIPTION: |
---|
206 | * |
---|
207 | * This routine places the_message at the front of the outstanding |
---|
208 | * messages on the_message_queue. |
---|
209 | */ |
---|
210 | |
---|
211 | RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend ( |
---|
212 | CORE_message_queue_Control *the_message_queue, |
---|
213 | CORE_message_queue_Buffer_control *the_message |
---|
214 | ) |
---|
215 | { |
---|
216 | _Chain_Prepend( |
---|
217 | &the_message_queue->Pending_messages, |
---|
218 | &the_message->Node |
---|
219 | ); |
---|
220 | } |
---|
221 | |
---|
222 | /*PAGE |
---|
223 | * |
---|
224 | * _CORE_message_queue_Is_null |
---|
225 | * |
---|
226 | * DESCRIPTION: |
---|
227 | * |
---|
228 | * This function returns TRUE if the_message_queue is TRUE and FALSE otherwise. |
---|
229 | */ |
---|
230 | |
---|
231 | RTEMS_INLINE_ROUTINE boolean _CORE_message_queue_Is_null ( |
---|
232 | CORE_message_queue_Control *the_message_queue |
---|
233 | ) |
---|
234 | { |
---|
235 | return ( the_message_queue == NULL ); |
---|
236 | } |
---|
237 | |
---|
238 | /*PAGE |
---|
239 | * |
---|
240 | * _CORE_message_queue_Is_notify_enabled |
---|
241 | * |
---|
242 | * DESCRIPTION: |
---|
243 | * |
---|
244 | * This function returns TRUE if notification is enabled on this message |
---|
245 | * queue and FALSE otherwise. |
---|
246 | */ |
---|
247 | |
---|
248 | RTEMS_INLINE_ROUTINE boolean _CORE_message_queue_Is_notify_enabled ( |
---|
249 | CORE_message_queue_Control *the_message_queue |
---|
250 | ) |
---|
251 | { |
---|
252 | return (the_message_queue->notify_handler != NULL); |
---|
253 | } |
---|
254 | |
---|
255 | /*PAGE |
---|
256 | * |
---|
257 | * _CORE_message_queue_Set_notify |
---|
258 | * |
---|
259 | * DESCRIPTION: |
---|
260 | * |
---|
261 | * This routine initializes the notification information for the_message_queue. |
---|
262 | */ |
---|
263 | |
---|
264 | RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify ( |
---|
265 | CORE_message_queue_Control *the_message_queue, |
---|
266 | CORE_message_queue_Notify_Handler the_handler, |
---|
267 | void *the_argument |
---|
268 | ) |
---|
269 | { |
---|
270 | the_message_queue->notify_handler = the_handler; |
---|
271 | the_message_queue->notify_argument = the_argument; |
---|
272 | } |
---|
273 | |
---|
274 | #endif |
---|
275 | /* end of include file */ |
---|