1 | /* |
---|
2 | * Message Queue Manager - rtems_message_queue_send |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <rtems/system.h> |
---|
19 | #include <rtems/score/sysstate.h> |
---|
20 | #include <rtems/score/chain.h> |
---|
21 | #include <rtems/score/isr.h> |
---|
22 | #include <rtems/score/coremsg.h> |
---|
23 | #include <rtems/score/object.h> |
---|
24 | #include <rtems/score/states.h> |
---|
25 | #include <rtems/score/thread.h> |
---|
26 | #include <rtems/score/wkspace.h> |
---|
27 | #if defined(RTEMS_MULTIPROCESSING) |
---|
28 | #include <rtems/score/mpci.h> |
---|
29 | #endif |
---|
30 | #include <rtems/rtems/status.h> |
---|
31 | #include <rtems/rtems/attr.h> |
---|
32 | #include <rtems/rtems/message.h> |
---|
33 | #include <rtems/rtems/options.h> |
---|
34 | #include <rtems/rtems/support.h> |
---|
35 | |
---|
36 | /* |
---|
37 | * |
---|
38 | * rtems_message_queue_send |
---|
39 | * |
---|
40 | * This routine implements the directive rtems_message_queue_send. It sends a |
---|
41 | * message to the specified message queue. |
---|
42 | * |
---|
43 | * Input parameters: |
---|
44 | * id - pointer to message queue |
---|
45 | * buffer - pointer to message buffer |
---|
46 | * size - size of message to send |
---|
47 | * |
---|
48 | * Output parameters: |
---|
49 | * RTEMS_SUCCESSFUL - if successful |
---|
50 | * error code - if unsuccessful |
---|
51 | */ |
---|
52 | |
---|
53 | #if defined(RTEMS_MULTIPROCESSING) |
---|
54 | #define MESSAGE_QUEUE_MP_HANDLER _Message_queue_Core_message_queue_mp_support |
---|
55 | #else |
---|
56 | #define MESSAGE_QUEUE_MP_HANDLER NULL |
---|
57 | #endif |
---|
58 | |
---|
59 | rtems_status_code rtems_message_queue_send( |
---|
60 | Objects_Id id, |
---|
61 | const void *buffer, |
---|
62 | size_t size |
---|
63 | ) |
---|
64 | { |
---|
65 | register Message_queue_Control *the_message_queue; |
---|
66 | Objects_Locations location; |
---|
67 | CORE_message_queue_Status status; |
---|
68 | |
---|
69 | if ( !buffer ) |
---|
70 | return RTEMS_INVALID_ADDRESS; |
---|
71 | |
---|
72 | the_message_queue = _Message_queue_Get( id, &location ); |
---|
73 | switch ( location ) { |
---|
74 | |
---|
75 | case OBJECTS_LOCAL: |
---|
76 | status = _CORE_message_queue_Send( |
---|
77 | &the_message_queue->message_queue, |
---|
78 | buffer, |
---|
79 | size, |
---|
80 | id, |
---|
81 | MESSAGE_QUEUE_MP_HANDLER, |
---|
82 | false, /* sender does not block */ |
---|
83 | 0 /* no timeout */ |
---|
84 | ); |
---|
85 | |
---|
86 | _Thread_Enable_dispatch(); |
---|
87 | |
---|
88 | /* |
---|
89 | * Since this API does not allow for blocking sends, we can directly |
---|
90 | * return the returned status. |
---|
91 | */ |
---|
92 | |
---|
93 | return _Message_queue_Translate_core_message_queue_return_code(status); |
---|
94 | |
---|
95 | #if defined(RTEMS_MULTIPROCESSING) |
---|
96 | case OBJECTS_REMOTE: |
---|
97 | return _Message_queue_MP_Send_request_packet( |
---|
98 | MESSAGE_QUEUE_MP_SEND_REQUEST, |
---|
99 | id, |
---|
100 | buffer, |
---|
101 | &size, |
---|
102 | 0, /* option_set */ |
---|
103 | MPCI_DEFAULT_TIMEOUT |
---|
104 | ); |
---|
105 | break; |
---|
106 | #endif |
---|
107 | |
---|
108 | case OBJECTS_ERROR: |
---|
109 | break; |
---|
110 | } |
---|
111 | return RTEMS_INVALID_ID; |
---|
112 | } |
---|