Changeset 3652ad35 in rtems for cpukit/rtems
- Timestamp:
- 09/19/95 14:53:29 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 38ffa0c
- Parents:
- b3ac6a8d
- Location:
- cpukit/rtems
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/rtems/include/rtems/rtems/message.h
rb3ac6a8d r3652ad35 40 40 #include <rtems/rtems/attr.h> 41 41 #include <rtems/core/threadq.h> 42 43 /* 44 * The following defines the data types needed to manipulate 45 * the contents of message buffers. 46 * Since msgs are variable length we just make a ptr to 1. 47 */ 48 49 typedef struct { 50 unsigned32 size; 51 52 #ifndef __cplusplus 53 /* NOTE: [0] is gcc specific, 54 * but specifically disallowed by ANSI STD C++ 55 * g++ warns about it, so we #ifdef it out to 56 * get rid of warnings when compiled by g++. 57 */ 58 unsigned32 buffer[0]; 59 #endif 60 61 } Message_queue_Buffer; 62 63 /* 64 * The following records define the organization of a message 65 * buffer. 66 */ 67 68 typedef struct { 69 Chain_Node Node; 70 Message_queue_Buffer Contents; 71 } Message_queue_Buffer_control; 72 73 /* 74 * The following records define the control block used to manage 75 * each message queue. 76 */ 77 78 typedef struct { 79 Objects_Control Object; 80 Thread_queue_Control Wait_queue; 81 rtems_attribute attribute_set; 82 unsigned32 maximum_pending_messages; 83 unsigned32 number_of_pending_messages; 84 unsigned32 maximum_message_size; 85 Chain_Control Pending_messages; 86 Message_queue_Buffer *message_buffers; 87 Chain_Control Inactive_messages; 88 } Message_queue_Control; 89 90 /* 91 * The following defines the information control block used to 92 * manage this class of objects. 93 */ 94 95 EXTERN Objects_Information _Message_queue_Information; 42 #include <rtems/core/coremsg.h> 96 43 97 44 /* … … 100 47 * in a send or urgent fashion. 101 48 */ 102 49 103 50 typedef enum { 104 51 MESSAGE_QUEUE_SEND_REQUEST = 0, 105 52 MESSAGE_QUEUE_URGENT_REQUEST = 1 106 53 } Message_queue_Submit_types; 54 55 /* 56 * The following records define the control block used to manage 57 * each message queue. 58 */ 59 60 typedef struct { 61 Objects_Control Object; 62 rtems_attribute attribute_set; 63 CORE_message_queue_Control message_queue; 64 } Message_queue_Control; 65 66 /* 67 * The following defines the information control block used to 68 * manage this class of objects. 69 */ 70 71 EXTERN Objects_Information _Message_queue_Information; 107 72 108 73 /* … … 256 221 Objects_Id id, 257 222 void *buffer, 258 unsigned32 *size _p,223 unsigned32 *size, 259 224 unsigned32 option_set, 260 225 rtems_interval timeout … … 278 243 279 244 /* 280 * _Message_queue_Copy_buffer281 *282 * DESCRIPTION:283 *284 * This routine copies the contents of the source message buffer285 * to the destination message buffer.286 */287 288 STATIC INLINE void _Message_queue_Copy_buffer (289 void *source,290 void *destination,291 unsigned32 size292 );293 294 /*295 * _Message_queue_Seize296 *297 * DESCRIPTION:298 *299 * This routine attempts to receive a message from the_message_queue.300 * If a message is available or if the RTEMS_NO_WAIT option is enabled in301 * option_set, then the routine returns. Otherwise, the calling task302 * is blocked until a message is available. If a message is returned303 * to the task, then buffer will contain its contents.304 */305 306 boolean _Message_queue_Seize(307 Message_queue_Control *the_message_queue,308 unsigned32 option_set,309 void *buffer,310 unsigned32 *size_p311 );312 313 /*314 * _Message_queue_Flush_support315 *316 * DESCRIPTION:317 *318 * This routine flushes all outstanding messages and returns319 * them to the inactive message chain.320 */321 322 unsigned32 _Message_queue_Flush_support(323 Message_queue_Control *the_message_queue324 );325 326 /*327 245 * _Message_queue_Submit 328 246 * 329 247 * DESCRIPTION: 330 248 * 331 * This routine provides the common foundation for the 332 * rtems_message_queue_send and rtems_message_queue_urgent directives. 333 */ 334 249 * This routine implements the directives rtems_message_queue_send 250 * and rtems_message_queue_urgent. It processes a message that is 251 * to be submitted to the designated message queue. The message will 252 * either be processed as a send send message which it will be inserted 253 * at the rear of the queue or it will be processed as an urgent message 254 * which will be inserted at the front of the queue. 255 */ 256 335 257 rtems_status_code _Message_queue_Submit( 336 258 Objects_Id id, … … 338 260 unsigned32 size, 339 261 Message_queue_Submit_types submit_type 340 );341 342 /*343 * _Message_queue_Allocate_message_buffer344 *345 * DESCRIPTION:346 *347 * This function allocates a message buffer from the inactive348 * message buffer chain.349 */350 351 STATIC INLINE Message_queue_Buffer_control *352 _Message_queue_Allocate_message_buffer (353 Message_queue_Control *the_message_queue354 );355 356 /*357 * _Message_queue_Free_message_buffer358 *359 * DESCRIPTION:360 *361 * This routine frees a message buffer to the inactive362 * message buffer chain.363 */364 365 STATIC INLINE void _Message_queue_Free_message_buffer (366 Message_queue_Control *the_message_queue,367 Message_queue_Buffer_control *the_message368 );369 370 /*371 * _Message_queue_Get_pending_message372 *373 * DESCRIPTION:374 *375 * This function removes the first message from the_message_queue376 * and returns a pointer to it.377 */378 379 STATIC INLINE380 Message_queue_Buffer_control *_Message_queue_Get_pending_message (381 Message_queue_Control *the_message_queue382 );383 384 /*385 * _Message_queue_Append386 *387 * DESCRIPTION:388 *389 * This routine places the_message at the rear of the outstanding390 * messages on the_message_queue.391 */392 393 STATIC INLINE void _Message_queue_Append (394 Message_queue_Control *the_message_queue,395 Message_queue_Buffer_control *the_message396 );397 398 /*399 * _Message_queue_Prepend400 *401 * DESCRIPTION:402 *403 * This routine places the_message at the rear of the outstanding404 * messages on the_message_queue.405 */406 407 STATIC INLINE void _Message_queue_Prepend (408 Message_queue_Control *the_message_queue,409 Message_queue_Buffer_control *the_message410 262 ); 411 263 … … 470 322 ); 471 323 324 /* 325 * _Message_queue_Translate_core_message_queue_return_code 326 * 327 * DESCRIPTION: 328 * 329 * This function returns a RTEMS status code based on the core message queue 330 * status code specified. 331 */ 332 333 rtems_status_code _Message_queue_Translate_core_message_queue_return_code ( 334 unsigned32 the_message_queue_status 335 ); 336 337 /* 338 * 339 * _Message_queue_Core_message_queue_mp_support 340 * 341 * Input parameters: 342 * the_thread - the remote thread the message was submitted to 343 * id - id of the message queue 344 * 345 * Output parameters: NONE 346 */ 347 348 void _Message_queue_Core_message_queue_mp_support ( 349 Thread_Control *the_thread, 350 Objects_Id id 351 ); 352 472 353 #include <rtems/rtems/message.inl> 473 354 #include <rtems/rtems/msgmp.h> -
cpukit/rtems/include/rtems/rtems/msgmp.h
rb3ac6a8d r3652ad35 64 64 unsigned32 size; 65 65 unsigned32 pad0; 66 Message_queue_BufferBuffer;66 CORE_message_queue_Buffer Buffer; 67 67 } Message_queue_MP_Packet; 68 68 -
cpukit/rtems/inline/rtems/rtems/message.inl
rb3ac6a8d r3652ad35 19 19 20 20 #include <rtems/core/wkspace.h> 21 22 /*PAGE23 *24 * _Message_queue_Copy_buffer25 *26 */27 28 STATIC INLINE void _Message_queue_Copy_buffer (29 void *source,30 void *destination,31 unsigned32 size32 )33 {34 memcpy(destination, source, size);35 }36 37 /*PAGE38 *39 * _Message_queue_Allocate_message_buffer40 *41 */42 43 STATIC INLINE Message_queue_Buffer_control *44 _Message_queue_Allocate_message_buffer (45 Message_queue_Control *the_message_queue46 )47 {48 return (Message_queue_Buffer_control *)49 _Chain_Get( &the_message_queue->Inactive_messages );50 }51 52 /*PAGE53 *54 * _Message_queue_Free_message_buffer55 *56 */57 58 STATIC INLINE void _Message_queue_Free_message_buffer (59 Message_queue_Control *the_message_queue,60 Message_queue_Buffer_control *the_message61 )62 {63 _Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );64 }65 66 /*PAGE67 *68 * _Message_queue_Get_pending_message69 *70 */71 72 STATIC INLINE73 Message_queue_Buffer_control *_Message_queue_Get_pending_message (74 Message_queue_Control *the_message_queue75 )76 {77 return (Message_queue_Buffer_control *)78 _Chain_Get_unprotected( &the_message_queue->Pending_messages );79 }80 81 /*PAGE82 *83 * _Message_queue_Append84 *85 */86 87 STATIC INLINE void _Message_queue_Append (88 Message_queue_Control *the_message_queue,89 Message_queue_Buffer_control *the_message90 )91 {92 _Chain_Append( &the_message_queue->Pending_messages, &the_message->Node );93 }94 95 /*PAGE96 *97 * _Message_queue_Prepend98 *99 */100 101 STATIC INLINE void _Message_queue_Prepend (102 Message_queue_Control *the_message_queue,103 Message_queue_Buffer_control *the_message104 )105 {106 _Chain_Prepend(107 &the_message_queue->Pending_messages,108 &the_message->Node109 );110 }111 21 112 22 /*PAGE … … 134 44 ) 135 45 { 136 if (the_message_queue->message_buffers) {137 _Workspace_Free((void *) the_message_queue->message_buffers);138 the_message_queue->message_buffers = 0;139 }140 141 46 _Objects_Free( &_Message_queue_Information, &the_message_queue->Object ); 142 47 } -
cpukit/rtems/macros/rtems/rtems/message.inl
rb3ac6a8d r3652ad35 20 20 /*PAGE 21 21 * 22 * _Message_queue_Copy_buffer23 */24 25 #define _Message_queue_Copy_buffer( _source, _destination, _size ) \26 memcpy( _destination, _source, _size)27 28 /*PAGE29 *30 * _Message_queue_Allocate_message_buffer31 *32 */33 34 #define _Message_queue_Allocate_message_buffer( _the_message_queue ) \35 (Message_queue_Buffer_control *) \36 _Chain_Get( &(_the_message_queue)->Inactive_messages )37 38 /*PAGE39 *40 * _Message_queue_Free_message_buffer41 *42 */43 44 #define _Message_queue_Free_message_buffer( _the_message_queue, _the_message ) \45 _Chain_Append( \46 &(_the_message_queue)->Inactive_messages, \47 &(_the_message)->Node \48 )49 50 /*PAGE51 *52 * _Message_queue_Get_pending_message53 *54 */55 56 #define _Message_queue_Get_pending_message( _the_message_queue ) \57 (Message_queue_Buffer_control *) \58 _Chain_Get_unprotected( &(_the_message_queue)->Pending_messages )59 60 /*PAGE61 *62 * _Message_queue_Append63 *64 */65 66 #define _Message_queue_Append( _the_message_queue, _the_message ) \67 _Chain_Append( &(_the_message_queue)->Pending_messages, \68 &(_the_message)->Node )69 70 /*PAGE71 *72 * _Message_queue_Prepend73 *74 */75 76 #define _Message_queue_Prepend( _the_message_queue, _the_message ) \77 _Chain_Prepend( &(_the_message_queue)->Pending_messages, \78 &(_the_message)->Node )79 80 /*PAGE81 *82 22 * _Message_queue_Is_null 83 23 * … … 94 34 95 35 #define _Message_queue_Free( _the_message_queue ) \ 96 do { \ 97 \ 98 if ( (_the_message_queue)->message_buffers ) { \ 99 _Workspace_Free((void *) (_the_message_queue)->message_buffers); \ 100 (_the_message_queue)->message_buffers = 0; \ 101 } \ 102 \ 103 _Objects_Free( \ 104 &_Message_queue_Information, \ 105 &(_the_message_queue)->Object \ 106 ); \ 107 } while ( 0 ) 108 36 _Objects_Free( &_Message_queue_Information, &(_the_message_queue)->Object ) 109 37 110 38 /*PAGE -
cpukit/rtems/src/msg.c
rb3ac6a8d r3652ad35 15 15 16 16 #include <rtems/system.h> 17 #include <rtems/rtems/status.h> 18 #include <rtems/rtems/attr.h> 17 #include <rtems/sysstate.h> 19 18 #include <rtems/core/chain.h> 20 19 #include <rtems/core/isr.h> 21 #include <rtems/ rtems/message.h>20 #include <rtems/core/coremsg.h> 22 21 #include <rtems/core/object.h> 23 #include <rtems/rtems/options.h>24 22 #include <rtems/core/states.h> 25 #include <rtems/rtems/support.h>26 23 #include <rtems/core/thread.h> 27 24 #include <rtems/core/wkspace.h> 28 25 #include <rtems/core/mpci.h> 29 #include <rtems/sysstate.h> 26 #include <rtems/rtems/status.h> 27 #include <rtems/rtems/attr.h> 28 #include <rtems/rtems/message.h> 29 #include <rtems/rtems/options.h> 30 #include <rtems/rtems/support.h> 30 31 31 32 /*PAGE … … 73 74 * 74 75 * Allocate a message queue and the space for its messages 76 * 77 * Input parameters: 78 * the_message_queue - the message queue to allocate message buffers 79 * count - maximum message and reserved buffer count 80 * max_message_size - maximum size of each message 81 * 82 * Output parameters: 83 * the_message_queue - set if successful, NULL otherwise 75 84 */ 76 85 77 86 Message_queue_Control *_Message_queue_Allocate ( 78 unsigned32 count, 79 unsigned32 max_message_size 80 ) 81 { 82 Message_queue_Control *mq = 0; 83 unsigned32 message_buffering_required; 84 unsigned32 allocated_message_size; 85 86 mq = 87 (Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information); 88 89 if (mq == 0) 90 goto failed; 91 92 mq->maximum_message_size = max_message_size; 93 94 /* 95 * round size up to multiple of a ptr for chain init 96 */ 97 98 allocated_message_size = max_message_size; 99 if (allocated_message_size & (sizeof(unsigned32) - 1)) { 100 allocated_message_size += sizeof(unsigned32); 101 allocated_message_size &= ~(sizeof(unsigned32) - 1); 102 } 103 104 message_buffering_required = 105 count * (allocated_message_size + sizeof(Message_queue_Buffer_control)); 106 107 mq->message_buffers = 108 (Message_queue_Buffer *) _Workspace_Allocate(message_buffering_required); 109 110 if (mq->message_buffers == 0) 111 goto failed; 112 113 _Chain_Initialize 114 (&mq->Inactive_messages, 115 mq->message_buffers, 116 count, 117 allocated_message_size + sizeof(Message_queue_Buffer_control) 118 ); 119 return mq; 120 121 failed: 122 if (mq) 123 _Message_queue_Free(mq); 124 return (Message_queue_Control *) 0; 87 unsigned32 count, 88 unsigned32 max_message_size 89 ) 90 { 91 return 92 (Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information); 93 125 94 } 126 95 … … 133 102 * 134 103 * Input parameters: 135 * name - user defined queue name136 * count - maximum message and reserved buffer count104 * name - user defined queue name 105 * count - maximum message and reserved buffer count 137 106 * max_message_size - maximum size of each message 138 * attribute_set - process method139 * id - pointer to queue107 * attribute_set - process method 108 * id - pointer to queue 140 109 * 141 110 * Output parameters: … … 154 123 { 155 124 register Message_queue_Control *the_message_queue; 125 CORE_message_queue_Attributes the_message_queue_attributes; 126 boolean is_global; 156 127 157 128 if ( !rtems_is_name_valid( name ) ) 158 129 return RTEMS_INVALID_NAME; 159 130 160 if ( _Attributes_Is_global( attribute_set) &&131 if ( (is_global = _Attributes_Is_global( attribute_set ) ) && 161 132 !_System_state_Is_multiprocessing ) 162 133 return RTEMS_MP_NOT_CONFIGURED; … … 175 146 */ 176 147 177 if ( _Attributes_Is_global( attribute_set ) && 178 (_MPCI_table->maximum_packet_size < max_message_size)) 179 { 180 return RTEMS_INVALID_SIZE; 181 } 148 if ( is_global && (_MPCI_table->maximum_packet_size < max_message_size) ) 149 return RTEMS_INVALID_SIZE; 150 182 151 #endif 183 152 184 153 _Thread_Disable_dispatch(); /* protects object pointer */ 185 154 186 the_message_queue = _Message_queue_Allocate( count, max_message_size);155 the_message_queue = _Message_queue_Allocate( count, max_message_size ); 187 156 188 157 if ( !the_message_queue ) { … … 191 160 } 192 161 193 if ( _Attributes_Is_global( attribute_set )&&194 !( _Objects_MP_Allocate_and_open( &_Message_queue_Information, name,195 the_message_queue->Object.id, FALSE ) ) ) {162 if ( is_global && 163 !( _Objects_MP_Allocate_and_open( &_Message_queue_Information, 164 name, the_message_queue->Object.id, FALSE ) ) ) { 196 165 _Message_queue_Free( the_message_queue ); 197 166 _Thread_Enable_dispatch(); … … 199 168 } 200 169 201 the_message_queue->maximum_pending_messages = count;202 203 170 the_message_queue->attribute_set = attribute_set; 204 the_message_queue->number_of_pending_messages = 0; 205 206 _Chain_Initialize_empty( &the_message_queue->Pending_messages ); 207 208 _Thread_queue_Initialize( 209 &the_message_queue->Wait_queue, 210 OBJECTS_RTEMS_MESSAGE_QUEUES, 211 _Attributes_Is_priority( attribute_set ) ? 212 THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO, 213 STATES_WAITING_FOR_MESSAGE, 214 _Message_queue_MP_Send_extract_proxy, 215 RTEMS_TIMEOUT 216 ); 171 172 if (_Attributes_Is_priority( attribute_set ) ) 173 the_message_queue_attributes.discipline = 174 CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY; 175 else 176 the_message_queue_attributes.discipline = 177 CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO; 178 179 if ( ! _CORE_message_queue_Initialize( 180 &the_message_queue->message_queue, 181 OBJECTS_RTEMS_MESSAGE_QUEUES, 182 &the_message_queue_attributes, 183 count, 184 max_message_size, 185 _Message_queue_MP_Send_extract_proxy ) ) { 186 if ( is_global ) 187 _Objects_MP_Close( 188 &_Message_queue_Information, the_message_queue->Object.id); 189 190 _Message_queue_Free( the_message_queue ); 191 _Thread_Enable_dispatch(); 192 return RTEMS_TOO_MANY; 193 } 217 194 218 195 _Objects_Open( … … 224 201 *id = the_message_queue->Object.id; 225 202 226 if ( _Attributes_Is_global( attribute_set ))203 if ( is_global ) 227 204 _Message_queue_MP_Send_process_packet( 228 205 MESSAGE_QUEUE_MP_ANNOUNCE_CREATE, … … 305 282 &the_message_queue->Object ); 306 283 307 if ( the_message_queue->number_of_pending_messages != 0 ) 308 (void) _Message_queue_Flush_support( the_message_queue ); 309 else 310 _Thread_queue_Flush( 311 &the_message_queue->Wait_queue, 312 _Message_queue_MP_Send_object_was_deleted, 313 RTEMS_OBJECT_WAS_DELETED 314 ); 284 _CORE_message_queue_Close( 285 &the_message_queue->message_queue, 286 _Message_queue_MP_Send_object_was_deleted, 287 CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED 288 ); 315 289 316 290 _Message_queue_Free( the_message_queue ); … … 347 321 * id - pointer to message queue 348 322 * buffer - pointer to message buffer 323 * size - size of message to sent urgently 349 324 * 350 325 * Output parameters: … … 359 334 ) 360 335 { 361 return _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST);336 return( _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST) ); 362 337 } 363 338 … … 372 347 * id - pointer to message queue 373 348 * buffer - pointer to message buffer 349 * size - size of message to sent urgently 374 350 * 375 351 * Output parameters: 376 352 * RTEMS_SUCCESSFUL - if successful 377 * error code - if unsuccessful353 * error code - if unsuccessful 378 354 */ 379 355 … … 384 360 ) 385 361 { 386 return _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_URGENT_REQUEST);362 return(_Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_URGENT_REQUEST)); 387 363 } 388 364 … … 397 373 * id - pointer to message queue 398 374 * buffer - pointer to message buffer 375 * size - size of message to broadcast 399 376 * count - pointer to area to store number of threads made ready 400 377 * 401 378 * Output parameters: 402 379 * count - number of threads made ready 403 * RTEMS_SUCCESSFUL - if successful380 * RTEMS_SUCCESSFUL - if successful 404 381 * error code - if unsuccessful 405 382 */ … … 414 391 register Message_queue_Control *the_message_queue; 415 392 Objects_Locations location; 416 Thread_Control *the_thread; 417 unsigned32 number_broadcasted; 393 CORE_message_queue_Status core_status; 418 394 419 395 the_message_queue = _Message_queue_Get( id, &location ); … … 435 411 436 412 case OBJECTS_LOCAL: 437 { 438 Thread_Wait_information *waitp; 439 unsigned32 constrained_size; 440 441 number_broadcasted = 0; 442 while ( (the_thread = 443 _Thread_queue_Dequeue(&the_message_queue->Wait_queue)) ) { 444 waitp = &the_thread->Wait; 445 number_broadcasted += 1; 446 447 constrained_size = size; 448 if (size > the_message_queue->maximum_message_size) 449 constrained_size = the_message_queue->maximum_message_size; 450 451 _Message_queue_Copy_buffer(buffer, 452 waitp->return_argument, 453 constrained_size); 454 455 *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 = size; 456 457 if ( !_Objects_Is_local_id( the_thread->Object.id ) ) { 458 the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL; 459 460 _Message_queue_MP_Send_response_packet( 461 MESSAGE_QUEUE_MP_RECEIVE_RESPONSE, 462 id, 463 the_thread 464 ); 465 } 466 } 413 core_status = _CORE_message_queue_Broadcast( 414 &the_message_queue->message_queue, 415 buffer, 416 size, 417 id, 418 _Message_queue_Core_message_queue_mp_support, 419 count 420 ); 421 467 422 _Thread_Enable_dispatch(); 468 *count = number_broadcasted; 469 return RTEMS_SUCCESSFUL; 470 } 471 472 default: 473 return RTEMS_INTERNAL_ERROR; 474 } 423 return 424 _Message_queue_Translate_core_message_queue_return_code( core_status ); 425 426 } 427 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 475 428 } 476 429 … … 485 438 * id - queue id 486 439 * buffer - pointer to message buffer 440 * size - size of message receive 487 441 * option_set - options on receive 488 442 * timeout - number of ticks to wait … … 490 444 * Output parameters: 491 445 * RTEMS_SUCCESSFUL - if successful 492 * error code 446 * error code - if unsuccessful 493 447 */ 494 448 … … 496 450 Objects_Id id, 497 451 void *buffer, 498 unsigned32 *size _p,452 unsigned32 *size, 499 453 unsigned32 option_set, 500 454 rtems_interval timeout … … 503 457 register Message_queue_Control *the_message_queue; 504 458 Objects_Locations location; 459 boolean wait; 505 460 506 461 the_message_queue = _Message_queue_Get( id, &location ); … … 515 470 id, 516 471 buffer, 517 size _p,472 size, 518 473 option_set, 519 474 timeout … … 521 476 522 477 case OBJECTS_LOCAL: 523 if ( ! _Message_queue_Seize(the_message_queue, 524 option_set, 525 buffer, 526 size_p)) 527 { 528 _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout ); 529 } 478 if ( _Options_Is_no_wait( option_set ) ) 479 wait = FALSE; 480 else 481 wait = TRUE; 482 483 _CORE_message_queue_Seize( 484 &the_message_queue->message_queue, 485 the_message_queue->Object.id, 486 buffer, 487 size, 488 wait, 489 timeout 490 ); 530 491 _Thread_Enable_dispatch(); 531 return _Thread_Executing->Wait.return_code; 492 return( _Message_queue_Translate_core_message_queue_return_code( 493 _Thread_Executing->Wait.return_code ) ); 494 532 495 } 533 496 … … 573 536 id, 574 537 0, /* buffer not used */ 575 0, /* size _p*/538 0, /* size */ 576 539 0, /* option_set not used */ 577 540 MPCI_DEFAULT_TIMEOUT … … 579 542 580 543 case OBJECTS_LOCAL: 581 if ( the_message_queue->number_of_pending_messages != 0 ) 582 *count = _Message_queue_Flush_support( the_message_queue ); 583 else 584 *count = 0; 544 *count = _CORE_message_queue_Flush( &the_message_queue->message_queue ); 585 545 _Thread_Enable_dispatch(); 586 546 return RTEMS_SUCCESSFUL; … … 592 552 /*PAGE 593 553 * 594 * _Message_queue_Seize595 *596 * This kernel routine dequeues a message, copies the message buffer to597 * a given destination buffer, and frees the message buffer to the598 * inactive message pool.599 *600 * Input parameters:601 * the_message_queue - pointer to message queue602 * option_set - options on receive603 * the_buffer - pointer to message buffer to be filled604 *605 * Output parameters:606 * TRUE - if message received or RTEMS_NO_WAIT and no message607 * FALSE - if thread is to block608 *609 * NOTE: Dependent on BUFFER_LENGTH610 *611 * INTERRUPT LATENCY:612 * available613 * wait614 */615 616 boolean _Message_queue_Seize(617 Message_queue_Control *the_message_queue,618 rtems_option option_set,619 void *buffer,620 unsigned32 *size_p621 )622 {623 ISR_Level level;624 Message_queue_Buffer_control *the_message;625 Thread_Control *executing;626 627 executing = _Thread_Executing;628 executing->Wait.return_code = RTEMS_SUCCESSFUL;629 _ISR_Disable( level );630 if ( the_message_queue->number_of_pending_messages != 0 ) {631 the_message_queue->number_of_pending_messages -= 1;632 633 the_message = _Message_queue_Get_pending_message( the_message_queue );634 _ISR_Enable( level );635 *size_p = the_message->Contents.size;636 _Message_queue_Copy_buffer( the_message->Contents.buffer, buffer, *size_p );637 _Message_queue_Free_message_buffer(the_message_queue, the_message );638 return( TRUE );639 }640 641 if ( _Options_Is_no_wait( option_set ) ) {642 _ISR_Enable( level );643 executing->Wait.return_code = RTEMS_UNSATISFIED;644 return( TRUE );645 }646 647 the_message_queue->Wait_queue.sync = TRUE;648 executing->Wait.queue = &the_message_queue->Wait_queue;649 executing->Wait.id = the_message_queue->Object.id;650 executing->Wait.option = option_set;651 executing->Wait.return_argument = (void *)buffer;652 executing->Wait.return_argument_1 = (void *)size_p;653 _ISR_Enable( level );654 return FALSE;655 }656 657 /*PAGE658 *659 * _Message_queue_Flush_support660 *661 * This message manager routine removes all messages from a message queue662 * and returns them to the inactive message pool.663 *664 * Input parameters:665 * the_message_queue - pointer to message queue666 *667 * Output parameters:668 * returns - number of messages placed on inactive chain669 *670 * INTERRUPT LATENCY:671 * only case672 */673 674 unsigned32 _Message_queue_Flush_support(675 Message_queue_Control *the_message_queue676 )677 {678 ISR_Level level;679 Chain_Node *inactive_first;680 Chain_Node *message_queue_first;681 Chain_Node *message_queue_last;682 unsigned32 count;683 684 _ISR_Disable( level );685 inactive_first = the_message_queue->Inactive_messages.first;686 message_queue_first = the_message_queue->Pending_messages.first;687 message_queue_last = the_message_queue->Pending_messages.last;688 689 the_message_queue->Inactive_messages.first = message_queue_first;690 message_queue_last->next = inactive_first;691 inactive_first->previous = message_queue_last;692 message_queue_first->previous =693 _Chain_Head( &the_message_queue->Inactive_messages );694 695 _Chain_Initialize_empty( &the_message_queue->Pending_messages );696 697 count = the_message_queue->number_of_pending_messages;698 the_message_queue->number_of_pending_messages = 0;699 _ISR_Enable( level );700 return count;701 }702 703 /*PAGE704 *705 554 * _Message_queue_Submit 706 555 * 707 * This routine implements the directives q_send and q_urgent. It708 * processes a message that is to be submitted to the designated709 * message queue. The message will either be processed as a send710 * send message which it will be inserted at the rear of the queue711 * or it will be processed as an urgent message which will be inserted712 * at the front of the queue.556 * This routine implements the directives rtems_message_queue_send 557 * and rtems_message_queue_urgent. It processes a message that is 558 * to be submitted to the designated message queue. The message will 559 * either be processed as a send send message which it will be inserted 560 * at the rear of the queue or it will be processed as an urgent message 561 * which will be inserted at the front of the queue. 713 562 * 714 563 * Input parameters: … … 730 579 ) 731 580 { 732 register Message_queue_Control *the_message_queue; 733 Objects_Locations location; 734 Thread_Control *the_thread; 735 Message_queue_Buffer_control *the_message; 581 register Message_queue_Control *the_message_queue; 582 Objects_Locations location; 583 CORE_message_queue_Status core_status; 736 584 737 585 the_message_queue = _Message_queue_Get( id, &location ); … … 767 615 768 616 case OBJECTS_LOCAL: 769 if (size > the_message_queue->maximum_message_size)770 {771 _Thread_Enable_dispatch();772 return RTEMS_INVALID_SIZE;773 }774 775 /*776 * Is there a thread currently waiting on this message queue?777 */778 779 the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );780 if ( the_thread )781 {782 _Message_queue_Copy_buffer(783 buffer,784 the_thread->Wait.return_argument,785 size786 );787 *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 = size;788 789 if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {790 the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;791 792 _Message_queue_MP_Send_response_packet(793 MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,794 id,795 the_thread796 );797 798 }799 _Thread_Enable_dispatch();800 return RTEMS_SUCCESSFUL;801 }802 803 /*804 * No one waiting on this one currently.805 * Allocate a message buffer and store it away806 */807 808 if ( the_message_queue->number_of_pending_messages ==809 the_message_queue->maximum_pending_messages ) {810 _Thread_Enable_dispatch();811 return RTEMS_TOO_MANY;812 }813 814 the_message = _Message_queue_Allocate_message_buffer(the_message_queue);815 if ( the_message == 0) {816 _Thread_Enable_dispatch();817 return RTEMS_UNSATISFIED;818 }819 820 _Message_queue_Copy_buffer( buffer, the_message->Contents.buffer, size );821 the_message->Contents.size = size;822 823 the_message_queue->number_of_pending_messages += 1;824 825 617 switch ( submit_type ) { 826 618 case MESSAGE_QUEUE_SEND_REQUEST: 827 _Message_queue_Append( the_message_queue, the_message ); 619 core_status = _CORE_message_queue_Send( 620 &the_message_queue->message_queue, 621 buffer, 622 size, 623 id, 624 _Message_queue_Core_message_queue_mp_support 625 ); 828 626 break; 829 627 case MESSAGE_QUEUE_URGENT_REQUEST: 830 _Message_queue_Prepend( the_message_queue, the_message ); 628 core_status = _CORE_message_queue_Urgent( 629 &the_message_queue->message_queue, 630 buffer, 631 size, 632 id, 633 _Message_queue_Core_message_queue_mp_support 634 ); 831 635 break; 636 default: 637 core_status = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; 638 return RTEMS_INTERNAL_ERROR; /* should never get here */ 832 639 } 833 640 834 641 _Thread_Enable_dispatch(); 642 return _Message_queue_Translate_core_message_queue_return_code( 643 core_status ); 644 645 } 646 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 647 } 648 649 /*PAGE 650 * 651 * _Message_queue_Translate_core_message_queue_return_code 652 * 653 * Input parameters: 654 * the_message_queue_status - message_queue status code to translate 655 * 656 * Output parameters: 657 * rtems status code - translated RTEMS status code 658 * 659 */ 660 661 rtems_status_code _Message_queue_Translate_core_message_queue_return_code ( 662 unsigned32 the_message_queue_status 663 ) 664 { 665 switch ( the_message_queue_status ) { 666 case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL: 835 667 return RTEMS_SUCCESSFUL; 836 837 default: 838 return RTEMS_INTERNAL_ERROR; /* And they were such nice boys, too! */ 839 } 840 } 668 case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE: 669 return RTEMS_INVALID_SIZE; 670 case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY: 671 return RTEMS_TOO_MANY; 672 case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED: 673 return RTEMS_UNSATISFIED; 674 case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT: 675 return RTEMS_UNSATISFIED; 676 case CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED: 677 return RTEMS_OBJECT_WAS_DELETED; 678 case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT: 679 return RTEMS_TIMEOUT; 680 case THREAD_STATUS_PROXY_BLOCKING: 681 return THREAD_STATUS_PROXY_BLOCKING; 682 } 683 _Internal_error_Occurred( /* XXX */ 684 INTERNAL_ERROR_RTEMS_API, 685 TRUE, 686 the_message_queue_status 687 ); 688 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 689 } 690 691 /*PAGE 692 * 693 * _Message_queue_Core_message_queue_mp_support 694 * 695 * Input parameters: 696 * the_thread - the remote thread the message was submitted to 697 * id - id of the message queue 698 * 699 * Output parameters: NONE 700 */ 701 702 void _Message_queue_Core_message_queue_mp_support ( 703 Thread_Control *the_thread, 704 Objects_Id id 705 ) 706 { 707 the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL; 708 709 _Message_queue_MP_Send_response_packet( 710 MESSAGE_QUEUE_MP_RECEIVE_RESPONSE, 711 id, 712 the_thread 713 ); 714 } -
cpukit/rtems/src/msgmp.c
rb3ac6a8d r3652ad35 134 134 if (buffer) { 135 135 the_packet->Buffer.size = *size_p; 136 _Message_queue_Copy_buffer(buffer, 137 the_packet->Buffer.buffer, 138 *size_p); 136 _CORE_message_queue_Copy_buffer( 137 buffer, 138 the_packet->Buffer.buffer, 139 *size_p 140 ); 139 141 } 140 142 … … 311 313 the_packet->size; 312 314 313 _ Message_queue_Copy_buffer(315 _CORE_message_queue_Copy_buffer( 314 316 the_packet->Buffer.buffer, 315 317 the_thread->Wait.return_argument, -
cpukit/rtems/src/sem.c
rb3ac6a8d r3652ad35 117 117 118 118 if ( !rtems_is_name_valid( name ) ) 119 return ( RTEMS_INVALID_NAME );119 return RTEMS_INVALID_NAME; 120 120 121 121 if ( _Attributes_Is_global( attribute_set ) ) { 122 122 123 123 if ( !_System_state_Is_multiprocessing ) 124 return ( RTEMS_MP_NOT_CONFIGURED );124 return RTEMS_MP_NOT_CONFIGURED; 125 125 126 126 if ( _Attributes_Is_inherit_priority( attribute_set ) ) 127 return ( RTEMS_NOT_DEFINED );127 return RTEMS_NOT_DEFINED; 128 128 129 129 } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { … … 131 131 if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && 132 132 _Attributes_Is_priority( attribute_set ) ) ) 133 return ( RTEMS_NOT_DEFINED );133 return RTEMS_NOT_DEFINED; 134 134 135 135 } 136 136 137 137 if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) 138 return ( RTEMS_INVALID_NUMBER );138 return RTEMS_INVALID_NUMBER; 139 139 140 140 _Thread_Disable_dispatch(); /* prevents deletion */ … … 144 144 if ( !the_semaphore ) { 145 145 _Thread_Enable_dispatch(); 146 return ( RTEMS_TOO_MANY );146 return RTEMS_TOO_MANY; 147 147 } 148 148 … … 152 152 _Semaphore_Free( the_semaphore ); 153 153 _Thread_Enable_dispatch(); 154 return ( RTEMS_TOO_MANY );154 return RTEMS_TOO_MANY; 155 155 } 156 156 … … 211 211 ); 212 212 _Thread_Enable_dispatch(); 213 return ( RTEMS_SUCCESSFUL );213 return RTEMS_SUCCESSFUL; 214 214 } 215 215 … … 271 271 switch ( location ) { 272 272 case OBJECTS_ERROR: 273 return ( RTEMS_INVALID_ID );273 return RTEMS_INVALID_ID; 274 274 case OBJECTS_REMOTE: 275 275 _Thread_Dispatch(); 276 return ( RTEMS_ILLEGAL_ON_REMOTE_OBJECT );276 return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; 277 277 case OBJECTS_LOCAL: 278 278 if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) { 279 279 if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) { 280 280 _Thread_Enable_dispatch(); 281 return ( RTEMS_RESOURCE_IN_USE );281 return RTEMS_RESOURCE_IN_USE; 282 282 } 283 283 else … … 311 311 } 312 312 _Thread_Enable_dispatch(); 313 return ( RTEMS_SUCCESSFUL );314 } 315 316 return ( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */313 return RTEMS_SUCCESSFUL; 314 } 315 316 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 317 317 } 318 318 … … 346 346 switch ( location ) { 347 347 case OBJECTS_ERROR: 348 return ( RTEMS_INVALID_ID );348 return RTEMS_INVALID_ID; 349 349 case OBJECTS_REMOTE: 350 350 return _Semaphore_MP_Send_request_packet( … … 368 368 ); 369 369 _Thread_Enable_dispatch(); 370 return (_Semaphore_Translate_core_mutex_return_code(371 _Thread_Executing->Wait.return_code ) );370 return _Semaphore_Translate_core_mutex_return_code( 371 _Thread_Executing->Wait.return_code ); 372 372 } else { 373 373 _CORE_semaphore_Seize( … … 378 378 ); 379 379 _Thread_Enable_dispatch(); 380 return (_Semaphore_Translate_core_semaphore_return_code(381 _Thread_Executing->Wait.return_code ) );380 return _Semaphore_Translate_core_semaphore_return_code( 381 _Thread_Executing->Wait.return_code ); 382 382 } 383 383 } 384 384 385 return ( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */385 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 386 386 } 387 387 … … 412 412 switch ( location ) { 413 413 case OBJECTS_ERROR: 414 return ( RTEMS_INVALID_ID );414 return RTEMS_INVALID_ID; 415 415 case OBJECTS_REMOTE: 416 return( 417 _Semaphore_MP_Send_request_packet( 418 SEMAPHORE_MP_RELEASE_REQUEST, 419 id, 420 0, /* Not used */ 421 MPCI_DEFAULT_TIMEOUT 422 ) 416 return _Semaphore_MP_Send_request_packet( 417 SEMAPHORE_MP_RELEASE_REQUEST, 418 id, 419 0, /* Not used */ 420 MPCI_DEFAULT_TIMEOUT 423 421 ); 424 422 case OBJECTS_LOCAL: … … 430 428 ); 431 429 _Thread_Enable_dispatch(); 432 return ( _Semaphore_Translate_core_mutex_return_code( mutex_status ));430 return _Semaphore_Translate_core_mutex_return_code( mutex_status ); 433 431 } 434 432 else … … 439 437 ); 440 438 _Thread_Enable_dispatch(); 441 return (442 _Semaphore_Translate_core_semaphore_return_code( semaphore_status ) );443 } 444 445 return ( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */439 return 440 _Semaphore_Translate_core_semaphore_return_code( semaphore_status ); 441 } 442 443 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 446 444 } 447 445 … … 464 462 switch ( the_mutex_status ) { 465 463 case CORE_MUTEX_STATUS_SUCCESSFUL: 466 return ( RTEMS_SUCCESSFUL );464 return RTEMS_SUCCESSFUL; 467 465 case CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT: 468 return ( RTEMS_UNSATISFIED );466 return RTEMS_UNSATISFIED; 469 467 case CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED: 470 return ( RTEMS_INTERNAL_ERROR );468 return RTEMS_INTERNAL_ERROR; 471 469 case CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE: 472 return ( RTEMS_NOT_OWNER_OF_RESOURCE );470 return RTEMS_NOT_OWNER_OF_RESOURCE; 473 471 case CORE_MUTEX_WAS_DELETED: 474 return ( RTEMS_OBJECT_WAS_DELETED );472 return RTEMS_OBJECT_WAS_DELETED; 475 473 case CORE_MUTEX_TIMEOUT: 476 return ( RTEMS_TIMEOUT );474 return RTEMS_TIMEOUT; 477 475 case THREAD_STATUS_PROXY_BLOCKING: 478 return( THREAD_STATUS_PROXY_BLOCKING ); 479 } 480 _Internal_error_Occurred( 481 INTERNAL_ERROR_RTEMS_API, 482 TRUE, 483 the_mutex_status 484 ); 485 return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */ 476 return THREAD_STATUS_PROXY_BLOCKING; 477 } 478 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 486 479 } 487 480 … … 504 497 switch ( the_semaphore_status ) { 505 498 case CORE_SEMAPHORE_STATUS_SUCCESSFUL: 506 return ( RTEMS_SUCCESSFUL );499 return RTEMS_SUCCESSFUL; 507 500 case CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT: 508 return ( RTEMS_UNSATISFIED );501 return RTEMS_UNSATISFIED; 509 502 case CORE_SEMAPHORE_WAS_DELETED: 510 return ( RTEMS_OBJECT_WAS_DELETED );503 return RTEMS_OBJECT_WAS_DELETED; 511 504 case CORE_SEMAPHORE_TIMEOUT: 512 return ( RTEMS_TIMEOUT );505 return RTEMS_TIMEOUT; 513 506 case THREAD_STATUS_PROXY_BLOCKING: 514 return( THREAD_STATUS_PROXY_BLOCKING ); 515 } 516 _Internal_error_Occurred( 517 INTERNAL_ERROR_RTEMS_API, 518 TRUE, 519 the_semaphore_status 520 ); 521 return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */ 522 return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */ 507 return THREAD_STATUS_PROXY_BLOCKING; 508 } 509 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 523 510 } 524 511 -
cpukit/rtems/src/tasks.c
rb3ac6a8d r3652ad35 115 115 116 116 _ISR_Disable( level ); 117 118 signal_set = asr->signals_posted; 119 120 if ( signal_set ) { 121 /* if ( _ASR_Are_signals_pending( asr ) ) { 122 123 signal_set = asr->signals_posted; */ 117 signal_set = asr->signals_posted; 124 118 asr->signals_posted = 0; 125 _ISR_Enable( level ); 126 127 asr->nest_level += 1; 128 rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode ); 129 130 (*asr->handler)( signal_set ); 131 132 asr->nest_level -= 1; 133 rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode ); 134 } 135 else 136 _ISR_Enable( level ); 119 _ISR_Enable( level ); 120 121 122 if ( !signal_set ) /* similar to _ASR_Are_signals_pending( asr ) */ 123 return; 124 125 asr->nest_level += 1; 126 rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode ); 127 128 (*asr->handler)( signal_set ); 129 130 asr->nest_level -= 1; 131 rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode ); 137 132 138 133 }
Note: See TracChangeset
for help on using the changeset viewer.