blob: c0394641a80395ab0106adf3fcab880bf2df181e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam1ed83fc2014-02-19 01:15:45 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028#if !defined( __VOS_EVENT_H )
29#define __VOS_EVENT_H
30
31/**=========================================================================
32
33 \file vos_event.h
34
35 \brief virtual Operating System Services (vOSS) Events
36
37 Definitions for vOSS Events
38
Jeff Johnson295189b2012-06-20 16:38:30 -070039
40 ========================================================================*/
41
42/* $Header$ */
43
44/*--------------------------------------------------------------------------
45 Include Files
46 ------------------------------------------------------------------------*/
47#include "vos_status.h"
48#include "vos_types.h"
49#include "i_vos_event.h"
50
51/*--------------------------------------------------------------------------
52 Preprocessor definitions and constants
53 ------------------------------------------------------------------------*/
54#ifdef __cplusplus
55extern "C" {
56#endif /* __cplusplus */
57
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053058#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
59#define INIT_COMPLETION(event) reinit_completion(&event)
60#endif
61
Jeff Johnson295189b2012-06-20 16:38:30 -070062/*--------------------------------------------------------------------------
63 Type declarations
64 ------------------------------------------------------------------------*/
65
66/*-------------------------------------------------------------------------
67 Function declarations and documenation
68 ------------------------------------------------------------------------*/
69
70/*-------------------------------------------------------------------------
71
72 \brief vos_event_init() - initialize a vOSS event
73
74 The \a vos_lock_event() function initializes the specified event. Upon
75 successful initialization, the state of the event becomes initialized
76 and not 'signaled.
77
78 An event must be initialized before it may be used in any other lock
79 functions.
80
81 Attempting to initialize an already initialized event results in
82 a failure.
83
84 \param lock - pointer to the opaque event object to initialize
85
86 \return VOS_STATUS_SUCCESS - event was successfully initialized and
87 is ready to be used.
88
89 VOS_STATUS_E_RESOURCES - System resources (other than memory)
90 are unavailable to initilize the event
91
92 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
93 the event
94
95 VOS_STATUS_E_BUSY - The implementation has detected an attempt
96 to reinitialize the object referenced by event, a previously
97 initialized, but not yet destroyed, event.
98
99 VOS_STATUS_E_FAULT - event is an invalid pointer.
100 \sa
101
102 -------------------------------------------------------------------------*/
103VOS_STATUS vos_event_init( vos_event_t *event );
104
105/*--------------------------------------------------------------------------
106
107 \brief vos_event_set() - set a vOSS event
108
109 The state of the specified event is set to 'signalled by calling
110 \a vos_event_set(). The state of the event remains signalled until an
111 explicit call to vos_event_reset().
112
113 Any threads waiting on the event as a result of a vos_event_wait() will
114 be unblocked and available to be scheduled for execution when the event
115 is signaled by a call to \a vos_event_set().
116
117 \param event - the event to set to the signalled state
118
119 \return VOS_STATUS_SUCCESS - the event was successfully signalled.
120
121 VOS_STATUS_E_INVAL - The value specified by event does not refer
122 to an initialized event object.
123
124 VOS_STATUS_E_FAULT - event is an invalid pointer.
125
126 \sa
127
128 -------------------------------------------------------------------------*/
129VOS_STATUS vos_event_set( vos_event_t * event );
130
131
132/*--------------------------------------------------------------------------
133
134 \brief vos_event_reset() - reset a vOSS event
135
136 The state of the specified event is set to 'NOT signalled' by calling
137 \a vos_event_reset(). The state of the event remains NOT signalled until an
138 explicit call to vos_event_set().
139
140 This function sets the event to a NOT signalled state even if the event was
141 signalled multiple times before being signaled.
142
143 \param event - the event to set to the NOT signalled state
144
145 \return VOS_STATUS_SUCCESS - the event state was successfully change to
146 NOT signalled.
147
148 VOS_STATUS_E_INVAL - The value specified by event does not refer
149 to an initialized event object.
150
151 VOS_STATUS_E_FAULT - event is an invalid pointer.
152
153 \sa
154
155 -------------------------------------------------------------------------*/
156VOS_STATUS vos_event_reset( vos_event_t * event );
157
158
159/*--------------------------------------------------------------------------
160
161 \brief vos_event_destroy() - Destroy a vOSS event
162
163 The \a vos_event_destroy() function shall destroy the event object
164 referenced by event. After a successful return from \a vos_event_destroy()
165 the event object becomes, in effect, uninitialized.
166
167 A destroyed event object can be reinitialized using vos_event_init();
168 the results of otherwise referencing the object after it has been destroyed
169 are undefined. Calls to vOSS event functions to manipulate the lock such
170 as vos_event_set() will fail if the event is destroyed. Therefore,
171 don't use the event after it has been destroyed until it has
172 been re-initialized.
173
174 \param event - the event object to be destroyed.
175
176 \return VOS_STATUS_SUCCESS - event was successfully destroyed.
177
178 VOS_STATUS_E_BUSY - The implementation has detected an attempt
179 to destroy the object referenced by event while it is still being
180 referenced (there are threads waiting on this event)
181
182 VOS_STATUS_E_INVAL - The value specified by event is invalid.
183
184 VOS_STATUS_E_FAULT - event is an invalid pointer.
185 \sa
186
187 -------------------------------------------------------------------------*/
188VOS_STATUS vos_event_destroy( vos_event_t *event );
189
190// TODO: this is being removed and a stub exists currently to avoid
191// compiler errors
192VOS_STATUS vos_wait_events( vos_event_t *events, v_U8_t numEvents,
193 v_U32_t timeout, v_U8_t *pEventIndex );
194
195/*----------------------------------------------------------------------------
196
197 \brief vos_wait_single_event() - Waits for a single event to be set.
198
199 This API waits for the event to be set.
200
201 \param pEvent - pointer to an event to wait on.
202
203 \param timeout - Timeout value (in milliseconds). This function returns
204 if this interval elapses, regardless if any of the events have
205 been set. An input value of 0 for this timeout parameter means
206 to wait infinitely, meaning a timeout will never occur.
207
208 \return VOS_STATUS_SUCCESS - the wait was satisifed by the event being
209 set.
210
211 VOS_STATUS_E_TIMEOUT - the timeout interval elapsed before the
212 event was set.
213
214 VOS_STATUS_E_INVAL - The value specified by event is invalid.
215
216 VOS_STATUS_E_FAULT - pEvent is an invalid pointer.
217
218 \sa vos_wait_multiple_events()
219
220 --------------------------------------------------------------------------*/
221VOS_STATUS vos_wait_single_event( vos_event_t *pEvent, v_U32_t timeout );
222
223/*----------------------------------------------------------------------------
224
225 \brief vos_wait_multiple_events() - Waits for event(s) to be set.
226
227 This API waits for any event in the input array of events to be
228 set. The caller is blocked waiting any event in the array to be
229 set or for the timeout to occur.
230
231 If multiple events in the array are set, only one event is identified
232 in the return from this call as satisfying the wait condition. The
233 caller is responsible for calling \a vos_wait_events() again to find
234 the other events that are set.
235
236 \param pEventList - pointer to an array of event pointers
237
238 \param numEvents - Number of events
239
240 \param timeout - Timeout value (in milliseconds). This function returns
241 if this interval elapses, regardless if any of the events have
242 been set. An input value of 0 for this timeout parameter means
243 to wait infinitely, meaning a timeout will never occur.
244
245 \param pEventIndex - This is a pointer to the location where the index of
246 the event in the event array that satisfied the wait because
247 the event was set.
248
249 \return VOS_STATUS_SUCCESS - the wait was satisifed by one of the events
250 in the event array being set. The index into the event arry
251 that satisfied the wait can be found at *pEventIndex.
252
253 VOS_STATUS_E_TIMEOUT - the timeout interval elapsed before any of
254 the events were set.
255
256 VOS_STATUS_E_INVAL - At least one of the values specified in the
257 event array refers to an uninitialized event object. The invalid
258 event is identified by the index in *pEventIndex. Note that only
259 the first uninitialized event is detected when this error is
260 returned.
261
262 VOS_STATUS_E_EMPTY - the events array is empty. This condition
263 is detected by numEvents being 0 on input.
264
265 VOS_STATUS_E_FAULT - event or pEventIndex is an invalid pointer.
266
267 \sa vos_wait_single_events()
268
269 --------------------------------------------------------------------------*/
270VOS_STATUS vos_wait_multiple_events( vos_event_t **pEventList, v_U8_t numEvents,
271 v_U32_t timeout, v_U8_t *pEventIndex );
272
273#ifdef __cplusplus
274}
275#endif /* __cplusplus */
276
277#endif // __VOSS_EVENT_H