Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6 | /**========================================================================= |
| 7 | |
| 8 | \file wlan_qct_pal_sync.c |
| 9 | |
| 10 | \brief Implementation trace/logging APIs PAL exports. wpt = (Wlan Pal Type) wpal = (Wlan PAL) |
| 11 | |
| 12 | Definitions for platform Windows and with legacy UMAC. |
| 13 | |
| 14 | Copyright 2010 (c) Qualcomm, Incorporated. All Rights Reserved. |
| 15 | |
| 16 | Qualcomm Confidential and Proprietary. |
| 17 | |
| 18 | ========================================================================*/ |
| 19 | |
| 20 | #include "wlan_qct_pal_sync.h" |
| 21 | #include "wlan_qct_pal_trace.h" |
| 22 | |
| 23 | #include "wlan_qct_os_status.h" |
| 24 | |
| 25 | /** |
| 26 | wpalMutexInit() |
| 27 | |
| 28 | @brief |
| 29 | This function initializes a mutex object |
| 30 | |
| 31 | @param pMutex: a pointer to caller allocated object of wpt_mutex |
| 32 | |
| 33 | @return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise. |
| 34 | |
| 35 | */ |
| 36 | wpt_status wpalMutexInit(wpt_mutex *pMutex) |
| 37 | { |
| 38 | /* Not doing sanity checks since VOS does them anyways */ |
| 39 | |
| 40 | if( vos_lock_init( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS ) |
| 41 | { |
| 42 | WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, |
Arif Hussain | 9a5d538 | 2013-11-17 22:05:35 -0800 | [diff] [blame] | 43 | " mutex init fail"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | return eWLAN_PAL_STATUS_E_FAILURE; |
| 45 | } |
| 46 | |
| 47 | return eWLAN_PAL_STATUS_SUCCESS; |
| 48 | } |
| 49 | |
| 50 | /*--------------------------------------------------------------------------- |
| 51 | @brief Invalidate a mutex object |
| 52 | |
| 53 | \param pMutex - a pointer to caller allocated object of wpt_mutex |
| 54 | |
| 55 | \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise. |
| 56 | ---------------------------------------------------------------------------*/ |
| 57 | wpt_status wpalMutexDelete(wpt_mutex *pMutex) |
| 58 | { |
| 59 | /* Not doing sanity checks since VOS does them anyways */ |
| 60 | |
| 61 | if( vos_lock_destroy( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS ) |
| 62 | { |
| 63 | WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, |
Arif Hussain | 9a5d538 | 2013-11-17 22:05:35 -0800 | [diff] [blame] | 64 | " mutex delete fail"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 65 | return eWLAN_PAL_STATUS_E_FAILURE; |
| 66 | } |
| 67 | |
| 68 | return eWLAN_PAL_STATUS_SUCCESS; |
| 69 | } |
| 70 | |
| 71 | /*--------------------------------------------------------------------------- |
| 72 | @brief Acquire a mutex object. It is blocked until the object is acquired. |
| 73 | |
| 74 | \param pMutex - a pointer to caller allocated object of wpt_mutex |
| 75 | |
| 76 | \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise. |
| 77 | ---------------------------------------------------------------------------*/ |
| 78 | wpt_status wpalMutexAcquire(wpt_mutex *pMutex) |
| 79 | { |
| 80 | /* Not doing sanity checks since VOS does them anyways */ |
| 81 | |
| 82 | if( vos_lock_acquire( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS ) |
| 83 | { |
| 84 | WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, |
Arif Hussain | 9a5d538 | 2013-11-17 22:05:35 -0800 | [diff] [blame] | 85 | " mutex acquire fail"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 86 | return eWLAN_PAL_STATUS_E_FAILURE; |
| 87 | } |
| 88 | |
| 89 | return eWLAN_PAL_STATUS_SUCCESS; |
| 90 | } |
| 91 | |
| 92 | /*--------------------------------------------------------------------------- |
| 93 | @brief Release a held mutex object |
| 94 | |
| 95 | \param pMutex - a pointer to caller allocated object of wpt_mutex |
| 96 | |
| 97 | \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise. |
| 98 | ---------------------------------------------------------------------------*/ |
| 99 | wpt_status wpalMutexRelease(wpt_mutex *pMutex) |
| 100 | { |
| 101 | /* Not doing sanity checks since VOS does them anyways */ |
| 102 | |
| 103 | if( vos_lock_release( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS ) |
| 104 | { |
| 105 | WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, |
Arif Hussain | 9a5d538 | 2013-11-17 22:05:35 -0800 | [diff] [blame] | 106 | " mutex release"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 107 | return eWLAN_PAL_STATUS_E_FAILURE; |
| 108 | } |
| 109 | |
| 110 | return eWLAN_PAL_STATUS_SUCCESS; |
| 111 | } |
| 112 | |
| 113 | /*--------------------------------------------------------------------------- |
| 114 | @brief Initialize an event object |
| 115 | |
| 116 | \param pEvent a pointer to caller allocated object of wpt_event |
| 117 | |
| 118 | \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise. |
| 119 | ------------------------------------------------------------------------*/ |
| 120 | wpt_status wpalEventInit(wpt_event *pEvent) |
| 121 | { |
| 122 | /* Not doing sanity checks since VOS does them anyways */ |
| 123 | |
| 124 | if( vos_event_init( (vos_event_t*)pEvent ) != VOS_STATUS_SUCCESS ) |
| 125 | { |
| 126 | WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, |
Arif Hussain | 9a5d538 | 2013-11-17 22:05:35 -0800 | [diff] [blame] | 127 | " create event fail"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 128 | return eWLAN_PAL_STATUS_E_FAILURE; |
| 129 | } |
| 130 | |
| 131 | return eWLAN_PAL_STATUS_SUCCESS; |
| 132 | } |
| 133 | |
| 134 | /*--------------------------------------------------------------------------- |
| 135 | @brief Invalidate an event object |
| 136 | |
| 137 | \param pEvent a pointer to caller allocated object of wpt_event |
| 138 | |
| 139 | \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise. |
| 140 | ------------------------------------------------------------------------*/ |
| 141 | |
| 142 | wpt_status wpalEventDelete(wpt_event *pEvent) |
| 143 | { |
| 144 | /* Not doing sanity checks since VOS does them anyways */ |
| 145 | |
| 146 | if( vos_event_destroy( (vos_event_t*)pEvent ) != VOS_STATUS_SUCCESS ) |
| 147 | { |
| 148 | WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, |
Arif Hussain | 9a5d538 | 2013-11-17 22:05:35 -0800 | [diff] [blame] | 149 | " delete event fail"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 150 | return eWLAN_PAL_STATUS_E_FAILURE; |
| 151 | } |
| 152 | |
| 153 | return eWLAN_PAL_STATUS_SUCCESS; |
| 154 | } |
| 155 | |
| 156 | /*--------------------------------------------------------------------------- |
| 157 | @brief wpalEventWait Wait on an event object |
| 158 | |
| 159 | \param |
| 160 | pEvent a pointer to caller allocated object of wpt_event |
| 161 | timeout - timeout value at unit of milli-seconds. |
| 162 | 0xffffffff means infinite wait |
| 163 | |
| 164 | \return eWLAN_PAL_STATUS_SUCCESS - the wait was satisifed by one of the events |
| 165 | in the event array being set. The index into the event arry |
| 166 | that satisfied the wait can be found at *pEventIndex. |
| 167 | |
| 168 | eWLAN_PALSTATUS_E_TIMEOUT - the timeout interval elapsed before any of |
| 169 | the events were set. |
| 170 | |
| 171 | eWLAN_PAL_STATUS_E_INVAL - At least one of the values specified in |
| 172 | the event array refers to an uninitialized event object. The |
| 173 | invalid event is identified by the index in *pEventIndex. Note |
| 174 | that only the first uninitialized event is detected when this error |
| 175 | is returned. |
| 176 | |
| 177 | eWLAN_PAL_STATUS_E_EMPTY - the events array is empty. This condition |
| 178 | is detected by numEvents being 0 on input. |
| 179 | |
| 180 | eWLAN_PAL_STATUS_E_FAULT - event or pEventIndex is an invalid pointer. |
| 181 | ---------------------------------------------------------------------------*/ |
| 182 | wpt_status wpalEventWait(wpt_event *pEvent, wpt_uint32 timeout) |
| 183 | { |
| 184 | /* Not doing sanity checks since VOS does them anyways */ |
| 185 | |
| 186 | wpt_status status = eWLAN_PAL_STATUS_E_FAILURE; |
| 187 | VOS_STATUS vos_status = VOS_STATUS_E_FAILURE; |
| 188 | |
| 189 | /* In VOS timeout = 0 corresponds to infinite wait */ |
| 190 | timeout = ( timeout == WLAN_PAL_WAIT_INFINITE ? 0 : timeout ); |
| 191 | |
| 192 | vos_status = vos_wait_single_event( (vos_event_t*)pEvent, timeout ); |
| 193 | |
| 194 | status = WPAL_VOS_TO_WPAL_STATUS( vos_status ); |
| 195 | |
| 196 | return status; |
| 197 | } |
| 198 | |
| 199 | /*--------------------------------------------------------------------------- |
| 200 | wpalEventSet Set an event object to signaled state |
| 201 | Param: |
| 202 | pEvent a pointer to caller allocated object of wpt_event |
| 203 | Return: |
| 204 | eWLAN_PAL_STATUS_SUCCESS success. Fail otherwise. |
| 205 | ---------------------------------------------------------------------------*/ |
| 206 | wpt_status wpalEventSet(wpt_event *pEvent) |
| 207 | { |
| 208 | /* Not doing sanity checks since VOS does them anyways */ |
| 209 | |
| 210 | return ( WPAL_VOS_TO_WPAL_STATUS(vos_event_set( (vos_event_t*)pEvent )) ); |
| 211 | } |
| 212 | |
| 213 | /*--------------------------------------------------------------------------- |
| 214 | wpalEventReset Set an event object to non-signaled state |
| 215 | Param: |
| 216 | pEvent a pointer to caller allocated object of wpt_event |
| 217 | Return: |
| 218 | eWLAN_PAL_STATUS_SUCCESS success. Fail otherwise. |
| 219 | ---------------------------------------------------------------------------*/ |
| 220 | wpt_status wpalEventReset(wpt_event *pEvent) |
| 221 | { |
| 222 | /* Not doing sanity checks since VOS does them anyways */ |
| 223 | |
| 224 | return ( WPAL_VOS_TO_WPAL_STATUS(vos_event_reset( (vos_event_t*)pEvent )) ); |
| 225 | } |
| 226 | |
| 227 | |