1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* 2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * context.c 3981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 4981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. 5981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * All rights reserved. 6981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 7981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Redistribution and use in source and binary forms, with or without 8981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * modification, are permitted provided that the following conditions 9981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * are met: 10981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 11981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * * Redistributions of source code must retain the above copyright 12981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * notice, this list of conditions and the following disclaimer. 13981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * * Redistributions in binary form must reproduce the above copyright 14981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * notice, this list of conditions and the following disclaimer in 15981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * the documentation and/or other materials provided with the 16981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * distribution. 17981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * * Neither the name Texas Instruments nor the names of its 18981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * contributors may be used to endorse or promote products derived 19981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * from this software without specific prior written permission. 20981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 21981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 33981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 34981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \file context.c 36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief The Context-Engine is an OS independent module, which provides the 37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * infrustracture for switching from external contexts to the driver's context. 38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This includes also the driver task itself (workqueue in Linux), which invokes the 39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * driver specific handlers in the driver's context. 40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The OS specific implementation under this module (e.g. task-switching or 41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * protection-locking) is provided by the OS abstraction layer (osapi.c). 42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \see context.h, osapi.c 44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define __FILE_ID__ FILE_ID_125 48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osApi.h" 49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "report.h" 50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "context.h" 51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "bmtrace_api.h" 52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define MAX_CLIENTS 8 /* Maximum number of clients using context services */ 56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define MAX_NAME_SIZE 16 /* Maximum client's name string size */ 57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 5904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidttypedef struct 60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 uSize; /* Clients' name string size */ 62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt char sName [MAX_NAME_SIZE]; /* Clients' name string */ 6304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt} TClientName; 64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /* TI_DBG */ 65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* context module structure */ 6704635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidttypedef struct 68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 6904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TI_HANDLE hOs; 7004635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TI_HANDLE hReport; 71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_BOOL bContextSwitchRequired; /* Indicate if the driver should switch to its */ 7304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt /* own context or not before handling events */ 74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_HANDLE hProtectionLock; /* Handle of protection lock used by context clients */ 75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 uNumClients; /* Number of registered clients */ 76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TContextCbFunc aClientCbFunc [MAX_CLIENTS]; /* Clients' callback functions */ 77981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_HANDLE aClientCbHndl [MAX_CLIENTS]; /* Clients' callback handles */ 78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_BOOL aClientEnabled[MAX_CLIENTS]; /* Clients' enable/disable flags */ 79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_BOOL aClientPending[MAX_CLIENTS]; /* Clients' pending flags */ 80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TClientName aClientName [MAX_CLIENTS]; /* Clients' name string */ 83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 aRequestCount [MAX_CLIENTS]; /* Clients' schedule requests counter*/ 84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 aInvokeCount [MAX_CLIENTS]; /* Clients' invocations counter */ 85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif 86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 8704635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt} TContext; 88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_Create 92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Create the module 93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Allocate and clear the module object. 95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hOs - Handle to Os Abstraction Layer 98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return Handle of the allocated object 99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa context_Destroy 100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_HANDLE context_Create (TI_HANDLE hOs) 102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 10304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TI_HANDLE hContext; 10404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 10504635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt /* allocate module object */ 10604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt hContext = os_memoryAlloc (hOs, sizeof(TContext)); 10704635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 10804635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt if (!hContext) 10904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt { 11004635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt WLAN_OS_REPORT (("context_Create(): Allocation failed!!\n")); 11104635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt return NULL; 11204635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt } 11304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt os_memoryZero (hOs, hContext, (sizeof(TContext))); 115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 11604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt return (hContext); 117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_Destroy 122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Destroy the module. 123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Free the module memory. 125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module object 128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK on success or TI_NOK on failure 129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa context_Create 130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS context_Destroy (TI_HANDLE hContext) 132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TContext *pContext = (TContext *)hContext; 134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Destroy the protection handle */ 136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt os_protectDestroy (pContext->hOs, pContext->hProtectionLock); 137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* free module object */ 13904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_memoryFree (pContext->hOs, pContext, sizeof(TContext)); 14004635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt return TI_OK; 142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_Init 147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Init required handles 148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Init required handles. 150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The queue object 153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hOs - Handle to Os Abstraction Layer 154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hReport - Handle to report module 155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void 156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa 157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_Init (TI_HANDLE hContext, TI_HANDLE hOs, TI_HANDLE hReport) 159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 16004635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->hOs = hOs; 163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->hReport = hReport; 16404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Create the module's protection lock and save its handle */ 166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->hProtectionLock = os_protectCreate (pContext->hOs); 167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_SetDefaults 172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Configure module with default settings 173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Set default setting which indicates if the driver should switch to 175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * its own context or not before handling events 176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module's object 179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param pContextInitParams - The module's init parameters 180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK on success or TI_NOK on failure 181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa 182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS context_SetDefaults (TI_HANDLE hContext, TContextInitParams *pContextInitParams) 184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 18504635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Set parameters */ 188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->bContextSwitchRequired = pContextInitParams->bContextSwitchRequired; 18904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt return TI_OK; 191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_RegisterClient 196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Save client's parameters 197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function is used by the Context clients in their init process, for registering 199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * their information, 200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This includes their callback function that should be invoked from the driver context 201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * when they are pending. 202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module handle 205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param fCbFunc - The client's callback function. 206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hCbHndl - The client's callback function handle. 207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param bEnable - TRUE = Enabled. 208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_UINT32 - The index allocated for the client 209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa 210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_UINT32 context_RegisterClient (TI_HANDLE hContext, 212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TContextCbFunc fCbFunc, 213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_HANDLE hCbHndl, 214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_BOOL bEnable, 215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt char *sName, 216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 uNameSize) 217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 21804635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 uClientId = pContext->uNumClients; 220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* If max number of clients is exceeded, report error and exit. */ 22204635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt if (uClientId == MAX_CLIENTS) 223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_ERROR , "context_RegisterClient() MAX_CLIENTS limit exceeded!!\n"); 225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt return 0; 226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Save the new client's parameters. */ 229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientCbFunc[uClientId] = fCbFunc; 230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientCbHndl[uClientId] = hCbHndl; 231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientEnabled[uClientId] = bEnable; 232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientPending[uClientId] = TI_FALSE; 233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 23504635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt if (uNameSize <= MAX_NAME_SIZE) 236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 23704635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_memoryCopy(pContext->hOs, 238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt (void *)(pContext->aClientName[uClientId].sName), 23904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt (void *)sName, 240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt uNameSize); 241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientName[uClientId].uSize = uNameSize; 242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 24304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt else 244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_ERROR , "context_RegisterClient() MAX_NAME_SIZE limit exceeded!\n"); 246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /* TI_DBG */ 248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Increment clients number and return new client ID. */ 250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->uNumClients++; 251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE2(pContext->hReport, REPORT_SEVERITY_INIT , "context_RegisterClient(): Client=, ID=%d, enabled=%d\n", uClientId, bEnable); 253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt return uClientId; 255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_RequestSchedule 260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Handle client's switch to driver's context. 261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function is called by a client from external context event. 263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * It sets the client's Pending flag and requests the driver's task scheduling. 264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Thus, the client's callback will be called afterwards from the driver context. 265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module handle 268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param uClientId - The client's index 269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void 270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa context_DriverTask 271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_RequestSchedule (TI_HANDLE hContext, TI_UINT32 uClientId) 273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 27404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aRequestCount[uClientId]++; 278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE3(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_RequestSchedule(): Client=, ID=%d, enabled=%d, pending=%d\n", uClientId, pContext->aClientEnabled[uClientId], pContext->aClientPending[uClientId]); 279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /* TI_DBG */ 280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Set client's Pending flag */ 282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientPending[uClientId] = TI_TRUE; 283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 28404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt /* Prevent system from going to sleep */ 28504635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_wake_lock(pContext->hOs); 28604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* 288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * If configured to switch context, request driver task scheduling. 289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Else (context switch not required) call the driver task directly. 290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt if (pContext->bContextSwitchRequired) 292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 29304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt if (os_RequestSchedule(pContext->hOs) != TI_OK) 29404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_wake_unlock(pContext->hOs); 295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 29604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt else 297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 29804635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt context_DriverTask(hContext); 29904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_wake_unlock(pContext->hOs); 300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_DriverTask 306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief The driver task 307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function is the driver's main task that always runs in the driver's 309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * single context, scheduled through the OS (the driver's workqueue in Linux). 310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Only one instantiation of this task may run at a time! 311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module handle 314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void 315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa context_RequestSchedule 316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_DriverTask (TI_HANDLE hContext) 318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 31904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TContextCbFunc fCbFunc; 321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_HANDLE hCbHndl; 322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 i; 323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt CL_TRACE_START_L1(); 324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_DriverTask():\n"); 326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* For all registered clients do: */ 32804635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt for (i = 0; i < pContext->uNumClients; i++) 329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* If client is pending and enabled */ 331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt if (pContext->aClientPending[i] && pContext->aClientEnabled[i]) 332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 33304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt#ifdef TI_DBG 33404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt pContext->aInvokeCount[i]++; 33504635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TRACE1(pContext->hReport, REPORT_SEVERITY_INFORMATION , "Invoking - Client=, ID=%d\n", i); 33604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt#endif /* TI_DBG */ 337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Clear client's pending flag */ 339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientPending[i] = TI_FALSE; 340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Call client's callback function */ 342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt fCbFunc = pContext->aClientCbFunc[i]; 343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt hCbHndl = pContext->aClientCbHndl[i]; 344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt fCbFunc(hCbHndl); 345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt CL_TRACE_END_L1("tiwlan_drv.ko", "CONTEXT", "TASK", ""); 349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_EnableClient / context_DisableClient 354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Enable a specific client activation 355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Called by the driver main when needed to enble/disable a specific event handling. 357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The Enable function also schedules the driver-task if the specified client is pending. 358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module handle 361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param uClientId - The client's index 362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void 363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa context_DriverTask 364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_EnableClient (TI_HANDLE hContext, TI_UINT32 uClientId) 366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 36704635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt if (pContext->aClientEnabled[uClientId]) 371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_ERROR , "context_EnableClient() Client already enabled!!\n"); 373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt return; 374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE3(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_EnableClient(): Client=, ID=%d, enabled=%d, pending=%d\n", uClientId, pContext->aClientEnabled[uClientId], pContext->aClientPending[uClientId]); 376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /* TI_DBG */ 377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Enable client */ 379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientEnabled[uClientId] = TI_TRUE; 380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* If client is pending, schedule driver task */ 382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt if (pContext->aClientPending[uClientId]) 383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 38404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt /* Prevent system from going to sleep */ 38504635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_wake_lock(pContext->hOs); 38604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt 387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* 388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * If configured to switch context, request driver task scheduling. 389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Else (context switch not required) call the driver task directly. 390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt if (pContext->bContextSwitchRequired) 392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 39304635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt if (os_RequestSchedule(pContext->hOs) != TI_OK) 39404635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_wake_unlock(pContext->hOs); 395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 39604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt else 397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 39804635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt context_DriverTask(hContext); 39904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt os_wake_unlock(pContext->hOs); 400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_DisableClient (TI_HANDLE hContext, TI_UINT32 uClientId) 405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 40604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt if (!pContext->aClientEnabled[uClientId]) 410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt { 411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_ERROR , "context_DisableClient() Client already disabled!!\n"); 412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt return; 413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt } 414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE3(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_DisableClient(): Client=, ID=%d, enabled=%d, pending=%d\n", uClientId, pContext->aClientEnabled[uClientId], pContext->aClientPending[uClientId]); 415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /* TI_DBG */ 416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Disable client */ 418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientEnabled[uClientId] = TI_FALSE; 419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_EnterCriticalSection / context_LeaveCriticalSection 424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Lock / Unlock context related critical sections 425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 426981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The context clients should use these functions for protecting their critical sections 427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * when handling context transition to driver context. 428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The module handle 431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void 432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa 433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_EnterCriticalSection (TI_HANDLE hContext) 435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 43604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_EnterCriticalSection():\n"); 439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Start critical section protection */ 441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt os_protectLock (pContext->hOs, pContext->hProtectionLock); 442981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_LeaveCriticalSection (TI_HANDLE hContext) 445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 44604635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TRACE0(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_LeaveCriticalSection():\n"); 449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt /* Stop critical section protection */ 451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt os_protectUnlock (pContext->hOs, pContext->hProtectionLock); 452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** 456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn context_Print 457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief Print module information 458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Print the module's clients parameters. 460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * 461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note 462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param hContext - The queue object 463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void 464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa 465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */ 466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG 468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid context_Print(TI_HANDLE hContext) 470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{ 47104635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt#ifdef REPORT_LOG 47204635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt TContext *pContext = (TContext *)hContext; 473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt TI_UINT32 i; 474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt WLAN_OS_REPORT(("context_Print(): %d Clients Registered:\n", pContext->uNumClients)); 476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt WLAN_OS_REPORT(("=======================================\n")); 477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt WLAN_OS_REPORT(("bContextSwitchRequired = %d\n", pContext->bContextSwitchRequired)); 478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 47904635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt for (i = 0; i < pContext->uNumClients; i++) 48004635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt { 48104635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt WLAN_OS_REPORT(("Client %d - %s: CbFunc=0x%x, CbHndl=0x%x, Enabled=%d, Pending=%d, Requests=%d, Invoked=%d\n", 482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt i, 483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientName[i].sName, 484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientCbFunc[i], 485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientCbHndl[i], 486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientEnabled[i], 487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aClientPending[i], 488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aRequestCount[i], 489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt pContext->aInvokeCount[i] )); 49004635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt } 49104635cee59642c3439608797ad2351ab37ca2840Dmitry Shmidt#endif 492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} 493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt 494981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /* TI_DBG */ 495