blob: 77efe2efbb8f436fc23458d70a9c19df2cf95543 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006#if !defined( __VOS_EVENT_H )
7#define __VOS_EVENT_H
8
9/**=========================================================================
10
11 \file vos_event.h
12
13 \brief virtual Operating System Services (vOSS) Events
14
15 Definitions for vOSS Events
16
17 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
18
19 Qualcomm Confidential and Proprietary.
20
21 ========================================================================*/
22
23/* $Header$ */
24
25/*--------------------------------------------------------------------------
26 Include Files
27 ------------------------------------------------------------------------*/
28#include "vos_status.h"
29#include "vos_types.h"
30#include "i_vos_event.h"
31
32/*--------------------------------------------------------------------------
33 Preprocessor definitions and constants
34 ------------------------------------------------------------------------*/
35#ifdef __cplusplus
36extern "C" {
37#endif /* __cplusplus */
38
39/*--------------------------------------------------------------------------
40 Type declarations
41 ------------------------------------------------------------------------*/
42
43/*-------------------------------------------------------------------------
44 Function declarations and documenation
45 ------------------------------------------------------------------------*/
46
47/*-------------------------------------------------------------------------
48
49 \brief vos_event_init() - initialize a vOSS event
50
51 The \a vos_lock_event() function initializes the specified event. Upon
52 successful initialization, the state of the event becomes initialized
53 and not 'signaled.
54
55 An event must be initialized before it may be used in any other lock
56 functions.
57
58 Attempting to initialize an already initialized event results in
59 a failure.
60
61 \param lock - pointer to the opaque event object to initialize
62
63 \return VOS_STATUS_SUCCESS - event was successfully initialized and
64 is ready to be used.
65
66 VOS_STATUS_E_RESOURCES - System resources (other than memory)
67 are unavailable to initilize the event
68
69 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
70 the event
71
72 VOS_STATUS_E_BUSY - The implementation has detected an attempt
73 to reinitialize the object referenced by event, a previously
74 initialized, but not yet destroyed, event.
75
76 VOS_STATUS_E_FAULT - event is an invalid pointer.
77 \sa
78
79 -------------------------------------------------------------------------*/
80VOS_STATUS vos_event_init( vos_event_t *event );
81
82/*--------------------------------------------------------------------------
83
84 \brief vos_event_set() - set a vOSS event
85
86 The state of the specified event is set to 'signalled by calling
87 \a vos_event_set(). The state of the event remains signalled until an
88 explicit call to vos_event_reset().
89
90 Any threads waiting on the event as a result of a vos_event_wait() will
91 be unblocked and available to be scheduled for execution when the event
92 is signaled by a call to \a vos_event_set().
93
94 \param event - the event to set to the signalled state
95
96 \return VOS_STATUS_SUCCESS - the event was successfully signalled.
97
98 VOS_STATUS_E_INVAL - The value specified by event does not refer
99 to an initialized event object.
100
101 VOS_STATUS_E_FAULT - event is an invalid pointer.
102
103 \sa
104
105 -------------------------------------------------------------------------*/
106VOS_STATUS vos_event_set( vos_event_t * event );
107
108
109/*--------------------------------------------------------------------------
110
111 \brief vos_event_reset() - reset a vOSS event
112
113 The state of the specified event is set to 'NOT signalled' by calling
114 \a vos_event_reset(). The state of the event remains NOT signalled until an
115 explicit call to vos_event_set().
116
117 This function sets the event to a NOT signalled state even if the event was
118 signalled multiple times before being signaled.
119
120 \param event - the event to set to the NOT signalled state
121
122 \return VOS_STATUS_SUCCESS - the event state was successfully change to
123 NOT signalled.
124
125 VOS_STATUS_E_INVAL - The value specified by event does not refer
126 to an initialized event object.
127
128 VOS_STATUS_E_FAULT - event is an invalid pointer.
129
130 \sa
131
132 -------------------------------------------------------------------------*/
133VOS_STATUS vos_event_reset( vos_event_t * event );
134
135
136/*--------------------------------------------------------------------------
137
138 \brief vos_event_destroy() - Destroy a vOSS event
139
140 The \a vos_event_destroy() function shall destroy the event object
141 referenced by event. After a successful return from \a vos_event_destroy()
142 the event object becomes, in effect, uninitialized.
143
144 A destroyed event object can be reinitialized using vos_event_init();
145 the results of otherwise referencing the object after it has been destroyed
146 are undefined. Calls to vOSS event functions to manipulate the lock such
147 as vos_event_set() will fail if the event is destroyed. Therefore,
148 don't use the event after it has been destroyed until it has
149 been re-initialized.
150
151 \param event - the event object to be destroyed.
152
153 \return VOS_STATUS_SUCCESS - event was successfully destroyed.
154
155 VOS_STATUS_E_BUSY - The implementation has detected an attempt
156 to destroy the object referenced by event while it is still being
157 referenced (there are threads waiting on this event)
158
159 VOS_STATUS_E_INVAL - The value specified by event is invalid.
160
161 VOS_STATUS_E_FAULT - event is an invalid pointer.
162 \sa
163
164 -------------------------------------------------------------------------*/
165VOS_STATUS vos_event_destroy( vos_event_t *event );
166
167// TODO: this is being removed and a stub exists currently to avoid
168// compiler errors
169VOS_STATUS vos_wait_events( vos_event_t *events, v_U8_t numEvents,
170 v_U32_t timeout, v_U8_t *pEventIndex );
171
172/*----------------------------------------------------------------------------
173
174 \brief vos_wait_single_event() - Waits for a single event to be set.
175
176 This API waits for the event to be set.
177
178 \param pEvent - pointer to an event to wait on.
179
180 \param timeout - Timeout value (in milliseconds). This function returns
181 if this interval elapses, regardless if any of the events have
182 been set. An input value of 0 for this timeout parameter means
183 to wait infinitely, meaning a timeout will never occur.
184
185 \return VOS_STATUS_SUCCESS - the wait was satisifed by the event being
186 set.
187
188 VOS_STATUS_E_TIMEOUT - the timeout interval elapsed before the
189 event was set.
190
191 VOS_STATUS_E_INVAL - The value specified by event is invalid.
192
193 VOS_STATUS_E_FAULT - pEvent is an invalid pointer.
194
195 \sa vos_wait_multiple_events()
196
197 --------------------------------------------------------------------------*/
198VOS_STATUS vos_wait_single_event( vos_event_t *pEvent, v_U32_t timeout );
199
200/*----------------------------------------------------------------------------
201
202 \brief vos_wait_multiple_events() - Waits for event(s) to be set.
203
204 This API waits for any event in the input array of events to be
205 set. The caller is blocked waiting any event in the array to be
206 set or for the timeout to occur.
207
208 If multiple events in the array are set, only one event is identified
209 in the return from this call as satisfying the wait condition. The
210 caller is responsible for calling \a vos_wait_events() again to find
211 the other events that are set.
212
213 \param pEventList - pointer to an array of event pointers
214
215 \param numEvents - Number of events
216
217 \param timeout - Timeout value (in milliseconds). This function returns
218 if this interval elapses, regardless if any of the events have
219 been set. An input value of 0 for this timeout parameter means
220 to wait infinitely, meaning a timeout will never occur.
221
222 \param pEventIndex - This is a pointer to the location where the index of
223 the event in the event array that satisfied the wait because
224 the event was set.
225
226 \return VOS_STATUS_SUCCESS - the wait was satisifed by one of the events
227 in the event array being set. The index into the event arry
228 that satisfied the wait can be found at *pEventIndex.
229
230 VOS_STATUS_E_TIMEOUT - the timeout interval elapsed before any of
231 the events were set.
232
233 VOS_STATUS_E_INVAL - At least one of the values specified in the
234 event array refers to an uninitialized event object. The invalid
235 event is identified by the index in *pEventIndex. Note that only
236 the first uninitialized event is detected when this error is
237 returned.
238
239 VOS_STATUS_E_EMPTY - the events array is empty. This condition
240 is detected by numEvents being 0 on input.
241
242 VOS_STATUS_E_FAULT - event or pEventIndex is an invalid pointer.
243
244 \sa vos_wait_single_events()
245
246 --------------------------------------------------------------------------*/
247VOS_STATUS vos_wait_multiple_events( vos_event_t **pEventList, v_U8_t numEvents,
248 v_U32_t timeout, v_U8_t *pEventIndex );
249
250#ifdef __cplusplus
251}
252#endif /* __cplusplus */
253
254#endif // __VOSS_EVENT_H