1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSImplClassicEvent |
---|
7 | * |
---|
8 | * @brief This header file provides the implementation interfaces of |
---|
9 | * the @ref RTEMSImplClassicEvent. |
---|
10 | */ |
---|
11 | |
---|
12 | /* COPYRIGHT (c) 1989-2008. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * Redistribution and use in source and binary forms, with or without |
---|
16 | * modification, are permitted provided that the following conditions |
---|
17 | * are met: |
---|
18 | * 1. Redistributions of source code must retain the above copyright |
---|
19 | * notice, this list of conditions and the following disclaimer. |
---|
20 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
21 | * notice, this list of conditions and the following disclaimer in the |
---|
22 | * documentation and/or other materials provided with the distribution. |
---|
23 | * |
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
34 | * POSSIBILITY OF SUCH DAMAGE. |
---|
35 | */ |
---|
36 | |
---|
37 | #ifndef _RTEMS_RTEMS_EVENTIMPL_H |
---|
38 | #define _RTEMS_RTEMS_EVENTIMPL_H |
---|
39 | |
---|
40 | #include <rtems/rtems/eventdata.h> |
---|
41 | #include <rtems/score/thread.h> |
---|
42 | |
---|
43 | #ifdef __cplusplus |
---|
44 | extern "C" { |
---|
45 | #endif |
---|
46 | |
---|
47 | /** |
---|
48 | * @defgroup RTEMSImplClassicEvent Event Manager |
---|
49 | * |
---|
50 | * @ingroup RTEMSImplClassic |
---|
51 | * |
---|
52 | * @brief This group contains the Event Manager implementation. |
---|
53 | * |
---|
54 | * @{ |
---|
55 | */ |
---|
56 | |
---|
57 | /** |
---|
58 | * @brief Seizes a set of events. |
---|
59 | * |
---|
60 | * @param event_in is the input event set. |
---|
61 | * |
---|
62 | * @param option_set is the option set. |
---|
63 | * |
---|
64 | * @param ticks is the optional timeout in clock ticks. |
---|
65 | * |
---|
66 | * @param event_out[out] is the output event set. |
---|
67 | * |
---|
68 | * @param executing[in, out] is the executing thread. |
---|
69 | * |
---|
70 | * @param event[in, out] is the source event set. |
---|
71 | * |
---|
72 | * @param wait_class is the thread wait class of the source event set. |
---|
73 | * |
---|
74 | * @param block_state is the thread blocking state of the source event set. |
---|
75 | * |
---|
76 | * @param lock_context[in, out] is the lock context set up by _Thread_Get(). |
---|
77 | * |
---|
78 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
79 | * |
---|
80 | * @retval ::RTEMS_UNSATISFIED The events of interest were not immediately |
---|
81 | * available. |
---|
82 | * |
---|
83 | * @retval ::RTEMS_TIMEOUT The events of interest were not available within the |
---|
84 | * specified timeout interval. |
---|
85 | */ |
---|
86 | rtems_status_code _Event_Seize( |
---|
87 | rtems_event_set event_in, |
---|
88 | rtems_option option_set, |
---|
89 | rtems_interval ticks, |
---|
90 | rtems_event_set *event_out, |
---|
91 | Thread_Control *executing, |
---|
92 | Event_Control *event, |
---|
93 | Thread_Wait_flags wait_class, |
---|
94 | States_Control block_state, |
---|
95 | ISR_lock_Context *lock_context |
---|
96 | ); |
---|
97 | |
---|
98 | /** |
---|
99 | * @brief Surrenders a set of events. |
---|
100 | * |
---|
101 | * @param the_thread[in, out] is the thread of the event set. |
---|
102 | * |
---|
103 | * @param event_in is the set of events to post. |
---|
104 | * |
---|
105 | * @param event[in, out] is the target event set. |
---|
106 | * |
---|
107 | * @param wait_class is the thread wait class of the target event set. |
---|
108 | * |
---|
109 | * @param lock_context[in, out] is the lock context set up by _Thread_Get(). |
---|
110 | * |
---|
111 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
112 | */ |
---|
113 | rtems_status_code _Event_Surrender( |
---|
114 | Thread_Control *the_thread, |
---|
115 | rtems_event_set event_in, |
---|
116 | Event_Control *event, |
---|
117 | Thread_Wait_flags wait_class, |
---|
118 | ISR_lock_Context *lock_context |
---|
119 | ); |
---|
120 | |
---|
121 | /** |
---|
122 | * @brief Initializes an event control block to have no pending events. |
---|
123 | * |
---|
124 | * @param event is the event control block to initialize. |
---|
125 | */ |
---|
126 | RTEMS_INLINE_ROUTINE void _Event_Initialize( Event_Control *event ) |
---|
127 | { |
---|
128 | event->pending_events = 0; |
---|
129 | } |
---|
130 | |
---|
131 | /** |
---|
132 | * @brief Checks if the event set is empty. |
---|
133 | * |
---|
134 | * @param the_event_set is the event set to check. |
---|
135 | * |
---|
136 | * @return Returns true, if there are no posted events in the event set, |
---|
137 | * otherwise false. |
---|
138 | */ |
---|
139 | RTEMS_INLINE_ROUTINE bool _Event_sets_Is_empty( |
---|
140 | rtems_event_set the_event_set |
---|
141 | ) |
---|
142 | { |
---|
143 | return ( the_event_set == 0 ); |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * @brief Posts the events in the specified event set. |
---|
148 | * |
---|
149 | * @param the_new_events is the set of events to post. |
---|
150 | * |
---|
151 | * @param the_event_set[in, out] is the event set. |
---|
152 | */ |
---|
153 | RTEMS_INLINE_ROUTINE void _Event_sets_Post( |
---|
154 | rtems_event_set the_new_events, |
---|
155 | rtems_event_set *the_event_set |
---|
156 | ) |
---|
157 | { |
---|
158 | *the_event_set |= the_new_events; |
---|
159 | } |
---|
160 | |
---|
161 | /** |
---|
162 | * @brief Gets the events of the specified event condition. |
---|
163 | * |
---|
164 | * @param the_event_set is the event set. |
---|
165 | * |
---|
166 | * @param the_event_condition is the event condition defining the events of interest. |
---|
167 | * |
---|
168 | * @return Return the events of the event condition which are posted in the |
---|
169 | * event set. |
---|
170 | */ |
---|
171 | RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Get( |
---|
172 | rtems_event_set the_event_set, |
---|
173 | rtems_event_set the_event_condition |
---|
174 | ) |
---|
175 | { |
---|
176 | return ( the_event_set & the_event_condition ); |
---|
177 | } |
---|
178 | |
---|
179 | /** |
---|
180 | * @brief Clears a set of events from an event set. |
---|
181 | * |
---|
182 | * @param the_event_set is the event set. |
---|
183 | * |
---|
184 | * @param the_mask is the set of events to clear. |
---|
185 | * |
---|
186 | * @return Returns the event set with all event cleared specified by the event |
---|
187 | * mask. |
---|
188 | */ |
---|
189 | RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Clear( |
---|
190 | rtems_event_set the_event_set, |
---|
191 | rtems_event_set the_mask |
---|
192 | ) |
---|
193 | { |
---|
194 | return ( the_event_set & ~(the_mask) ); |
---|
195 | } |
---|
196 | |
---|
197 | /**@}*/ |
---|
198 | |
---|
199 | #ifdef __cplusplus |
---|
200 | } |
---|
201 | #endif |
---|
202 | |
---|
203 | #if defined(RTEMS_MULTIPROCESSING) |
---|
204 | #include <rtems/rtems/eventmp.h> |
---|
205 | #endif |
---|
206 | |
---|
207 | #endif |
---|
208 | /* end of include file */ |
---|