Exemplo n.º 1
0
/* HEX DUMP for BDs !!! Debug code only !!! */
mcpf_res_t report_PrintDump (McpU8 *pData, McpU32 datalen)
{
#ifdef _DEBUG
    McpS32  dbuflen=0;
    McpU32 j;
    char   dbuf[50];
    static const char hexdigits[16] = "0123456789ABCDEF";

    for(j=0; j < datalen;)
    {
        /* Add a byte to the line*/
        dbuf[dbuflen] =  hexdigits[(pData[j] >> 4)&0x0f];
        dbuf[dbuflen+1] = hexdigits[pData[j] & 0x0f];
        dbuf[dbuflen+2] = ' ';
        dbuf[dbuflen+3] = '\0';
        dbuflen += 3;
        j++;
        if((j % 16) == 0)
        {
            /* Dump a line every 16 hex digits*/
            MCPF_OS_REPORT(("%04.4x  %s\n", j-16, dbuf));
            dbuflen = 0;
        }
    }
    /* Flush if something has left in the line*/
    if(dbuflen)
        MCPF_OS_REPORT(("%04.4x  %s\n", j & 0xfff0, dbuf));
#else
    MCP_UNUSED_PARAMETER(pData);
    MCP_UNUSED_PARAMETER(datalen);
#endif
    return E_COMPLETE;
}
Exemplo n.º 2
0
/**
 * \fn     stPortRxStart
 * \brief  ST port receive start
 *
 * Resets and start ST receive operation
 *
 * \note
 * \param   pHalSt  - pointer to HAL ST object
 * \return  Returns the status of operation: OK or Error
 * \sa      HAL_ST_Init
 */
static EMcpfRes stPortRxStart (THalStObj *pHalSt, McpU8 *pBuf, McpU16 len)
{
    /* Activate DTR line */
    MCP_UNUSED_PARAMETER(pHalSt);
    MCP_UNUSED_PARAMETER(pBuf);
    MCP_UNUSED_PARAMETER(len);
    return RES_OK;
}
Exemplo n.º 3
0
/**
 * \fn     HAL_ST_Port_Reset
 * \brief  reset and optionally start HAL ST  hardware to
 * 
 * 
 */ 
EMcpfRes HAL_ST_Port_Reset (handle_t  *hHalSt, McpU8 *pBuf, McpU16 len, const McpU16 baudrate)
{
    THalStObj     *pHalSt = (THalStObj *) hHalSt;

    MCP_UNUSED_PARAMETER(pBuf);
    MCP_UNUSED_PARAMETER(len);

    pHalSt->tPortCfg.uBaudRate = (McpU32)baudrate;
    return stPortConfig(pHalSt);
}
void MCP_BTS_SP_HciCmdCompleted(McpBtsSpContext *context, 
                                McpU8 *eventParms,
                                McpU8 eventParmsLen)
{
    MCP_UNUSED_PARAMETER(eventParms);
    MCP_UNUSED_PARAMETER(eventParmsLen);
    
/* 
    [ToDo] The eventParms currentl doens't include the HCI opcode, event status, etc. Only the HCI return parms 

    Need to see how to handle this in FMC_Transport
*/
#if 0   
    McpBtsSpStatus spStatus;

    /* Initialize to an invalid event status (in case there is no status available in the event parameters) */
    McpBtsSpHciEventStatus  eventStatus = (McpBtsSpHciEventStatus)0xFF;

    /* Extract event status from parms */
    if (eventParmsLen >= MCP_BTS_SP_HCI_EVENT_STATUS_OFFSET)
    {
        eventStatus = eventParms[MCP_BTS_SP_HCI_EVENT_STATUS_OFFSET];
    }
    
    if (eventType != MCP_BTS_SP_HCI_EVENT_COMMAND_COMPLETE)
    {
        MCP_LOG_FATAL(("MCP_BTS_SP_HciCmdCompleted: Unexpected HCI Event (%d), Status: %d",
                       eventType,
                       eventStatus));   
        _MCP_BTS_SP_CompleteExecution(context,
                                      MCP_BTS_SP_STATUS_EXECUTION_FAILED_UNEXPECTED_HCI_EVENT);
        return;
    }

    /* Now we know we have the expected command complete event */

    /* verify that the command completed successfully */
    if (eventStatus != MCP_BTS_SP_HCI_EVENT_STATUS_SUCCESS)
    {
        MCP_LOG_FATAL(("MCP_BTS_SP_HciCmdCompleted: Command completed unsuccessfully (%d)",
                       eventStatus));  
        _MCP_BTS_SP_CompleteExecution(context,
                                      MCP_BTS_SP_STATUS_EXECUTION_FAILED_COMMAND_FAILED);
        return;
    }
    
#endif

    /* [ToDo] - Pass the command complete status as the event data (instead of the 3rd argument) */
    _MCP_BTS_SP_ProcessScriptCommands(context, MCP_BTS_SP_PROCESSING_EVENT_COMMAND_COMPLETE, NULL);
}
Exemplo n.º 5
0
MCP_STATIC void MCP_LM_Abort(void *pUserData)
{
    McpBtsSpStatus  status;

    MCP_FUNC_START("MCP_LM_Abort");

    MCP_UNUSED_PARAMETER(pUserData);

    /* Abort script execution */
    status = MCP_BTS_SP_AbortScriptExecution(&(context));

    /* Set the return status according to script processor reply */
    switch (status)
    {
        case MCP_BTS_SP_STATUS_SUCCESS:
        case MCP_BTS_SP_STATUS_EXECUTION_ABORTED:
            iLoadSmstatus = MCP_HAL_STATUS_SUCCESS;
            break;

        case MCP_BTS_SP_STATUS_PENDING:
            iLoadSmstatus = MCP_HAL_STATUS_PENDING;
            break;

        default:
            iLoadSmstatus = MCP_HAL_STATUS_FAILED;
            break;
    }

    MCP_FUNC_END();
}
Exemplo n.º 6
0
/*------------------------------------------------------------------------------
 *       Call back function for the script processor to send an HCI command
 *------------------------------------------------------------------------------
 */
McpBtsSpStatus MCP_LM_SendHciCmdCB (McpBtsSpContext *context,
                                    McpU16 hciOpcode, 
                                    McpU8 *hciCmdParms, 
                                    McpUint hciCmdParmsLen)
{
    McpBtsSpStatus          status = MCP_BTS_SP_STATUS_PENDING;
    BtHciIfStatus           btHciIfStatus;

    MCP_FUNC_START("MCP_LM_SendHciCmdCB");

    MCP_UNUSED_PARAMETER(context);

    btHciIfStatus = BT_HCI_IF_SendHciCommand(handle,   
                                              (BtHciIfHciOpcode)hciOpcode, 
                                             hciCmdParms, 
                                             (McpU8)hciCmdParmsLen,                                          
                                             BT_HCI_IF_HCI_EVENT_COMMAND_COMPLETE,
                                             NULL);

    MCP_VERIFY_ERR((btHciIfStatus == BT_HCI_IF_STATUS_PENDING), MCP_BTS_SP_STATUS_FAILED,
                   ("MCP_LM_SendHciCmdCB: BT_HCI_IF_SendHciCommand Failed"));

    MCP_FUNC_END();

    return status;
}
Exemplo n.º 7
0
/*------------------------------------------------------------------------------
 *            Callback function for script execution complete
 *------------------------------------------------------------------------------
 */
void MCP_LM_ExcutionCompleteCB(McpBtsSpContext *context, McpBtsSpStatus status)
{
    MCP_FUNC_START("MCP_LM_ExcutionCompleteCB");

    MCP_UNUSED_PARAMETER(context);

    if (status == MCP_BTS_SP_STATUS_EXECUTION_ABORTED)
    {
        /* Abort was completed successfully sent anMCP_LM_EVENT_ABORT_DONE to the SM */
        MCP_GenSM_Event (&tDataGenSm, MCP_LM_EVENT_ABORT_DONE, NULL);
    }

    else if (status == MCP_BTS_SP_STATUS_SUCCESS)
    {
        /* Load script was successfully sent an event to SM that the load is done */
        MCP_GenSM_Event (&tDataGenSm, MCP_LM_EVENT_LOAD_DONE, NULL);
    }
    else
    {
        /* Load script fail send an event to SM */
        MCP_GenSM_Event(&tDataGenSm, MCP_LM_EVENT_LOAD_FAIL, NULL);
    }

    fCb (status, pUserData);

    MCP_FUNC_END();
}
Exemplo n.º 8
0
/*
    This function receives all the notification from the child BtTranOnSm instance. It maps the notification
    to an SM engine event and calls the engine to process the event
*/
void _CCM_IM_BtTranSm_TranOnSmCb(_CcmIm_BtTranOnSm_CompletionEvent *event)
{
    _CcmIm_BtTranSm_Obj *btTranSmObj = &_ccmIm_BtTranSm_Data.smObjs[event->chipId];

    MCP_FUNC_START("_CCM_IM_BtTranSm_TranOnSmCb");

    MCP_UNUSED_PARAMETER(event);

    if (event->completionStatus == _CCM_IM_STATUS_SUCCESS)
    {
        _CCM_IM_BtTranSm_InternalHandleEvent(btTranSmObj, _CCM_IM_BT_TRAN_SM_EVENT_TRAN_ON_COMPLETE, NULL);
    }
    else if (event->completionStatus == _CCM_IM_STATUS_TRAN_ON_ABORTED)
    {
        _CCM_IM_BtTranSm_InternalHandleEvent(btTranSmObj, _CCM_IM_BT_TRAN_SM_EVENT_TRAN_ON_ABORT_COMPLETE, NULL);
    }
    else if (event->completionStatus == _CCM_IM_STATUS_FAILED)
    {
        _CCM_IM_BtTranSm_InternalHandleEvent(btTranSmObj, _CCM_IM_BT_TRAN_SM_EVENT_TRAN_ON_FAILED, NULL);
    }
    else
    {
        MCP_FATAL_NO_RETVAR(("_CCM_IM_BtTranSm_TranOnSmCb: Unexpected Completion Status (%d)", event->completionStatus));
    }

    MCP_FUNC_END();
}
Exemplo n.º 9
0
/**
 * \fn     stPortRxReset
 * \brief  ST port receive reset
 *
 * Purges ST device input buffer and triggers the new receive operation
 *
 * \note
 * \param   pHalSt  - pointer to HAL ST object
 * \return  Returns the status of operation: OK or Error
 * \sa      stPortRxStart
 */
static EMcpfRes stPortRxReset (THalStObj *pHalSt, McpU8 *pBuf, McpU16 len)
{
    McpS32	iReadNum, iRetCode;
    
    MCP_UNUSED_PARAMETER(len);

	/* 
	 * Read and discard all available bytes from ST port input buffer.
	 * ReadFile returns 0 when fails (no more data to read or error)
	 */

    iRetCode = ioctl (pHalSt->hOsPort, FIONREAD, &iReadNum);

    MCPF_REPORT_DEBUG_CONTROL(pHalSt->hMcpf, HAL_ST_MODULE_LOG, ("%s: Rx queue  res=%d avail=%d\n", __FUNCTION__, iRetCode, iReadNum));

    /* read available number of bytes from ST input queue */
    iRetCode = read (pHalSt->hOsPort, pBuf, iReadNum);
    if (iRetCode < 0)
    {
        MCPF_REPORT_ERROR (pHalSt->hMcpf, HAL_ST_MODULE_LOG,
                           ("%s: Read failed, err=%u\n", __FUNCTION__, errno));
		return RES_ERROR;
    }
	return RES_OK;
}
Exemplo n.º 10
0
/*
    This function is called during the On-Abort process. It is called when the transport off process completed.
    Now the transport is back in the off state.
*/
_CcmImStatus _CCM_IM_BtTranSm_HandlerOnAbortedOffCompleted(_CcmIm_BtTranSm_Obj *thisObj, void *eventData)
{
    MCP_UNUSED_PARAMETER(eventData);
    
    return _CCM_IM_BtTranSm_PerformCompletion(thisObj, 
                                                _CCM_IM_BT_TRAN_SM_COMPLETED_EVENT_TRAN_ON_ABORT_COMPLETED,
                                                _CCM_IM_STATUS_SUCCESS);
}
Exemplo n.º 11
0
MCP_STATIC void MCP_LM_Nothing (void *pUserData)
{   
    MCP_FUNC_START("MCP_LM_Nothing");

    MCP_UNUSED_PARAMETER(pUserData);

    MCP_FUNC_END();
}
Exemplo n.º 12
0
/*-------------------------------------------------------------------------------
 * CCM_HAL_PWR_UP_DWN_Shutdown()
 *
 *		Shutdowns BT Host Controller chip.
 */
CcmHalPwrUpDwnStatus CCM_HAL_PWR_UP_DWN_Shutdown(McpHalChipId	chipId, McpHalCoreId coreId)
{
	MCP_UNUSED_PARAMETER(chipId);
	MCP_UNUSED_PARAMETER(coreId);

    if (_ccmHalPwrUpDwn_PinRefCount > 0)
    	--_ccmHalPwrUpDwn_PinRefCount;

	/* Actually Shut Down only when the last core requests shutdown */
	if (_ccmHalPwrUpDwn_PinRefCount == 0)
	{
    	if (CCM_HAL_PWR_UP_DWN_STATUS_SUCCESS != CCM_HAL_PWR_UP_DWN_ResetPin(BTENABLE_FILE_NAME))
	    	return CCM_HAL_PWR_UP_DWN_STATUS_FAILED;
	}
    
	return CCM_HAL_PWR_UP_DWN_STATUS_SUCCESS;
}
Exemplo n.º 13
0
/*
    This function receives all the notification from the child BtTranOffSm instance. It maps the notification
    to an SM engine event and calls the engine to process the event
*/
void _CCM_IM_BtTranSm_TranOffSmCb(_CcmIm_BtTranOffSm_CompletionEvent *event)
{
    _CcmIm_BtTranSm_Obj *btTranSmObj = &_ccmIm_BtTranSm_Data.smObjs[event->chipId];

    MCP_UNUSED_PARAMETER(event);
    
    _CCM_IM_BtTranSm_InternalHandleEvent(btTranSmObj, _CCM_IM_BT_TRAN_SM_EVENT_TRAN_OFF_COMPLETE, NULL);
}
Exemplo n.º 14
0
/**
 * \fn     HAL_ST_RestartRead
 * \brief  Signals to start read operation
 *
 */
EMcpfRes HAL_ST_RestartRead (const handle_t  hHalSt)
{
    handle_t  lHalSt = hHalSt; /* reduce compiler warnings*/
    
    MCP_UNUSED_PARAMETER(lHalSt);
    /* Nothing to do, the read is not stopped */
    return RES_OK;
}
Exemplo n.º 15
0
MCP_STATIC void MCP_LM_ActionUnexpected(void *pUserData)
{

    MCP_FUNC_START("MCP_LM_ActionUnexpected");

    MCP_UNUSED_PARAMETER(pUserData);

    MCP_FUNC_END();
}
Exemplo n.º 16
0
/*
    This function is called when transport on failed
*/
_CcmImStatus _CCM_IM_BtTranSm_HandlerTranOnFailed(_CcmIm_BtTranSm_Obj *thisObj, void *eventData)
{
    MCP_UNUSED_PARAMETER(eventData);

    MCP_LOG_FATAL(("_CCM_IM_BtTranSm_HandlerTranOnFailed: Tran On Failed"));
    
    return _CCM_IM_BtTranSm_PerformCompletion(thisObj, 
                                                _CCM_IM_BT_TRAN_SM_COMPLETED_EVENT_TRAN_ON_COMPLETED,
                                                _CCM_IM_STATUS_FAILED);
}
Exemplo n.º 17
0
MCP_STATIC void MCP_LM_Load_Pending(void *pUserData)
{       
    MCP_FUNC_START("MCP_LM_Load_Pending");

    MCP_UNUSED_PARAMETER (pUserData);

    /* Update Load status return flag */
    iLoadSmstatus = MCP_HAL_STATUS_PENDING;

    MCP_FUNC_END();
}   
Exemplo n.º 18
0
MCP_STATIC void MCP_LM_Load_Success(void *pUserData)
{   

    MCP_FUNC_START("MCP_LM_Load_Success");

    MCP_UNUSED_PARAMETER(pUserData);

    iLoadSmstatus=MCP_BTS_SP_STATUS_SUCCESS;

    MCP_FUNC_END();
}   
Exemplo n.º 19
0
void MCP_LoadMngr_Hci_Cmds_callback(BtHciIfClientEvent *event)
{

    MCP_FUNC_START("MCP_LoadMngr_Hci_Cmds_callback");

    MCP_UNUSED_PARAMETER (event);

    /* The command is finished, proceed to the next command */
    MCP_BTS_SP_HciCmdCompleted (&context, NULL, NULL);

    MCP_FUNC_END();
}
Exemplo n.º 20
0
/*-------------------------------------------------------------------------------
 * CCM_HAL_PWR_UP_DWN_Reset()
 *
 *		Resets BT Host Controller chip.
 */
CcmHalPwrUpDwnStatus CCM_HAL_PWR_UP_DWN_Reset(McpHalChipId	chipId, McpHalCoreId coreId)
{
	MCP_UNUSED_PARAMETER(chipId);
	MCP_UNUSED_PARAMETER(coreId);

	if (_ccmHalPwrUpDwn_PinRefCount == 0)
	{
    	if (CCM_HAL_PWR_UP_DWN_STATUS_SUCCESS != CCM_HAL_PWR_UP_DWN_ResetPin(BTENABLE_FILE_NAME))
	    	return CCM_HAL_PWR_UP_DWN_STATUS_FAILED;

       	usleep(5000);

    	if (CCM_HAL_PWR_UP_DWN_STATUS_SUCCESS != CCM_HAL_PWR_UP_DWN_SetPin(BTENABLE_FILE_NAME))
	    	return CCM_HAL_PWR_UP_DWN_STATUS_FAILED;
    		
       	usleep(10000);
    }


	++_ccmHalPwrUpDwn_PinRefCount;
    

	return CCM_HAL_PWR_UP_DWN_STATUS_SUCCESS;
}
Exemplo n.º 21
0
/*
    This function is called to abort the transport on process

    The event is forwarded to tran_on_sm that should handle it according to its state
*/
_CcmImStatus _CCM_IM_BtTranSm_HandlerAbortOn(_CcmIm_BtTranSm_Obj *thisObj, void *eventData)
{
    _CcmImStatus    status;

    MCP_FUNC_START("_CCM_IM_BtTranSm_HandlerAbortOn");
    
    MCP_UNUSED_PARAMETER(eventData);

    status  = _CCM_IM_BtTranOnSm_HandleEvent(   thisObj->tranOnSmObj,
                                                _CCM_IM_BT_TRAN_ON_SM_EVENT_ABORT,
                                                NULL);
    MCP_VERIFY_FATAL((status == _CCM_IM_STATUS_PENDING), status, ("_CCM_IM_BtTranOnSm_HandleEvent"));
    
    MCP_FUNC_END();

    return status;
}
Exemplo n.º 22
0
/*
    This function is called to shutdown the BT transport

    The tran_off_sm will be called to handle that
*/
_CcmImStatus _CCM_IM_BtTranSm_HandlerTranOff(_CcmIm_BtTranSm_Obj *thisObj, void *eventData)
{
    _CcmImStatus    status;

    MCP_FUNC_START("_CCM_IM_BtTranSm_HandlerTranOff");
    
    MCP_UNUSED_PARAMETER(eventData);
    
    status  = _CCM_IM_BtTranOffSm_HandleEvent(  thisObj->tranOffSmObj,
                                                _CCM_IM_BT_TRAN_OFF_SM_EVENT_START,
                                                NULL);
    MCP_VERIFY_FATAL((status == _CCM_IM_STATUS_SUCCESS) || (status == _CCM_IM_STATUS_PENDING), status,
                        ("_CCM_IM_BtTranSm_HandlerTurnTranOff"));
    
    MCP_FUNC_END();

    return status;
}
ECCM_VAC_Status _CCM_VAC_MappingEngine_Configure (TCCM_VAC_MappingEngine *ptMappEngine, 
                                                  TCAL_ResourceSupport *ptAvailResources,
                                                  TCAL_OperationSupport *ptAvailOperations)
{
    McpU32                      uOperationNum, uOperationIndex, uOptResourceNum, uOptResourceIndex, uIndex;
    McpConfigParserStatus       eCPStatus;
    McpU8                       *pTempValue;
    ECAL_Operation              eOperation;
    ECAL_Resource               eResource;
    TCAL_OptionalResource       tTempOptResource;
    ECCM_VAC_Status             status;

    /*
     * The configuration process involves reading chip capabilities and ini file settings 
     * (host capabilities). Chip capabilities are read by the configuration engine and are 
     * set in advance to the mapping engine configuration. This function than read the 
     * mapping section of the ini file. For every operation it read the possible optional 
     * resources and arrange them accordingly. It also read the default resource to be used
     * and set it.
     */

    MCP_FUNC_START ("_CCM_VAC_MappingEngine_Configure");

    MCP_UNUSED_PARAMETER (ptAvailOperations);
    MCP_UNUSED_PARAMETER (ptAvailResources);

    /* read number of operations from ini file */
    eCPStatus = MCP_CONFIG_PARSER_GetIntegerKey (ptMappEngine->pConfigParser, 
                                                 (McpU8 *)CCM_VAC_CONFIG_INI_OPERATIONS_SECTION_NAME,
                                                 (McpU8 *)CCM_VAC_CONFIG_INI_OPERATIONS_NUMBER_KEY_NAME,
                                                 (McpS32 *)&uOperationNum);
    MCP_VERIFY_FATAL (((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS) && (0 < uOperationNum)),
                        CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                        ("_CCM_VAC_MappingEngine_Configure: error reading number of operations "
                         "from file, number: %d, status: %d", uOperationNum, eCPStatus));

    /* for every operation */
    for (uOperationIndex = 0; uOperationIndex < uOperationNum; uOperationIndex++)
    {
        /* read operation */
        eCPStatus = MCP_CONFIG_PARSER_GetAsciiKey (ptMappEngine->pConfigParser,
                                                   (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_SECTION_NAME,
                                                   (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_OP_KEY_NAME,
                                                   &pTempValue);
        MCP_VERIFY_FATAL ((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS),
                          CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                          ("_CCM_VAC_MappingEngine_Configure: error reading operation name, status: %d",
                           eCPStatus));

        /* convert operation name to enum value */
        eOperation = StringtoOperation ((const McpU8*)pTempValue);
        MCP_VERIFY_FATAL ((CAL_OPERATION_INVALID != eOperation),
                          CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                          ("_CCM_VAC_MappingEngine_Configure: erro converting string %s to operation",
                           pTempValue));

        /* read number of optional resources */
        eCPStatus = MCP_CONFIG_PARSER_GetIntegerKey (ptMappEngine->pConfigParser, 
                                                     (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_SECTION_NAME,
                                                     (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_CONFIG_NUM_KEY_NAME,
                                                     (McpS32*)&uOptResourceNum);
        MCP_VERIFY_FATAL ((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS),
                          CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                          ("_CCM_VAC_MappingEngine_Configure: error reading number of optional resources for "
                           "operation %s, status %d",  _CCM_VAC_DebugOperationStr(eOperation), eCPStatus));

        /* for each optional resource */
        for (uOptResourceIndex = 0; uOptResourceIndex < uOptResourceNum; uOptResourceIndex++)
        {
            /* read resource name */
            eCPStatus = MCP_CONFIG_PARSER_GetAsciiKey (ptMappEngine->pConfigParser,
                                                       (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_SECTION_NAME,
                                                       (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_RESOURCE_KEY_NAME,
                                                       &pTempValue);
            MCP_VERIFY_FATAL ((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS),
                              CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                              ("_CCM_VAC_MappingEngine_Configure: error reading resource name (index %d) "
                               "for operation %s, status: %d", uOptResourceIndex, 
                               _CCM_VAC_DebugOperationStr(eOperation), eCPStatus));

            /* convert resource name to enum value */
            eResource = StringtoResource ((const McpU8 *)pTempValue);
            MCP_VERIFY_FATAL ((CAL_RESOURCE_INVALID != eResource),
                              CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                              ("_CCM_VAC_MappingEngine_Configure: error converting string %s to resource",
                               pTempValue));

            /* find the resource entry in the optional resources list */
            for (uIndex = 0; 
                 uIndex < ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.uNumOfResourceLists;
                 uIndex++)
            {
                if (eResource == ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uIndex ].eOptionalResource)
                {
                    break;
                }
            }

            /* verify resource was found */
            MCP_VERIFY_FATAL ((uIndex < ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.uNumOfResourceLists),
                              CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                              ("_CCM_VAC_MappingEngine_Configure: optional resource %s for operation %s in "
                               "ini file is not within chip capabilities", 
                               _CCM_VAC_DebugResourceStr(eResource), _CCM_VAC_DebugOperationStr(eOperation)));

            /* if needed, move it to the beginning of the list */
            if (uIndex > uOptResourceIndex)
            {
                /* copy resource at the list beginning to temp storage */
                MCP_HAL_MEMORY_MemCopy (&tTempOptResource, 
                                        &(ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uOptResourceIndex ]), 
                                        sizeof (TCAL_OptionalResource));

                /* copy found resource to list beginning */
                MCP_HAL_MEMORY_MemCopy (&(ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uOptResourceIndex ]), 
                                        &(ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uIndex ]), 
                                        sizeof (TCAL_OptionalResource));

                /* finally, copy back temp storage to found resource */
                MCP_HAL_MEMORY_MemCopy (&(ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uIndex ]),
                                        &tTempOptResource,
                                        sizeof (TCAL_OptionalResource));
            }

            /* mark the resource as unused */
            ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uOptResourceIndex ].bIsUsed = MCP_FALSE;
        }

        /* set number of possible optional resources */
        ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.uNumOfResourceLists = uOptResourceNum;

        /* if there are optional resources, read and indicate the default optional resource */
        if (0 < uOptResourceNum)
        {
            /* read the default resource */
            eCPStatus = MCP_CONFIG_PARSER_GetAsciiKey (ptMappEngine->pConfigParser,
                                                       (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_SECTION_NAME,
                                                       (McpU8 *)CCM_VAC_CONFIG_INI_MAPPING_DEF_RESOURCE_KEY_NAME,
                                                       &pTempValue);
            MCP_VERIFY_FATAL ((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS),
                              CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                              ("_CCM_VAC_MappingEngine_Configure: error reading default resource name "
                               "for operation %s, status: %d", uOptResourceIndex, 
                               _CCM_VAC_DebugOperationStr(eOperation), eCPStatus));

            /* convert default resource name to enum value */
            eResource = StringtoResource ((const McpU8 *)pTempValue);
            MCP_VERIFY_FATAL ((CAL_RESOURCE_INVALID != eResource),
                              CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                              ("_CCM_VAC_MappingEngine_Configure: error converting string %s to resource",
                               pTempValue));

            /* search default resource within optional resources */
            for (uIndex = 0; 
                 uIndex < ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.uNumOfResourceLists;
                 uIndex++)
            {
                /* if this is the default resource */
                if (eResource == ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uIndex ].eOptionalResource)
                {
                    /* mark it as current mapping for this operation */
                    ptMappEngine->tConfig.tOpToResMap[ eOperation ].tOptionalResources.tOptionalResourceLists[ uIndex ].bIsUsed = MCP_TRUE;
                }
            } 
        }
    }

    MCP_FUNC_END ();

    return CCM_VAC_STATUS_SUCCESS;
}
McpBtsSpStatus _MCP_BTS_SP_MemCloseScript(McpBtsSpContext *context)
{
    MCP_UNUSED_PARAMETER(context);
    
    return MCP_BTS_SP_STATUS_SUCCESS;
}
Exemplo n.º 25
0
/** 
 * \fn     CCMA_SendHciCommand 
 * \brief  Send HCI command over transport layer
 * 
 */ 
CcmaStatus CCMA_SendHciCommand(CcmaClientHandle hClientHandle,
                               CcmaHciOpcode eHciOpcode, 
                               McpU8 *pHciCmdParms, 
                               McpU8 uHciCmdParmsLen,
                               McpU8 uEeventType,
                               void *pUserData)
{
    TClientNode *pClient = (TClientNode *)hClientHandle;
    TCcmaObj *pCcma = (TCcmaObj *)pClient->hCcma;
    CcmaStatus eStatus;
#ifdef MCP_STK_ENABLE
    eHalHciStatus eResult;
#else
    EMcpfRes eRes;
#endif

    MCP_FUNC_START("CCMA_SendHciCommand");

    MCP_UNUSED_PARAMETER(uEeventType);

    /* Save user's data for future use */
    pClient->hClientUserData = pUserData;

#ifdef MCP_STK_ENABLE

    eResult = hal_hci_SendCommand(pCcma->hHalHci, eHciOpcode, 
    								  pHciCmdParms, uHciCmdParmsLen, 
		      						  clientCmdComplete, hClientHandle);

    
    
        if (eResult != HAL_HCI_STATUS_PENDING)
        {
            MCP_LOG_ERROR(("Error writing HCI packet"));
            eStatus = CCMA_STATUS_FAILED;
        }
        else
        {
            eStatus = CCMA_STATUS_PENDING;
        }

#else

	eRes = HCIA_SendCommand(((Tmcpf *)pCcma->hMcpf)->hHcia,
                            (McpU16) eHciOpcode, 
                            pHciCmdParms, 
                            uHciCmdParmsLen,
                            clientCmdComplete, 
                            hClientHandle);
    
	if (eRes == RES_OK)
	{
		eStatus = CCMA_STATUS_PENDING;
	}
	else
	{
		eStatus = CCMA_STATUS_FAILED;
	}

#endif
	
	MCP_FUNC_END();

	return eStatus;

}
/*
    The main state machine of the script processor
*/
McpBtsSpStatus _MCP_BTS_SP_ProcessScriptCommands(McpBtsSpContext *context,
                                                 McpBtsSpProcessingEvent processingEvent,
                                                 void *eventData)
{
    McpBtsSpStatus spStatus = MCP_BTS_SP_STATUS_SUCCESS;
    McpBool keepProcessing;

    MCP_UNUSED_PARAMETER(eventData);
    
    MCP_LOG_INFO(("_MCP_BTS_SP_ProcessScriptCommands: Processing Event: %d", processingEvent));

    keepProcessing = MCP_TRUE;
    
    while ((keepProcessing == MCP_TRUE) && (context->abortRequested == MCP_FALSE))
    {
        keepProcessing = MCP_FALSE;

        MCP_LOG_INFO(("_MCP_BTS_SP_ProcessScriptCommands: State = %d", context->processingState));
        
        switch (context->processingState)
        {
            case MCP_BTS_SP_PROCESSING_STATE_NONE:

                if (processingEvent == MCP_BTS_SP_PROCESSING_EVENT_START)
                {
                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_PROCESS_NEXT_ACTION;             
                }
                else
                {
                    MCP_LOG_FATAL(("_MCP_BTS_SP_ProcessScriptCommands: Unexpected Processing Event (%d)",
                                   processingEvent));

                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_DONE;
                    spStatus = MCP_BTS_SP_STATUS_INTERNAL_ERROR;
                }

                keepProcessing = MCP_TRUE;
                
            break;

            case MCP_BTS_SP_PROCESSING_STATE_PROCESS_NEXT_ACTION:
            {
                McpBool moreActions;
                
                /* Process next script action as long as we do not have to wait for a command complete event */
                do {
                    spStatus = _MCP_BTS_SP_ProcessNextScriptAction(context, &moreActions);
                } while ((spStatus == MCP_BTS_SP_STATUS_SUCCESS) && (moreActions == MCP_TRUE));

                /* [ToDo] - Handle the case of the last actio in the script being a "Send Command" (illegal) */
                if (spStatus == MCP_BTS_SP_STATUS_PENDING)
                {
                    /* The first time we wait for a command complete event we will record that fact */
                    context->asyncExecution = MCP_TRUE;

                    /* */
                    if (moreActions == MCP_TRUE)
                    {
                        context->processingState = MCP_BTS_SP_PROCESSING_STATE_WAIT_FOR_COMMAND_COMPLETE;
                    }
                    else
                    {
                        context->processingState = MCP_BTS_SP_PROCESSING_STATE_WAIT_FOR_LAST_COMMAND_COMPLETE;
                    }
                }
                else
                {
                    /* 
                        We get here in 2 cases:
                        1. script processing error
                        2. Last script action was not a "Send Command" action

                        In that case we terminate. spStatus stores the completion status
                    */
                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_DONE;
                    keepProcessing = MCP_TRUE;
                }
            }
            break;
            
            case MCP_BTS_SP_PROCESSING_STATE_WAIT_FOR_COMMAND_COMPLETE:

                if (processingEvent == MCP_BTS_SP_PROCESSING_EVENT_COMMAND_COMPLETE)
                {
                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_PROCESS_NEXT_ACTION; 
                }
                else
                {
                    MCP_LOG_FATAL(("_MCP_BTS_SP_ProcessScriptCommands: Unexpected Processing Event (%d)",
                                   processingEvent));

                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_DONE;
                    spStatus = MCP_BTS_SP_STATUS_INTERNAL_ERROR;
                }
                
                keepProcessing = MCP_TRUE;
                
            break;

            case MCP_BTS_SP_PROCESSING_STATE_WAIT_FOR_LAST_COMMAND_COMPLETE:
                
                if (processingEvent == MCP_BTS_SP_PROCESSING_EVENT_COMMAND_COMPLETE)
                {
                    spStatus = MCP_BTS_SP_STATUS_SUCCESS;
                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_DONE;
                }
                else
                {
                    MCP_LOG_FATAL(("_MCP_BTS_SP_ProcessScriptCommands: Unexpected Processing Event (%d)",
                                   processingEvent));

                    context->processingState = MCP_BTS_SP_PROCESSING_STATE_DONE;
                    spStatus = MCP_BTS_SP_STATUS_INTERNAL_ERROR;
                }

                keepProcessing = MCP_TRUE;
                
            break;
            
            case MCP_BTS_SP_PROCESSING_STATE_DONE:

                MCP_LOG_INFO(("_MCP_BTS_SP_ProcessScriptCommands: Completed (%s)",
                              _MCP_BTS_SP_DebugStatusStr(spStatus)));
                
                _MCP_BTS_SP_CompleteExecution(context, spStatus);

            break;
            
            default:
                MCP_LOG_FATAL(("_MCP_BTS_SP_ProcessScriptCommands: Invalid Processing State (%s)",
                               context->processingState));

                context->processingState = MCP_BTS_SP_PROCESSING_STATE_DONE;
                spStatus = MCP_BTS_SP_STATUS_INTERNAL_ERROR;
                keepProcessing = MCP_TRUE;
        }
    }

    if (context->abortRequested == MCP_TRUE)
    {
        _MCP_BTS_SP_CompleteExecution(context, MCP_BTS_SP_STATUS_EXECUTION_ABORTED);
    }
    
    return spStatus;
}
Exemplo n.º 27
0
void MCP_GenSM_Destroy (MCP_TGenSM *pGenSM)
{
		/*Currently this function is NULL for future purpose */
		MCP_UNUSED_PARAMETER(pGenSM);
}
ECCM_VAC_Status _CCM_VAC_AllocationEngine_Configure (TCCM_VAC_AllocationEngine *ptAllocEngine, 
                                                     TCAL_ResourceSupport *ptAvailResources,
                                                     TCAL_OperationSupport *ptAvailOperations)
{
    McpConfigParserStatus   eCPStatus;
    McpU32                  uResourcesNum, uIndex;
    McpU8                   *pTempValue;
    ECAL_Resource           eResource;
    ECCM_VAC_Status         status;

    MCP_FUNC_START ("_CCM_VAC_AllocationEngine_Configure");

    MCP_UNUSED_PARAMETER (ptAvailOperations);

    /* configure available resources: */
    /* 1. update all available external resources (read from ini file and compare with CAL) */

    /* get number of resources from ini file */
    eCPStatus = MCP_CONFIG_PARSER_GetIntegerKey (ptAllocEngine->pConfigParser, 
                                                 (McpU8 *)CCM_VAC_CONFIG_INI_RESOURCES_SECTION_NAME,
                                                 (McpU8 *)CCM_VAC_CONFIG_INI_RESOURCES_NUMBER_KEY_NAME,
                                                 (McpS32*)&uResourcesNum);
    MCP_VERIFY_FATAL (((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS) && (0 < uResourcesNum)),
                      CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                      ("_CCM_VAC_AllocationEngine_Configure: error reading number of resources "
                       "from file, number: %d, status: %d", uResourcesNum, eCPStatus));

    /* for each resource */
    for (uIndex = 0; uIndex < uResourcesNum; uIndex++)
    {
        /* read resource name */
        eCPStatus = MCP_CONFIG_PARSER_GetAsciiKey (ptAllocEngine->pConfigParser, 
                                                   (McpU8 *)CCM_VAC_CONFIG_INI_RESOURCES_SECTION_NAME,
                                                   (McpU8 *)CCM_VAC_CONFIG_INI_RESOURCE_NAME_KEY_NAME,
                                                   &pTempValue);
        MCP_VERIFY_FATAL (((eCPStatus == MCP_CONFIG_PARSER_STATUS_SUCCESS) && (NULL != pTempValue)),
                          CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                          ("_CCM_VAC_AllocationEngine_Configure: Can't get resource name for resource number %d",
                           uIndex));

        /* convert to enum value */
        eResource = StringtoResource (pTempValue);
        MCP_VERIFY_FATAL ((CAL_RESOURCE_INVALID != eResource),
                          CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                          ("_CCM_VAC_AllocationEngine_Configure: Can't convert resource number %d, "
                           "string %s to enum value", uIndex, pTempValue));

        /* verify it is available by the chip */
        MCP_VERIFY_FATAL ((MCP_TRUE == ptAvailResources->bResourceSupport[ eResource ]),
                          CCM_VAC_STATUS_FAILURE_INVALID_CONFIGURATION,
                          ("_CCM_VAC_AllocationEngine_Configure: resource %s required by ini file"
                           "is not supported by chip!", _CCM_VAC_DebugResourceStr(eResource)));

        /* and finally, mark it as enabled */
        ptAllocEngine->tResources[ eResource ].bAvailable = MCP_TRUE;
    }

    /* 2. update all available internal resources (read from CAL) */
    for (uIndex = CAL_RESOURCE_LAST_EX_RESOURCE + 1; uIndex < CAL_RESOURCE_MAX_NUM; uIndex++)
    {
        /* if the internal resource is supported by the chip, mark it as supported */
        ptAllocEngine->tResources[ uIndex ].bAvailable = ptAvailResources->bResourceSupport[ uIndex ];
    }

    MCP_FUNC_END ();

    return CCM_VAC_STATUS_SUCCESS;
}
Exemplo n.º 29
0
MCP_STATIC void MCP_LM_Load (void *pUserData)
{
    McpBtsSpStatus status;
    McpBtsSpScriptLocation tScriptLocation;
    McpBool memInitScriptFound;
    McpUtf8 scriptFullFileName[MCP_HAL_CONFIG_FS_MAX_PATH_LEN_CHARS *
                               MCP_HAL_CONFIG_MAX_BYTES_IN_UTF8_CHAR];

    MCP_FUNC_START ("MCP_LM_Load");

    MCP_UNUSED_PARAMETER (pUserData);

    /* First try to load the script from FS */
    tScriptLocation.locationType = MCP_BTS_SP_SCRIPT_LOCATION_FS;
    MCP_StrCpyUtf8(scriptFullFileName, (const McpUtf8 *)pScriptLocation);
    MCP_StrCatUtf8(scriptFullFileName, (const McpUtf8 *)pScriptName);
    tScriptLocation.locationData.fullFileName = scriptFullFileName;

    /* Execute the requested script*/
    status = MCP_BTS_SP_ExecuteScript (&tScriptLocation, &tExcuteCallbacks, &context);

    if (status == MCP_BTS_SP_STATUS_PENDING)
    {
        /* Update the State Machine status */
        iLoadSmstatus = MCP_HAL_STATUS_PENDING;
    }
    else if (status == MCP_BTS_SP_STATUS_SUCCESS)
    {
        /* Update the State Machine status */
        iLoadSmstatus = MCP_HAL_STATUS_SUCCESS;    
    }
    else if (MCP_BTS_SP_STATUS_FILE_NOT_FOUND == status)
    {
        /* FS Script Not Found - Use default hard-coded memory script instead */
        tScriptLocation.locationType = MCP_BTS_SP_SCRIPT_LOCATION_MEMORY;

        /* Check if memory has a script for this version and load its parameters if found */
        memInitScriptFound =  MCP_RomScriptsGetMemInitScriptData(
                                    pScriptName, 
                                    &tScriptLocation.locationData.memoryData.size,
                                    (const McpU8**)&tScriptLocation.locationData.memoryData.address);

        /* verify the script was found in memory */
        MCP_VERIFY_FATAL_NO_RETVAR ((memInitScriptFound == MCP_TRUE),
                          ("MCP_LM_Load: can't find script %s on FS and memory", pScriptName));

        /* execute the memory script */
        status = MCP_BTS_SP_ExecuteScript(&tScriptLocation, &tExcuteCallbacks, &context);

        if (status == MCP_BTS_SP_STATUS_PENDING)
        {
            iLoadSmstatus = MCP_HAL_STATUS_PENDING;
        }
        else if (status == MCP_BTS_SP_STATUS_SUCCESS)
        {
            iLoadSmstatus = MCP_HAL_STATUS_SUCCESS;
        }
        else
        {
            iLoadSmstatus = MCP_HAL_STATUS_FAILED;
        }
    }
    else
    {
        /* Update the State Machine status */
        iLoadSmstatus = MCP_HAL_STATUS_FAILED;
    }

    MCP_FUNC_END();
}