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