示例#1
0
/** 
 * \fn     cmdHndlr_Complete 
 * \brief  called whenever a command has finished executing
 * 
 * This routine is called whenever a command has finished executing.
 * Either called by the cmdHndlr_HandleCommands if completed in the same context, 
 *     or by the CmdInterpreter module when tcompleted in a later context (Async).
 * 
 * \note    
 * \param  hCmdHndlr - The module object
 * \return void
 * \sa     cmdHndlr_InsertCommand, cmdHndlr_HandleCommands
 */ 
void cmdHndlr_Complete (TI_HANDLE hCmdHndlr)
{
    TCmdHndlrObj *pCmdHndlr = (TCmdHndlrObj *)hCmdHndlr;
    TI_BOOL       bLocalWaitFlag;

    if (pCmdHndlr->pCurrCmd)
    {
        /* set Status to COMPLETE */
        pCmdHndlr->pCurrCmd->eCmdStatus = TI_OK;
    
        /* save the wait flag before free semaphore */
        bLocalWaitFlag = pCmdHndlr->pCurrCmd->bWaitFlag;

        wlanDrvIf_CommandDone(pCmdHndlr->hOs, pCmdHndlr->pCurrCmd->pSignalObject, pCmdHndlr->pCurrCmd->CmdRespBuffer); 

        /* if cmdHndlr_InsertCommand() not wait to cmd complete? */
        if (TI_FALSE == bLocalWaitFlag)
        {
            /* no wait, free the command memory */
            os_memoryFree (pCmdHndlr->hOs, pCmdHndlr->pCurrCmd, sizeof (TConfigCommand));
        }

        pCmdHndlr->pCurrCmd = NULL;

        return;
    }

    TRACE0(pCmdHndlr->hReport, REPORT_SEVERITY_ERROR, "cmdHndlr_Complete(): pCurrCmd is NULL!\n");
}
示例#2
0
/** 
 * \fn     cmdHndlr_HandleCommands 
 * \brief  Handle queued commands
 * 
 * While there are queued commands, dequeue a command and call the 
 *     commands interpreter (OID or WEXT selected at compile time).
 * If the command processing is not completed in this context (pending), we exit and 
 *     this function is called again upon commnad completion, so it can continue processing 
 *     further queued commands (if any).
 * 
 * \note    
 * \param  hCmdHndlr - The module object
 * \return void
 * \sa     cmdHndlr_InsertCommand, cmdHndlr_Complete
 */
void cmdHndlr_HandleCommands(TI_HANDLE hCmdHndlr)
{
	TCmdHndlrObj *pCmdHndlr = (TCmdHndlrObj *) hCmdHndlr;

	while (1) {
		/* Enter critical section to protect queue access */
		context_EnterCriticalSection(pCmdHndlr->hContext);

		/* Dequeue a command */
		pCmdHndlr->pCurrCmd =
		    (TConfigCommand *) que_Dequeue(pCmdHndlr->hCmdQueue);

		/* If we have got a command */
		if (pCmdHndlr->pCurrCmd) {
			/* Leave critical section */
			context_LeaveCriticalSection(pCmdHndlr->hContext);

			/* Convert to driver structure and execute command */
			pCmdHndlr->pCurrCmd->eCmdStatus =
			    cmdInterpret_convertAndExecute(pCmdHndlr->
							   hCmdInterpret,
							   pCmdHndlr->pCurrCmd);

			/* 
			 *  If command not completed in this context (Async), return.
			 *    (we'll be called back upon command completion) 
			 */
			if (COMMAND_PENDING == pCmdHndlr->pCurrCmd->eCmdStatus) {
				return;
			}

			/* Command was completed so free the wait signal and continue to next command */
			wlanDrvIf_CommandDone(pCmdHndlr->hOs,
					      pCmdHndlr->pCurrCmd->
					      pSignalObject,
					      pCmdHndlr->pCurrCmd->
					      CmdRespBuffer);

			pCmdHndlr->pCurrCmd = NULL;

		}

		/* Else, we don't have commands to handle */
		else {
			/* Indicate that we are not handling commands (before leaving critical section!) */
			pCmdHndlr->bProcessingCmds = TI_FALSE;

			/* Leave critical section */
			context_LeaveCriticalSection(pCmdHndlr->hContext);

			/* Exit (no more work) */
			return;
		}
	}
}