1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ClassicMessageQueueImpl |
---|
5 | * |
---|
6 | * @brief Classic Message Queue Manager Implementation |
---|
7 | */ |
---|
8 | |
---|
9 | /* COPYRIGHT (c) 1989-2008. |
---|
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.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_RTEMS_MESSAGEIMPL_H |
---|
18 | #define _RTEMS_RTEMS_MESSAGEIMPL_H |
---|
19 | |
---|
20 | #include <rtems/rtems/messagedata.h> |
---|
21 | #include <rtems/score/objectimpl.h> |
---|
22 | #include <rtems/score/coremsgimpl.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup ClassicMessageQueueImpl Classic Message Queue Implementation |
---|
30 | * |
---|
31 | * @ingroup ClassicMessageQueue |
---|
32 | * |
---|
33 | * @{ |
---|
34 | */ |
---|
35 | |
---|
36 | /** |
---|
37 | * The following enumerated type details the modes in which a message |
---|
38 | * may be submitted to a message queue. The message may be posted |
---|
39 | * in a send or urgent fashion. |
---|
40 | */ |
---|
41 | typedef enum { |
---|
42 | /** |
---|
43 | * This value indicates the user wants to send the message using the |
---|
44 | * normal message insertion protocol (FIFO or priority). |
---|
45 | */ |
---|
46 | MESSAGE_QUEUE_SEND_REQUEST = 0, |
---|
47 | /** |
---|
48 | * This value indicates the user considers the message to be urgent |
---|
49 | * and wants it inserted at the head of the pending message queue. |
---|
50 | */ |
---|
51 | MESSAGE_QUEUE_URGENT_REQUEST = 1 |
---|
52 | } Message_queue_Submit_types; |
---|
53 | |
---|
54 | /** |
---|
55 | * The following defines the information control block used to |
---|
56 | * manage this class of objects. |
---|
57 | */ |
---|
58 | extern Objects_Information _Message_queue_Information; |
---|
59 | |
---|
60 | /** |
---|
61 | * @brief Message_queue_Submit |
---|
62 | * |
---|
63 | * This routine implements the directives rtems_message_queue_send |
---|
64 | * and rtems_message_queue_urgent. It processes a message that is |
---|
65 | * to be submitted to the designated message queue. The message will |
---|
66 | * either be processed as a send send message which it will be inserted |
---|
67 | * at the rear of the queue or it will be processed as an urgent message |
---|
68 | * which will be inserted at the front of the queue. |
---|
69 | */ |
---|
70 | rtems_status_code _Message_queue_Submit( |
---|
71 | rtems_id id, |
---|
72 | const void *buffer, |
---|
73 | size_t size, |
---|
74 | Message_queue_Submit_types submit_type |
---|
75 | ); |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief Deallocates a message queue control block into |
---|
79 | * the inactive chain of free message queue control blocks. |
---|
80 | * |
---|
81 | * This routine deallocates a message queue control block into |
---|
82 | * the inactive chain of free message queue control blocks. |
---|
83 | */ |
---|
84 | RTEMS_INLINE_ROUTINE void _Message_queue_Free ( |
---|
85 | Message_queue_Control *the_message_queue |
---|
86 | ) |
---|
87 | { |
---|
88 | _Objects_Free( &_Message_queue_Information, &the_message_queue->Object ); |
---|
89 | } |
---|
90 | |
---|
91 | RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get( |
---|
92 | Objects_Id id, |
---|
93 | Thread_queue_Context *queue_context |
---|
94 | ) |
---|
95 | { |
---|
96 | _Thread_queue_Context_initialize( queue_context ); |
---|
97 | return (Message_queue_Control *) _Objects_Get( |
---|
98 | id, |
---|
99 | &queue_context->Lock_context.Lock_context, |
---|
100 | &_Message_queue_Information |
---|
101 | ); |
---|
102 | } |
---|
103 | |
---|
104 | RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void ) |
---|
105 | { |
---|
106 | return (Message_queue_Control *) |
---|
107 | _Objects_Allocate( &_Message_queue_Information ); |
---|
108 | } |
---|
109 | |
---|
110 | /**@}*/ |
---|
111 | |
---|
112 | #ifdef __cplusplus |
---|
113 | } |
---|
114 | #endif |
---|
115 | |
---|
116 | #if defined(RTEMS_MULTIPROCESSING) |
---|
117 | #include <rtems/rtems/msgmp.h> |
---|
118 | #endif |
---|
119 | |
---|
120 | #endif |
---|
121 | /* end of include file */ |
---|