1 | /** |
---|
2 | * @file rtems/score/coremsg.h |
---|
3 | * |
---|
4 | * @brief Constants and Structures Associated with the Message Queue Handler. |
---|
5 | * |
---|
6 | * This include file contains all the constants and structures associated |
---|
7 | * with the Message queue Handler. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2009. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_COREMSG_H |
---|
20 | #define _RTEMS_SCORE_COREMSG_H |
---|
21 | |
---|
22 | #include <rtems/score/chain.h> |
---|
23 | #include <rtems/score/isrlock.h> |
---|
24 | #include <rtems/score/threadq.h> |
---|
25 | #include <rtems/score/watchdog.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | |
---|
31 | /** |
---|
32 | * @defgroup ScoreMessageQueue Message Queue Handler |
---|
33 | * |
---|
34 | * @ingroup Score |
---|
35 | * |
---|
36 | * This handler encapsulates functionality which provides the foundation |
---|
37 | * Message Queue services used in all of the APIs supported by RTEMS. |
---|
38 | */ |
---|
39 | /**@{*/ |
---|
40 | |
---|
41 | #if defined(RTEMS_POSIX_API) |
---|
42 | /** |
---|
43 | * This macro is defined when an API is enabled that requires that the |
---|
44 | * Message Queue Handler include support for priority based enqueuing |
---|
45 | * of messages. |
---|
46 | */ |
---|
47 | #define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY |
---|
48 | #endif |
---|
49 | |
---|
50 | #if defined(RTEMS_POSIX_API) |
---|
51 | /** |
---|
52 | * This macro is defined when an API is enabled that requires that the |
---|
53 | * Message Queue Handler include support for notification of enqueuing |
---|
54 | * a message. |
---|
55 | */ |
---|
56 | #define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION |
---|
57 | #endif |
---|
58 | |
---|
59 | #if defined(RTEMS_POSIX_API) |
---|
60 | /** |
---|
61 | * This macro is defined when an API is enabled that requires the |
---|
62 | * Message Queue Handler include support for blocking send operations. |
---|
63 | */ |
---|
64 | #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND |
---|
65 | #endif |
---|
66 | |
---|
67 | typedef struct CORE_message_queue_Control CORE_message_queue_Control; |
---|
68 | |
---|
69 | /** |
---|
70 | * @brief Data types needed to manipulate the contents of message buffers. |
---|
71 | * |
---|
72 | * The following defines the data types needed to manipulate |
---|
73 | * the contents of message buffers. |
---|
74 | * |
---|
75 | * @note The buffer field is normally longer than a single uint32_t |
---|
76 | * but since messages are variable length we just make a ptr to 1. |
---|
77 | */ |
---|
78 | typedef struct { |
---|
79 | /** This field is the size of this message. */ |
---|
80 | size_t size; |
---|
81 | /** This field contains the actual message. */ |
---|
82 | uint32_t buffer[1]; |
---|
83 | } CORE_message_queue_Buffer; |
---|
84 | |
---|
85 | /** |
---|
86 | * @brief The organization of a message buffer. |
---|
87 | * |
---|
88 | * The following records define the organization of a message |
---|
89 | * buffer. |
---|
90 | */ |
---|
91 | typedef struct { |
---|
92 | /** This element allows this structure to be placed on chains. */ |
---|
93 | Chain_Node Node; |
---|
94 | #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) |
---|
95 | /** This field is the priority of this message. */ |
---|
96 | int priority; |
---|
97 | #endif |
---|
98 | /** This field points to the contents of the message. */ |
---|
99 | CORE_message_queue_Buffer Contents; |
---|
100 | } CORE_message_queue_Buffer_control; |
---|
101 | |
---|
102 | /** |
---|
103 | * @brief The possible blocking disciplines for a message queue. |
---|
104 | * |
---|
105 | * This enumerated types defines the possible blocking disciplines |
---|
106 | * for a message queue. |
---|
107 | */ |
---|
108 | typedef enum { |
---|
109 | /** This value indicates that blocking tasks are in FIFO order. */ |
---|
110 | CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO, |
---|
111 | /** This value indicates that blocking tasks are in priority order. */ |
---|
112 | CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY |
---|
113 | } CORE_message_queue_Disciplines; |
---|
114 | |
---|
115 | #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) |
---|
116 | /** |
---|
117 | * @brief Type for a notification handler. |
---|
118 | * |
---|
119 | * The following defines the type for a Notification handler. A |
---|
120 | * notification handler is invoked when the message queue makes a |
---|
121 | * 0->1 transition on pending messages. |
---|
122 | */ |
---|
123 | typedef void (*CORE_message_queue_Notify_Handler)( |
---|
124 | CORE_message_queue_Control *, |
---|
125 | Thread_queue_Context * |
---|
126 | ); |
---|
127 | #endif |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief Control block used to manage each message queue. |
---|
131 | * |
---|
132 | * The following defines the control block used to manage each |
---|
133 | * Message Queue. |
---|
134 | */ |
---|
135 | struct CORE_message_queue_Control { |
---|
136 | /** This field is the Waiting Queue used to manage the set of tasks |
---|
137 | * which are blocked waiting to receive a message from this queue. |
---|
138 | */ |
---|
139 | Thread_queue_Control Wait_queue; |
---|
140 | |
---|
141 | /** |
---|
142 | * @brief The thread queue operations according to the blocking discipline. |
---|
143 | */ |
---|
144 | const Thread_queue_Operations *operations; |
---|
145 | |
---|
146 | /** This element is maximum number of messages which may be pending |
---|
147 | * at any given time. |
---|
148 | */ |
---|
149 | uint32_t maximum_pending_messages; |
---|
150 | /** This element is the number of messages which are currently pending. |
---|
151 | */ |
---|
152 | uint32_t number_of_pending_messages; |
---|
153 | /** This is the size in bytes of the largest message which may be |
---|
154 | * sent via this queue. |
---|
155 | */ |
---|
156 | size_t maximum_message_size; |
---|
157 | /** This chain is the set of pending messages. It may be ordered by |
---|
158 | * message priority or in FIFO order. |
---|
159 | */ |
---|
160 | Chain_Control Pending_messages; |
---|
161 | /** This is the address of the memory allocated for message buffers. |
---|
162 | * It is allocated are part of message queue initialization and freed |
---|
163 | * as part of destroying it. |
---|
164 | */ |
---|
165 | CORE_message_queue_Buffer *message_buffers; |
---|
166 | #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) |
---|
167 | /** This is the routine invoked when the message queue transitions |
---|
168 | * from zero (0) messages pending to one (1) message pending. |
---|
169 | */ |
---|
170 | CORE_message_queue_Notify_Handler notify_handler; |
---|
171 | #endif |
---|
172 | /** This chain is the set of inactive messages. A message is inactive |
---|
173 | * when it does not contain a pending message. |
---|
174 | */ |
---|
175 | Chain_Control Inactive_messages; |
---|
176 | }; |
---|
177 | |
---|
178 | /**@}*/ |
---|
179 | |
---|
180 | #ifdef __cplusplus |
---|
181 | } |
---|
182 | #endif |
---|
183 | |
---|
184 | #endif |
---|
185 | /* end of include file */ |
---|