/** * \fn txDataQ_Create * \brief Create the module and its queues * * Create the Tx Data module and its queues. * * \note * \param hOs - Handle to the Os Abstraction Layer * \return Handle to the allocated Tx Data Queue module (NULL if failed) * \sa */ TI_HANDLE txDataQ_Create(TI_HANDLE hOs) { TTxDataQ *pTxDataQ; /* allocate TxDataQueue module */ pTxDataQ = os_memoryAlloc(hOs, (sizeof(TTxDataQ))); if (!pTxDataQ) { WLAN_OS_REPORT(("Error allocating the TxDataQueue Module\n")); return NULL; } /* Reset TxDataQueue module */ os_memoryZero(hOs, pTxDataQ, (sizeof(TTxDataQ))); return (TI_HANDLE) pTxDataQ; }
/** * \fn twIf_Create * \brief Create the module * * Allocate and clear the module's object. * * \note * \param hOs - Handle to Os Abstraction Layer * \return Handle of the allocated object, NULL if allocation failed * \sa twIf_Destroy */ TI_HANDLE twIf_Create (TI_HANDLE hOs) { TI_HANDLE hTwIf; TTwIfObj *pTwIf; hTwIf = os_memoryAlloc (hOs, sizeof(TTwIfObj)); if (hTwIf == NULL) return NULL; pTwIf = (TTwIfObj *)hTwIf; os_memoryZero (hOs, hTwIf, sizeof(TTwIfObj)); pTwIf->hOs = hOs; return pTwIf; }
/** * * admCtrl_create * * \b Description: * * Create the admission control context. * * \b ARGS: * * I - role - admission cotrol role (AP or Station) \n * I - authSuite - authentication suite to work with \n * * \b RETURNS: * * TI_OK on success, TI_NOK on failure. * * \sa */ admCtrl_t* admCtrl_create(TI_HANDLE hOs) { admCtrl_t *pHandle; /* allocate rsniation context memory */ pHandle = (admCtrl_t*)os_memoryAlloc(hOs, sizeof(admCtrl_t)); if (pHandle == NULL) { return NULL; } os_memoryZero(hOs, pHandle, sizeof(admCtrl_t)); pHandle->hOs = hOs; return pHandle; }
/* * \brief Initialize the module * * \param hFwDebug - Handle to FW Debug * \param hReport - Handle to report * \param hTwif - Handle to TWIF * \param hFwEvent - Handle to fwEvent * \return none * * \par Description * * * \sa */ void fwDbg_Init (TI_HANDLE hFwDebug, TI_HANDLE hReport, TI_HANDLE hTwif, TI_HANDLE hFwEvent) { TFwDebug* pFwDebug = (TFwDebug*)hFwDebug; pFwDebug->hReport = hReport; pFwDebug->hTwif = hTwif; pFwDebug->hFwEvent = hFwEvent; /* Allocate DMA memory for read write transact */ pFwDebug->pDMABuf = (TI_UINT8*)os_memoryAlloc(pFwDebug->hOs,DMA_SIZE_BUF); /* Init SDIO test variables */ pFwDebug->pSdioTestWriteBuf = NULL; pFwDebug->pSdioTestReadBuf = NULL; }
/** * * mainSec_create * * \b Description: * * Allocate memory for the main security context, and create all the rest of the needed contexts. * * \b ARGS: * * I - hOs - OS handle for OS operations. * * \b RETURNS: * * pointer to main security context. If failed, returns NULL. * * \sa */ mainSec_t* mainSec_create(TI_HANDLE hOs) { mainSec_t *pHandle; TI_STATUS status; /* allocate association context memory */ pHandle = (mainSec_t*)os_memoryAlloc(hOs, sizeof(mainSec_t)); if (pHandle == NULL) { return NULL; } os_memoryZero(hOs, pHandle, sizeof(mainSec_t)); /* allocate memory for association state machine */ status = fsm_Create(hOs, &pHandle->pMainSecSm, MAIN_SEC_MAX_NUM_STATES, MAIN_SEC_MAX_NUM_EVENTS); if (status != TI_OK) { os_memoryFree(hOs, pHandle, sizeof(mainSec_t)); return NULL; } pHandle->pMainKeys = mainKeys_create(hOs); if (pHandle->pMainKeys == NULL) { fsm_Unload(hOs, pHandle->pMainSecSm); os_memoryFree(hOs, pHandle, sizeof(mainSec_t)); return NULL; } pHandle->pKeyParser = pHandle->pMainKeys->pKeyParser; pHandle->hOs = hOs; /* created only for external security mode */ pHandle->pExternalSec = externalSec_create(hOs); if (pHandle->pExternalSec == NULL) { fsm_Unload(hOs, pHandle->pMainSecSm); mainKeys_unload(pHandle->pMainKeys); os_memoryFree(hOs, pHandle, sizeof(mainSec_t)); return NULL; } return pHandle; }
/** * \fn tmr_Create * \brief Create the timer module * * Allocate and clear the timer module object. * * \note This is NOT a specific timer creation! (see tmr_CreateTimer) * \param hOs - Handle to Os Abstraction Layer * \return Handle of the allocated object * \sa tmr_Destroy */ TI_HANDLE tmr_Create (TI_HANDLE hOs) { TI_HANDLE hTimerModule; /* allocate module object */ hTimerModule = os_memoryAlloc (hOs, sizeof(TTimerModule)); if (!hTimerModule) { WLAN_OS_REPORT (("tmr_Create(): Allocation failed!!\n")); return NULL; } os_memoryZero (hOs, hTimerModule, (sizeof(TTimerModule))); return (hTimerModule); }
/* * \brief Create the TCmdQueue object * * \param hOs - OS module object handle * \return Handle to the created object * * \par Description * Calling this function creates a CmdQueue object * * \sa cmdQueue_Destroy */ TI_HANDLE cmdQueue_Create (TI_HANDLE hOs) { TCmdQueue *pCmdQueue; pCmdQueue = os_memoryAlloc (hOs, sizeof(TCmdQueue)); if (pCmdQueue == NULL) { WLAN_OS_REPORT(("FATAL ERROR: cmdQueue_Create(): Error Creating aCmdQueue - Aborting\n")); return NULL; } /* reset control module control block */ os_memoryZero (hOs, pCmdQueue, sizeof(TCmdQueue)); pCmdQueue->hOs = hOs; return pCmdQueue; }
/* * \brief Create the mailbox object * * \param hOs - OS module object handle * \return Handle to the created object * * \par Description * Calling this function creates a CmdMbox object * * \sa cmdMbox_Destroy */ TI_HANDLE cmdMbox_Create (TI_HANDLE hOs) { TCmdMbox *pCmdMbox; pCmdMbox = os_memoryAlloc (hOs, sizeof (TCmdMbox)); if (pCmdMbox == NULL) { WLAN_OS_REPORT (("FATAL ERROR: cmdMbox_Create(): Error Creating CmdMbox - Aborting\n")); return NULL; } /* reset control module control block */ os_memoryZero (hOs, pCmdMbox, sizeof (TCmdMbox)); pCmdMbox->hOs = hOs; return pCmdMbox; }
/** * \fn staCap_Create * \brief Create the staCap module. * * Allocate and clear the staCap module object. * * \param hOs - Handle to Os Abstraction Layer * \return Handle of the allocated object * \sa staCap_Destroy */ TI_HANDLE StaCap_Create (TI_HANDLE hOs) { TI_HANDLE hStaCap; /* allocate module object */ hStaCap = os_memoryAlloc (hOs, sizeof(TStaCap)); if (!hStaCap) { WLAN_OS_REPORT (("StaCap_Create(): Allocation failed!!\n")); return NULL; } os_memoryZero (hOs, hStaCap, (sizeof(TStaCap))); return (hStaCap); }
/** * \fn RxQueue_Create() * \brief Create the RxQueue module. * * Allocate and clear the RxQueue module object. * * \param hOs - Handle to Os Abstraction Layer * \return Handle of the allocated object * \sa RxQueue_Destroy */ TI_HANDLE RxQueue_Create (TI_HANDLE hOs) { TRxQueue *pRxQueue; /* allocate module object */ pRxQueue = os_memoryAlloc (hOs, sizeof(TRxQueue)); if (!pRxQueue) { WLAN_OS_REPORT (("RxQueue_Create(): Allocation failed!!\n")); return NULL; } os_memoryZero (hOs, pRxQueue, (sizeof(TRxQueue))); pRxQueue->hOs = hOs; return (pRxQueue); }
TI_HANDLE pwrState_Create (TI_HANDLE hOs) { TPwrState *pPwrState = NULL; pPwrState = (TPwrState*) os_memoryAlloc (hOs, sizeof(TPwrState)); if ( NULL == pPwrState ) { WLAN_OS_REPORT(("%s: Memory Allocation Error!\n", __func__)); return NULL; } os_memoryZero (hOs, pPwrState, sizeof(TPwrState)); pPwrState->hOs = hOs; return pPwrState; }
/**************************************************************************************** * os_memoryAlloc() **************************************************************************************** DESCRIPTION: Allocates resident (nonpaged) system-space memory. ARGUMENTS: OsContext - our adapter context. Size - Specifies the size, in bytes, to be allocated. RETURN: Pointer to the allocated memory. NULL if there is insufficient memory available. NOTES: With the call to vmalloc it is assumed that this function will never be called in an interrupt context. vmalloc has the potential to sleep the caller while waiting for memory to become available. *****************************************************************************************/ void* mem_Alloc (TI_HANDLE hMem, TI_UINT32 size) { TMemMng *pMemMng = (TMemMng *)hMem; TMemBlock *pMemBlock; TI_UINT32 total = size + sizeof(TMemBlock) + sizeof(TI_UINT32); pMemBlock = (TMemBlock *) os_memoryAlloc (pMemMng->hOs, total); pMemBlock->size = size; pMemBlock->signature = MEM_BLOCK_START; *(TI_UINT32 *)((TI_UINT8 *)pMemBlock + total - sizeof(TI_UINT32)) = MEM_BLOCK_END; pMemMng->uCurAllocated += total; if (pMemMng->uMaxAllocated < pMemMng->uCurAllocated) { pMemMng->uMaxAllocated = pMemMng->uCurAllocated; } return (void*)((TI_UINT8 *)pMemBlock + sizeof(TMemBlock)); }
/** * * roamingMngr_smSuccHandover * * \b Description: * * This procedure is called when handover succeeded. * Inform Scan Manager about the new AP. * UnMask Roaming Triggers. * * \b ARGS: * * I - hRoamingMngr - roamingMngr SM context \n * * \b RETURNS: * * TI_OK if successful, TI_NOK otherwise. * * */ static void roamingMngr_smSuccHandover(TI_HANDLE hRoamingMngr) { roamingMngr_t *pRoamingMngr; bssEntry_t *pNewConnectedAp; pRoamingMngr = (roamingMngr_t*)hRoamingMngr; TRACE1(pRoamingMngr->hReport, REPORT_SEVERITY_INFORMATION, "roamingMngr_smSuccHandover, candidateApIndex=%d \n", pRoamingMngr->candidateApIndex); if (pRoamingMngr->handoverWasPerformed && (pRoamingMngr->pListOfAPs != NULL) && (pRoamingMngr->pListOfAPs->numOfEntries>0)) { if (pRoamingMngr->candidateApIndex == CURRENT_AP_INDEX) { /* get the current AP */ pNewConnectedAp = apConn_getBSSParams(pRoamingMngr->hAPConnection); } else { /* get the candidate AP */ pNewConnectedAp = &pRoamingMngr->pListOfAPs->BSSList[pRoamingMngr->candidateApIndex]; } scanMngr_handoverDone(pRoamingMngr->hScanMngr, &pNewConnectedAp->BSSID, pNewConnectedAp->band); } pRoamingMngr->maskRoamingEvents = TI_FALSE; pRoamingMngr->candidateApIndex = INVALID_CANDIDATE_INDEX; pRoamingMngr->handoverWasPerformed = TI_FALSE; pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE; /* Start pre-authentication in order to set PMKID for the current AP */ if (pRoamingMngr->staCapabilities.authMode==os802_11AuthModeWPA2) { /* No Pre-Auth is required */ bssList_t *pBssList; pBssList = os_memoryAlloc(pRoamingMngr->hOs, sizeof(bssList_t)); if (!pBssList) { return; } pBssList->numOfEntries = 0; apConn_preAuthenticate(pRoamingMngr->hAPConnection, pBssList); os_memoryFree(pRoamingMngr->hOs, pBssList, sizeof(bssList_t)); } }
/** * \fn busDrv_Create * \brief Create the module * * Create and clear the bus driver's object, and the SDIO-adapter. * * \note * \param hOs - Handle to Os Abstraction Layer * \return Handle of the allocated object, NULL if allocation failed * \sa busDrv_Destroy */ TI_HANDLE busDrv_Create (TI_HANDLE hOs) { TI_HANDLE hBusDrv; TBusDrvObj *pBusDrv; hBusDrv = os_memoryAlloc(hOs, sizeof(TBusDrvObj)); if (hBusDrv == NULL) { return NULL; } pBusDrv = (TBusDrvObj *)hBusDrv; os_memoryZero(hOs, hBusDrv, sizeof(TBusDrvObj)); pBusDrv->hOs = hOs; return pBusDrv; }
/** * mlme_Start - Start event for the MLME SM * * \b Description: * Start event for the MLME SM * * \b ARGS: * I - hMlme - MLME SM context \n * II - connectionType - roaming or initial? with FT (802.11r) or not? * \b RETURNS: * TI_OK if successful, TI_NOK otherwise. * * \sa mlme_Stop, mlme_Recv */ TI_STATUS mlme_start(TI_HANDLE hMlme, TI_UINT8 connectionType) { EConnType econnectionType = (EConnType)connectionType; mlme_t *pMlme = (mlme_t*)hMlme; paramInfo_t *pParam; if (pMlme == NULL) { return TI_NOK; } pParam = (paramInfo_t *)os_memoryAlloc(pMlme->hOs, sizeof(paramInfo_t)); if (pParam == NULL) { return TI_NOK; } pMlme->assocInfo.disAssoc = TI_FALSE; pParam->paramType = RSN_EXT_AUTHENTICATION_MODE; rsn_getParam(pMlme->hRsn, pParam); switch (econnectionType) { case CONN_TYPE_FIRST_CONN: case CONN_TYPE_ROAM: if (AUTH_LEGACY_SHARED_KEY == pParam->content.rsnExtAuthneticationMode) { pMlme->authInfo.authType = AUTH_LEGACY_SHARED_KEY; } else { pMlme->authInfo.authType = AUTH_LEGACY_OPEN_SYSTEM; } break; default: pMlme->authInfo.authType = AUTH_LEGACY_OPEN_SYSTEM; break; } mlme_smEvent(pMlme->hMlmeSm, MLME_SM_EVENT_START, pMlme); return TI_OK; }
static TI_STATUS connInfra_ScrWaitDisconn_to_disconnect(void *pData) { TI_STATUS status; paramInfo_t *pParam; conn_t *pConn = (conn_t *)pData; status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys); if (status != TI_OK) return status; pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t)); if (!pParam) { return TI_NOK; } pParam->paramType = RX_DATA_PORT_STATUS_PARAM; pParam->content.rxDataPortStatus = CLOSE; status = rxData_setParam(pConn->hRxData, pParam); if (status == TI_OK) { /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */ txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_MGMT); pParam->paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM; regulatoryDomain_setParam(pConn->hRegulatoryDomain, pParam); status = mlme_stop( pConn->hMlme, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP ); if (status == TI_OK) { /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the supported rates, and stopModules clears all rates. */ stopModules(pConn, TI_TRUE); /* send disconnect command to firmware */ prepare_send_disconnect(pData); } } os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t)); return status; }
TI_HANDLE txnQ_Create (TI_HANDLE hOs) { TI_HANDLE hTxnQ; TTxnQObj *pTxnQ; TI_UINT32 i; hTxnQ = os_memoryAlloc(hOs, sizeof(TTxnQObj)); if (hTxnQ == NULL) return NULL; pTxnQ = (TTxnQObj *)hTxnQ; os_memoryZero(hOs, hTxnQ, sizeof(TTxnQObj)); pTxnQ->hOs = hOs; pTxnQ->pCurrTxn = NULL; pTxnQ->uMinFuncId = MAX_FUNCTIONS; /* Start at maximum and save minimal value in txnQ_Open */ pTxnQ->uMaxFuncId = 0; /* Start at minimum and save maximal value in txnQ_Open */ #ifdef TI_DBG pTxnQ->pAggregQueue = NULL; #endif for (i = 0; i < MAX_FUNCTIONS; i++) { pTxnQ->aFuncInfo[i].eState = FUNC_STATE_NONE; pTxnQ->aFuncInfo[i].uNumPrios = 0; pTxnQ->aFuncInfo[i].pSingleStep = NULL; pTxnQ->aFuncInfo[i].fTxnQueueDoneCb = NULL; pTxnQ->aFuncInfo[i].hCbHandle = NULL; } /* Create the Bus-Driver module */ pTxnQ->hBusDrv = busDrv_Create (hOs); if (pTxnQ->hBusDrv == NULL) { WLAN_OS_REPORT(("%s: Error - failed to create BusDrv\n", __FUNCTION__)); txnQ_Destroy (hTxnQ); return NULL; } return pTxnQ; }
TI_HANDLE EvHandler_Create (TI_HANDLE hOs) { TEvHandlerObj *pEvHandler; PRINT(DBG_INIT_LOUD, (" EvHandlerInit\n")); pEvHandler = os_memoryAlloc(hOs,sizeof(TEvHandlerObj)); os_memoryZero(hOs,pEvHandler,sizeof(TEvHandlerObj)); #ifdef EV_HANDLER_DEBUG ghEvHandler= pEvHandler; PRINTF(DBG_INIT_VERY_LOUD, ("EvHandlerInit: ghEvHandler set to %08X\n", ghEvHandler)); #endif pEvHandler->hOs = hOs; pEvHandler->LastUMEventType = 0xFFFFFFFF; IPCKernelInit(hOs, NULL); return (TI_HANDLE) pEvHandler; }
/** * \fn cmdDispatch_Create * \brief Create the module * * Create the Command-Dispatcher module * * \note * \param hOs - Handle to the Os Abstraction Layer * \return Handle to the allocated module (NULL if failed) * \sa */ TI_HANDLE cmdDispatch_Create (TI_HANDLE hOs) { TCmdDispatchObj *pCmdDispatch; /* allocate CmdDispatcher module */ pCmdDispatch = os_memoryAlloc (hOs, (sizeof(TCmdDispatchObj))); if (!pCmdDispatch) { WLAN_OS_REPORT(("Error allocating the CmdDispatcher Module\n")); return NULL; } /* Reset CmdDispatcher module */ os_memoryZero (hOs, pCmdDispatch, (sizeof(TCmdDispatchObj))); pCmdDispatch->hOs = hOs; return (TI_HANDLE)pCmdDispatch; }
TI_HANDLE MacServices_create( TI_HANDLE hOS) { MacServices_t *pMacServices = (MacServices_t*)os_memoryAlloc( hOS, sizeof(MacServices_t) ); if ( NULL == pMacServices ) { WLAN_OS_REPORT( ("ERROR: Failed to create Mac SRV module") ); return NULL; } /* nullify all handles, so that only handles in existence will be released */ pMacServices->hScanSRV = NULL; pMacServices->hPowerSrv = NULL; /* create the scanSRV handle */ pMacServices->hScanSRV = MacServices_scanSRV_create(hOS); if ( NULL == pMacServices->hScanSRV ) { MacServices_destroy( pMacServices ); return NULL; } /* create the measurment handle */ pMacServices->hMeasurementSRV = MacServices_measurementSRV_create( hOS ); if ( NULL == pMacServices->hMeasurementSRV ) { MacServices_destroy(pMacServices); return NULL; } pMacServices->hPowerSrv = powerSrv_create(hOS); if (NULL == pMacServices->hPowerSrv ) { MacServices_destroy(pMacServices); return NULL; } /* store OS handle */ pMacServices->hOS = hOS; return pMacServices; }
/** * \fn cmdHndlr_Create * \brief Create the module * * Create the module object * * \note * \param hOs - Handle to the Os Abstraction Layer * \return Handle to the allocated module (NULL if failed) * \sa */ TI_HANDLE cmdHndlr_Create (TI_HANDLE hOs, TI_HANDLE hEvHandler) { TCmdHndlrObj *pCmdHndlr = (TCmdHndlrObj *) os_memoryAlloc (hOs, sizeof(TCmdHndlrObj)); if (pCmdHndlr == NULL) { return NULL; } os_memoryZero (hOs, (void *)pCmdHndlr, sizeof(TCmdHndlrObj)); pCmdHndlr->hOs = hOs; pCmdHndlr->hCmdInterpret = cmdInterpret_Create (hOs); if (pCmdHndlr->hCmdInterpret == NULL) { cmdHndlr_Destroy ((TI_HANDLE) pCmdHndlr, (TI_HANDLE) hEvHandler); return NULL; } return (TI_HANDLE) pCmdHndlr; }
/** * \fn busDrv_Create * \brief Create the module * * Allocate and clear the module's object. * * \note * \param hOs - Handle to Os Abstraction Layer * \return Handle of the allocated object, NULL if allocation failed * \sa busDrv_Destroy */ TI_HANDLE busDrv_Create (TI_HANDLE hOs) { TI_HANDLE hBusDrv; TBusDrvObj *pBusDrv; hBusDrv = os_memoryAlloc(hOs, sizeof(TBusDrvObj)); if (hBusDrv == NULL) return NULL; pBusDrv = (TBusDrvObj *)hBusDrv; os_memoryZero(hOs, hBusDrv, sizeof(TBusDrvObj)); pBusDrv->hOs = hOs; // addapt to WSPI pBusDrv->hWspi= WSPI_Open(hOs); return pBusDrv; }
/**************************************************************************************** * os_memoryCAlloc() **************************************************************************************** DESCRIPTION: Allocates an array in memory with elements initialized to 0. ARGUMENTS: OsContext - our adapter context. Number - Number of elements Size - Length in bytes of each element RETURN: None NOTES: *****************************************************************************************/ void* os_memoryCAlloc( TI_HANDLE OsContext, TI_UINT32 Number, TI_UINT32 Size ) { void* pAllocatedMem; TI_UINT32 MemSize; MemSize = Number * Size; pAllocatedMem = os_memoryAlloc(OsContext, MemSize); if(!pAllocatedMem) return NULL; memset(pAllocatedMem,0,MemSize); return pAllocatedMem; }
/** * \fn sme_Create * \brief Creates the SME module. Allocates system resources * * Creates the SME module. Allocates system resources * * \param hOS - handle to the OS adaptation layer * \return Handle to the SME object * \sa sme_Init, sme_SetDefaults, sme_Destroy */ TI_HANDLE sme_Create (TI_HANDLE hOS) { TSme *pSme; /* allocate space for the SME object */ pSme = (TSme*)os_memoryAlloc (hOS, sizeof (TSme)); if (NULL == pSme) { WLAN_OS_REPORT (("sme_Create: unable to allocate memor yfor SME object. SME craetion failed\n")); return NULL; } /* nullify SME object */ os_memoryZero (hOS, (void*)pSme, sizeof (TSme)); /* store OS handle */ pSme->hOS = hOS; /* Create SME generic state-machine */ pSme->hSmeSm = genSM_Create (hOS); if (NULL == pSme->hSmeSm) { WLAN_OS_REPORT (("sme_Create: unable to create SME generic SM. SME creation failed\n")); sme_Destroy ((TI_HANDLE)pSme); return NULL; } /* Create SME scan result table */ pSme->hScanResultTable = scanResultTable_Create (hOS); if (NULL == pSme->hScanResultTable) { WLAN_OS_REPORT (("sme_Create: unable to create scan result table. SME creation failed\n")); sme_Destroy ((TI_HANDLE)pSme); return NULL; } return (TI_HANDLE)pSme; }
/**************************************************************************************** * os_memoryAlloc() **************************************************************************************** DESCRIPTION: Allocates resident (nonpaged) system-space memory. ARGUMENTS: OsContext - our adapter context. Size - Specifies the size, in bytes, to be allocated. RETURN: Pointer to the allocated memory. NULL if there is insufficient memory available. NOTES: With the call to vmalloc it is assumed that this function will never be called in an interrupt context. vmalloc has the potential to sleep the caller while waiting for memory to become available. *****************************************************************************************/ void *mem_Alloc(TI_HANDLE hMem, TI_UINT32 size) { TMemMng *pMemMng = (TMemMng *) hMem; TMemBlock *pMemBlock; TI_UINT32 total = size + sizeof(TMemBlock) + sizeof(TI_UINT32); #ifdef TI_MEM_ALLOC_TRACE os_printf("mem_Alloc(0x%p, %lu) : %u\n", hMem, size, uTotalSize); #endif pMemBlock = (TMemBlock *) os_memoryAlloc(pMemMng->hOs, total); pMemBlock->size = size; pMemBlock->signature = MEM_BLOCK_START; *(TI_UINT32 *) ((TI_UINT8 *) pMemBlock + total - sizeof(TI_UINT32)) = MEM_BLOCK_END; pMemMng->uCurAllocated += total; if (pMemMng->uMaxAllocated < pMemMng->uCurAllocated) { pMemMng->uMaxAllocated = pMemMng->uCurAllocated; } return (void *)((TI_UINT8 *) pMemBlock + sizeof(TMemBlock)); }
/* STOP_MLME, SET_DATA_PORT_CLOSE, DIS_JOIN */ static TI_STATUS mlmeWait_to_WaitDisconnect(void *pData) { TI_STATUS status; paramInfo_t *pParam; conn_t *pConn = (conn_t *)pData; status = mlme_stop( pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP ); if (status != TI_OK) return status; pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t)); if (!pParam) { return TI_NOK; } pParam->paramType = RX_DATA_PORT_STATUS_PARAM; pParam->content.rxDataPortStatus = CLOSE; rxData_setParam(pConn->hRxData, pParam); /* Update TxMgmtQueue SM to close Tx path. */ txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_CLOSE); /* Start the disconnect complete time out timer. Disconect Complete event, which stops the timer. */ tmr_StartTimer (pConn->hConnTimer, conn_timeout, (TI_HANDLE)pConn, DISCONNECT_TIMEOUT_MSEC, TI_FALSE); /* FW will send the disconn frame according to disConnType */ TWD_CmdFwDisconnect (pConn->hTWD, pConn->disConnType, pConn->disConnReasonToAP); #ifdef XCC_MODULE_INCLUDED XCCMngr_updateIappInformation(pConn->hXCCMngr, XCC_DISASSOC); #endif os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t)); return TI_OK; }
/** * \fn smeSm_Connect * \brief Starts a connection process with the selected network * * Starts a connection process with the selected network * * \param hSme - handle to the SME object * \return None * \sa smeSm_PreConnect, smeSm_ConnectSuccess */ void smeSm_Connect (TI_HANDLE hSme) { TSme *pSme = (TSme*)hSme; TI_STATUS tStatus; paramInfo_t *pParam; /* Sanity check - if no connection candidate was found so far */ if (NULL == pSme->pCandidate) { sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme); } else { pParam = (paramInfo_t *)os_memoryAlloc(pSme->hOS, sizeof(paramInfo_t)); if (!pParam) { return; } /* set SCR group */ if (BSS_INFRASTRUCTURE == pSme->pCandidate->bssType) { scr_setGroup (pSme->hScr, SCR_GID_CONNECT); } /***************** Config Connection *************************/ pParam->paramType = CONN_TYPE_PARAM; if (BSS_INDEPENDENT == pSme->pCandidate->bssType) if (SITE_SELF == pSme->pCandidate->siteType) { pParam->content.connType = CONNECTION_SELF; } else { pParam->content.connType = CONNECTION_IBSS; } else pParam->content.connType = CONNECTION_INFRA; conn_setParam(pSme->hConn, pParam); os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t)); /* start the connection process */ tStatus = conn_start (pSme->hConn, CONN_TYPE_FIRST_CONN, sme_ReportConnStatus, hSme, TI_FALSE, TI_FALSE); } }
/** * \fn tmr_CreateTimer * \brief Create a new timer * * Create a new timer object, icluding creating a timer in the OS-API. * * \note This timer creation may be used only after tmr_Create() and tmr_Init() were executed!! * \param hTimerModule - The module handle * \return TI_HANDLE - The created timer handle * \sa tmr_DestroyTimer */ TI_HANDLE tmr_CreateTimer (TI_HANDLE hTimerModule) { TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; /* The timer module handle */ TTimerInfo *pTimerInfo; /* The created timer handle */ if (!pTimerModule) { WLAN_OS_REPORT (("tmr_CreateTimer(): ERROR - NULL timer!\n")); return NULL; } /* Allocate timer object */ pTimerInfo = os_memoryAlloc (pTimerModule->hOs, sizeof(TTimerInfo)); if (!pTimerInfo) { WLAN_OS_REPORT (("tmr_CreateTimer(): Timer allocation failed!!\n")); return NULL; } os_memoryZero (pTimerModule->hOs, pTimerInfo, (sizeof(TTimerInfo))); /* Allocate OS-API timer, providing the common expiry callback with the current timer handle */ pTimerInfo->hOsTimerObj = os_timerCreate(pTimerModule->hOs, tmr_GetExpiry, (TI_HANDLE)pTimerInfo); if (!pTimerInfo->hOsTimerObj) { TRACE0(pTimerModule->hReport, REPORT_SEVERITY_CONSOLE ,"tmr_CreateTimer(): OS-API Timer allocation failed!!\n"); os_memoryFree (pTimerModule->hOs, pTimerInfo, sizeof(TTimerInfo)); WLAN_OS_REPORT (("tmr_CreateTimer(): OS-API Timer allocation failed!!\n")); return NULL; } /* Save the timer module handle in the created timer object (needed for the expiry callback) */ pTimerInfo->hTimerModule = hTimerModule; pTimerModule->uTimersCount++; /* count created timers */ /* Return the created timer handle */ return (TI_HANDLE)pTimerInfo; }
/* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */ static TI_STATUS rsnWait_to_disconnect(void *pData) { TI_STATUS status; paramInfo_t *pParam; conn_t *pConn = (conn_t *)pData; status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys); if (status != TI_OK) return status; pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t)); if (!pParam) { return TI_NOK; } pParam->paramType = RX_DATA_PORT_STATUS_PARAM; pParam->content.rxDataPortStatus = CLOSE; status = rxData_setParam(pConn->hRxData, pParam); os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t)); if (status != TI_OK) return status; /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */ txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_MGMT); status = mlme_stop( pConn->hMlme, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP ); if (status != TI_OK) return status; /* send disconnect command to firmware */ prepare_send_disconnect(pData); return TI_OK; }
/** * * mlme_Create - allocate memory for MLME SM * * \b Description: * Allocate memory for MLME SM. \n * Allocates memory for MLME context. \n * Allocates memory for MLME timer. \n * Allocates memory for MLME SM matrix. \n * * \b ARGS: * I - pOs - OS context \n * * \b RETURNS: * TI_OK if successful, TI_NOK otherwise. * * \sa rsn_mainSecSmKeysOnlyStop() */ TI_HANDLE mlme_create(TI_HANDLE hOs) { mlme_t *pHandle; /* allocate MLME context memory */ pHandle = (mlme_t*)os_memoryAlloc(hOs, sizeof(mlme_t)); if (pHandle == NULL) { return NULL; } /* nullify the MLME object */ os_memoryZero(hOs, (void*)pHandle, sizeof(mlme_t)); pHandle->hMlmeSm = genSM_Create (hOs); if (NULL == pHandle->hMlmeSm) { WLAN_OS_REPORT (("mlme_Create: unable to create MLME generic SM. MLME creation failed\n")); mlme_destroy ((TI_HANDLE)pHandle); return NULL; } pHandle->hOs = hOs; return pHandle; }