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