[1e1b3e00] | 1 | /* |
---|
| 2 | * Message Queue Manager |
---|
| 3 | * |
---|
| 4 | * |
---|
[08311cc3] | 5 | * COPYRIGHT (c) 1989-1999. |
---|
[1e1b3e00] | 6 | * On-Line Applications Research Corporation (OAR). |
---|
| 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in the file LICENSE in this distribution or at |
---|
[277cc95] | 10 | * http://www.rtems.com/license/LICENSE. |
---|
[1e1b3e00] | 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
[1095ec1] | 15 | #if HAVE_CONFIG_H |
---|
| 16 | #include "config.h" |
---|
| 17 | #endif |
---|
| 18 | |
---|
[1e1b3e00] | 19 | #include <rtems/system.h> |
---|
| 20 | #include <rtems/score/sysstate.h> |
---|
| 21 | #include <rtems/score/chain.h> |
---|
| 22 | #include <rtems/score/isr.h> |
---|
| 23 | #include <rtems/score/coremsg.h> |
---|
| 24 | #include <rtems/score/object.h> |
---|
| 25 | #include <rtems/score/states.h> |
---|
| 26 | #include <rtems/score/thread.h> |
---|
| 27 | #include <rtems/score/wkspace.h> |
---|
| 28 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 29 | #include <rtems/score/mpci.h> |
---|
| 30 | #endif |
---|
| 31 | #include <rtems/rtems/status.h> |
---|
| 32 | #include <rtems/rtems/attr.h> |
---|
| 33 | #include <rtems/rtems/message.h> |
---|
| 34 | #include <rtems/rtems/options.h> |
---|
| 35 | #include <rtems/rtems/support.h> |
---|
| 36 | |
---|
| 37 | /*PAGE |
---|
| 38 | * |
---|
| 39 | * rtems_message_queue_broadcast |
---|
| 40 | * |
---|
| 41 | * This directive sends a message for every thread waiting on the queue |
---|
| 42 | * designated by id. |
---|
| 43 | * |
---|
| 44 | * Input parameters: |
---|
| 45 | * id - pointer to message queue |
---|
| 46 | * buffer - pointer to message buffer |
---|
| 47 | * size - size of message to broadcast |
---|
| 48 | * count - pointer to area to store number of threads made ready |
---|
| 49 | * |
---|
| 50 | * Output parameters: |
---|
| 51 | * count - number of threads made ready |
---|
| 52 | * RTEMS_SUCCESSFUL - if successful |
---|
| 53 | * error code - if unsuccessful |
---|
| 54 | */ |
---|
| 55 | |
---|
| 56 | rtems_status_code rtems_message_queue_broadcast( |
---|
| 57 | Objects_Id id, |
---|
| 58 | void *buffer, |
---|
[1d496f6] | 59 | uint32_t size, |
---|
| 60 | uint32_t *count |
---|
[1e1b3e00] | 61 | ) |
---|
| 62 | { |
---|
| 63 | register Message_queue_Control *the_message_queue; |
---|
| 64 | Objects_Locations location; |
---|
| 65 | CORE_message_queue_Status core_status; |
---|
| 66 | |
---|
[e980b219] | 67 | if ( !buffer ) |
---|
| 68 | return RTEMS_INVALID_ADDRESS; |
---|
| 69 | |
---|
| 70 | if ( !count ) |
---|
| 71 | return RTEMS_INVALID_ADDRESS; |
---|
| 72 | |
---|
[1e1b3e00] | 73 | the_message_queue = _Message_queue_Get( id, &location ); |
---|
| 74 | switch ( location ) { |
---|
| 75 | case OBJECTS_REMOTE: |
---|
| 76 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 77 | _Thread_Executing->Wait.return_argument = count; |
---|
| 78 | |
---|
| 79 | return |
---|
| 80 | _Message_queue_MP_Send_request_packet( |
---|
| 81 | MESSAGE_QUEUE_MP_BROADCAST_REQUEST, |
---|
| 82 | id, |
---|
| 83 | buffer, |
---|
| 84 | &size, |
---|
| 85 | 0, /* option_set not used */ |
---|
| 86 | MPCI_DEFAULT_TIMEOUT |
---|
| 87 | ); |
---|
| 88 | #endif |
---|
| 89 | |
---|
| 90 | case OBJECTS_ERROR: |
---|
| 91 | return RTEMS_INVALID_ID; |
---|
| 92 | |
---|
| 93 | case OBJECTS_LOCAL: |
---|
| 94 | core_status = _CORE_message_queue_Broadcast( |
---|
| 95 | &the_message_queue->message_queue, |
---|
| 96 | buffer, |
---|
| 97 | size, |
---|
| 98 | id, |
---|
| 99 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 100 | _Message_queue_Core_message_queue_mp_support, |
---|
| 101 | #else |
---|
| 102 | NULL, |
---|
| 103 | #endif |
---|
| 104 | count |
---|
| 105 | ); |
---|
[50f32b11] | 106 | |
---|
[1e1b3e00] | 107 | _Thread_Enable_dispatch(); |
---|
[50f32b11] | 108 | return |
---|
[1e1b3e00] | 109 | _Message_queue_Translate_core_message_queue_return_code( core_status ); |
---|
| 110 | |
---|
| 111 | } |
---|
| 112 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
---|
| 113 | } |
---|