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