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