1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Urgent Message Queue |
---|
5 | * @ingroup ClassicMessageQueue |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
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 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/sysstate.h> |
---|
23 | #include <rtems/score/chain.h> |
---|
24 | #include <rtems/score/isr.h> |
---|
25 | #include <rtems/score/coremsgimpl.h> |
---|
26 | #include <rtems/score/object.h> |
---|
27 | #include <rtems/score/states.h> |
---|
28 | #include <rtems/score/thread.h> |
---|
29 | #include <rtems/score/wkspace.h> |
---|
30 | #if defined(RTEMS_MULTIPROCESSING) |
---|
31 | #include <rtems/score/mpci.h> |
---|
32 | #endif |
---|
33 | #include <rtems/rtems/status.h> |
---|
34 | #include <rtems/rtems/attrimpl.h> |
---|
35 | #include <rtems/rtems/messageimpl.h> |
---|
36 | #include <rtems/rtems/options.h> |
---|
37 | #include <rtems/rtems/support.h> |
---|
38 | |
---|
39 | #if defined(RTEMS_MULTIPROCESSING) |
---|
40 | #define MESSAGE_QUEUE_MP_HANDLER _Message_queue_Core_message_queue_mp_support |
---|
41 | #else |
---|
42 | #define MESSAGE_QUEUE_MP_HANDLER NULL |
---|
43 | #endif |
---|
44 | |
---|
45 | rtems_status_code rtems_message_queue_urgent( |
---|
46 | rtems_id id, |
---|
47 | const void *buffer, |
---|
48 | size_t size |
---|
49 | ) |
---|
50 | { |
---|
51 | register Message_queue_Control *the_message_queue; |
---|
52 | Objects_Locations location; |
---|
53 | CORE_message_queue_Status status; |
---|
54 | |
---|
55 | if ( !buffer ) |
---|
56 | return RTEMS_INVALID_ADDRESS; |
---|
57 | |
---|
58 | the_message_queue = _Message_queue_Get( id, &location ); |
---|
59 | switch ( location ) { |
---|
60 | |
---|
61 | case OBJECTS_LOCAL: |
---|
62 | status = _CORE_message_queue_Urgent( |
---|
63 | &the_message_queue->message_queue, |
---|
64 | buffer, |
---|
65 | size, |
---|
66 | id, |
---|
67 | MESSAGE_QUEUE_MP_HANDLER, |
---|
68 | false, /* sender does not block */ |
---|
69 | 0 /* no timeout */ |
---|
70 | ); |
---|
71 | _Objects_Put( &the_message_queue->Object ); |
---|
72 | |
---|
73 | /* |
---|
74 | * Since this API does not allow for blocking sends, we can directly |
---|
75 | * return the returned status. |
---|
76 | */ |
---|
77 | |
---|
78 | return _Message_queue_Translate_core_message_queue_return_code(status); |
---|
79 | |
---|
80 | #if defined(RTEMS_MULTIPROCESSING) |
---|
81 | case OBJECTS_REMOTE: |
---|
82 | return _Message_queue_MP_Send_request_packet( |
---|
83 | MESSAGE_QUEUE_MP_URGENT_REQUEST, |
---|
84 | id, |
---|
85 | buffer, |
---|
86 | &size, |
---|
87 | 0, /* option_set */ |
---|
88 | MPCI_DEFAULT_TIMEOUT |
---|
89 | ); |
---|
90 | #endif |
---|
91 | |
---|
92 | case OBJECTS_ERROR: |
---|
93 | break; |
---|
94 | } |
---|
95 | |
---|
96 | return RTEMS_INVALID_ID; |
---|
97 | } |
---|