BST_VOID * BST_OS_StaticMemAlloc(BST_MEM_TYPE_ENUM_UINT8 enType, BST_UINT32 ulSize ) { BST_INT32 i; BST_UINT_PTR *pulSpace; BST_MEM_BLOCK_INFO *pstMemInfo; BST_MEM_CTRL_BLOCK *pstMemCtrl; BST_INT32 lCycle; if( 0 == ulSize ) { BST_RLS_LOG("# BST_OS_StaticMemAlloc size is 0"); return BST_NULL_PTR; } if(BST_MEM_TYPE_DYNAMIC == enType) { pstMemInfo = g_BstMemBlockInfo; lCycle = BST_MEM_CTRL_BLOCK_NUMBER; pstMemCtrl = g_BstMemCtrlBlk; } else if(BST_MEM_TYPE_PBUF == enType) { pstMemInfo = g_BstBufBlockInfo; lCycle = BST_BUF_CTRL_BLOCK_NUMBER; pstMemCtrl = g_BstBufCtrlBlk; } else { BST_RLS_LOG1("# V_MemAlloc wrong type:%d", enType); return BST_NULL_PTR; } for ( i=0; i<lCycle; i++ ) { if(ulSize <= pstMemInfo[i].ulSize ) { pulSpace = (BST_UINT_PTR *)BST_OS_StaticMemCtrlBlkMalloc(&(pstMemCtrl[i])); if( BST_NULL_PTR != pulSpace ) { /*如果当前申请的内存块是最大size的内存块,需要检查内存是否达到低内存上报的门限*/ if( i== ( lCycle - 1 )) { BST_OS_MemStatusReport( enType ); } /* offset space which be reserved of OSA */ pulSpace += BST_MEMORY_RESERVED_WORD_HEAD; BST_DBG_LOG1("BST_MemAlloc" ,pulSpace); return (BST_VOID *)pulSpace; } } } BST_RLS_LOG1("# alloce memory fail size %d.", (BST_INT32)ulSize); return BST_NULL_PTR; }
BST_IP_ERR_T BST_IP_RawTcpSend( BST_FD_T fd, BST_UINT8* pData, BST_UINT16 usLength ) { BST_IP_ERR_T stErrMsg; struct tcp_pcb *pstPcb; if( !BST_IP_IsRawFdValid(fd) ) { return BST_IP_ERR_MEM; } if( BST_NULL_PTR == pData ) { return BST_IP_ERR_MEM; } pstPcb = ( struct tcp_pcb * )fd.pFd; if( 0 == pstPcb->snd_wnd_max ) { return BST_IP_ERR_WIN; } stErrMsg = tcp_write( pstPcb, pData, usLength, TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE ); if( BST_IP_ERR_OK != stErrMsg ) { BST_RLS_LOG1("BST_IP_RawTcpSend tcp_write Error:", stErrMsg ); } stErrMsg = tcp_output( pstPcb ); if( BST_IP_ERR_OK != stErrMsg ) { BST_RLS_LOG1("BST_IP_RawTcpSend tcp_output Error:", stErrMsg ); } return stErrMsg; }
BST_CORE_CNPTask::~BST_CORE_CNPTask ( BST_VOID ) { BST_CORE_CRegedit *pcRegedit; BST_APP_CMainTask *pcMainTask; BST_ERR_ENUM_UINT8 ucRtnVal; #if ( BST_OS_VER != BST_QCOM_ROS ) try { #endif BST_DBG_LOG( "BST_CORE_CNPTask::~BST_CORE_CNPTask in" ); pcRegedit = BST_CORE_CRegedit::GetInstance(); pcMainTask = BST_APP_CMainTask::GetInstance(); if ( BST_NULL_PTR != m_pExptReport ) { ucRtnVal = Report ( BST_TRAFFIC_FLOW_REPORT ); if ( BST_NO_ERROR_MSG != ucRtnVal ) { BST_RLS_LOG1( "BST_CORE_CNPTask::~BST_CORE_CNPTask Report Traffic Error: %u", ucRtnVal ); } ucRtnVal = Report ( BST_ERR_TASK_REMOVED ); if ( BST_NO_ERROR_MSG != ucRtnVal ) { BST_RLS_LOG1( "BST_CORE_CNPTask::~BST_CORE_CNPTask Report Removed Error: %u", ucRtnVal ); } delete m_pExptReport; } if ( BST_NULL_PTR != pcRegedit ) { pcRegedit->unRegist ( this ); } if ( BST_NULL_PTR != pcMainTask ) { pcMainTask->Detach ( this ); } BST_DBG_LOG1( "BST_CORE_CNPTask::~BST_CORE_CNPTask m_pSocket=%p", m_pSocket ); if ( BST_NULL_PTR != m_pSocket ) { delete m_pSocket; } #if ( BST_OS_VER != BST_QCOM_ROS ) } catch (...) { BST_RLS_LOG("BST_CORE_CNPTask destructor exception!"); } #endif }
BST_UINT16 BST_CORE_CNPTask::InquiredSocketProperty( BST_UINT16 usDataSize, BST_VOID *const pData ) { BST_IP_ERR_T enIpErr; BST_DBG_LOG ( " BST_CORE_CNPTask::InquiredSocketProperty Enter."); if ( usDataSize < BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU ) ) { BST_RLS_LOG1 ( "BST_CORE_CNPTask::InquiredSocketProperty usDataSize=%d", usDataSize ); return BST_CORE_INVALID_INQUIRED_LEN; } Stop(); enIpErr = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_PROPERTY, pData ); BST_ResetPrptyFlag(); ( BST_VOID )PidInquired ( BST_PID_SOCKET_PROPERTY, usDataSize, pData ); if ( BST_IP_ERR_OK == enIpErr ) { return ( BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU ) ); } else { return BST_CORE_INVALID_INQUIRED_LEN; } }
BST_IP_ERR_T BST_IP_SslConnect( BST_FD_T fd, BST_ARG_T Arg, BST_IP_SOCKET_ADD_T *pAdd ) { SSL *pstSsl; BST_INT32 ret; BST_FD_T lSocketFd; pstSsl = (SSL *)fd.pFd; lSocketFd.lFd = SSL_get_fd(pstSsl); if (BST_IP_ERR_OK != BST_IP_BsdConnect(lSocketFd, Arg, pAdd) ) { BST_RLS_LOG( "BST_IP_SslConnect BST_IP_BsdConnect error" ); return BST_IP_ERR_MEM; } ret = SSL_connect( pstSsl ); /* 返回值等于1表示connect成功 */ if ( 1 == ret ) { return BST_IP_ERR_OK; } ret = SSL_get_error( pstSsl, ret ); BST_RLS_LOG1( "BST_IP_SslConnect Err No. is %d", ret ); return BST_IP_ERR_VAL; }
VOS_VOID BST_FidTask ( VOS_UINT32 Para1, VOS_UINT32 Para2, VOS_UINT32 Para3, VOS_UINT32 Para4 ) { MsgBlock *pMsg = VOS_NULL_PTR; VOS_UINT32 ulEvent = 0; VOS_UINT32 ulTaskID = 0; VOS_UINT32 ulEventMask = 0; VOS_UINT32 ulExpectEvent = 0; ulTaskID = VOS_GetCurrentTaskID(); if ( PS_NULL_UINT32 == ulTaskID ) { BST_RLS_LOG ( "BST_FidTask: This Task Id is Error" ); return; } if ( VOS_OK != VOS_CreateEvent(ulTaskID) ) { BST_RLS_LOG ( "BST_FidTask:, Create Event Fail"); return; } ulExpectEvent = VOS_MSG_SYNC_EVENT|BST_CDS_EVENT_RCV_DL_PROC; ulEventMask = (VOS_EVENT_ANY | VOS_EVENT_WAIT); g_ulBastetTaskId = VOS_GetCurrentTaskID(); g_ulBstTaskReadyFlag = BST_TRUE; for (;;) { if ( VOS_OK != VOS_EventRead(ulExpectEvent,ulEventMask,0,&ulEvent) ) { BST_RLS_LOG ( "BST_FidTask: BASTET Read Event Error" ); continue; } /*事件处理*/ if (VOS_MSG_SYNC_EVENT != ulEvent) { BST_SYS_EvtProcEntry(ulEvent); continue; } pMsg = (MsgBlock *)VOS_GetMsg(ulTaskID); if ( VOS_NULL_PTR != pMsg ) { switch ( TTF_GET_MSG_RECV_PID( pMsg ) ) { case UEPS_PID_BASTET: BST_SYS_MsgProcEntry( pMsg ); break; default: BST_RLS_LOG1 ( "BST_FidTask: Recv Unkown Message %d\r\n", TTF_GET_MSG_NAME(pMsg) ); break; } PS_FREE_MSG ( UEPS_PID_BASTET, pMsg ); } } }
BST_ERR_ENUM_UINT8 BST_DSPP_CDlLayerBase::UnPack ( BST_DSPP_HEAD_STRU *const pstRxHeadInfo ) { BST_DSPP_CDlLayerBase *pcNextLayer; BST_DSPP_VERION_ENUM_UINT8 enNextVer; BST_ERR_ENUM_UINT8 ucRtnVal; enNextVer = BST_DSPP_VER_INVALID; pcNextLayer = BST_NULL_PTR; BST_DBG_LOG ( "BST_DSPP_CDlLayerBase::UnPack is called" ); ucRtnVal = UnpackInternal ( pstRxHeadInfo, &enNextVer ); if ( BST_NO_ERROR_MSG != ucRtnVal ) { BST_RLS_LOG1( "BST_DSPP_CDlLayerBase::UnPack UnpackInternal Err=%u", ucRtnVal ); return BST_ERR_LAYER_VER; } if ( BST_DSPP_VER_VOID == enNextVer ) { return BST_ERR_LAYER_VER; } pcNextLayer = GetNextStrategy ( enNextVer ); if ( BST_NULL_PTR != pcNextLayer ) { ucRtnVal = pcNextLayer->UnPack ( pstRxHeadInfo ); } else { ucRtnVal = BST_NO_ERROR_MSG; } return ucRtnVal; }
BST_IP_ERR_T BST_IP_SslSend( BST_FD_T fd, BST_UINT8* pData, BST_UINT16 usLength ) { SSL *pstSsl; BST_INT32 ret; if ( BST_NULL_PTR == fd.pFd) { return BST_IP_ERR_ARG; } if ( BST_NULL_PTR == pData ) { return BST_IP_ERR_ARG; } pstSsl = (SSL *)fd.pFd; ret = SSL_write( pstSsl, pData, usLength); ret = SSL_get_error( pstSsl, ret ); if ( SSL_ERROR_NONE != ret) { BST_RLS_LOG1( "BST_IP_SslSend Err No. is %d", ret ); return BST_IP_ERR_VAL; } return BST_IP_ERR_OK; }
BST_VOID BST_PAL_NetMsgEntry( MsgBlock *pstMsg ) { BST_UINT32 ulTrsFlg; if ( BST_NULL_PTR == pstMsg ) { BST_RLS_LOG( "BST_PAL_NetMsgEntry : Input NULL PTR." ); return; } BST_RLS_LOG1( "BST_PAL_NetMsgEntry : MsgId", TTF_GET_MSG_NAME(pstMsg) ); switch( TTF_GET_MSG_NAME(pstMsg) ) { /* CDS发给BASTET的消息原语: 有其他IP包在运行中 */ case ID_BST_CDS_TX_RX_IND: ulTrsFlg = BST_TRUE; BST_PalAsEventRcvCb( BST_AS_EVT_L3_AP_TRS_RCV_IND, ( BST_UINT16 )BST_OS_SIZEOF(ulTrsFlg), &ulTrsFlg ); break; /* CDS发给BASTET的消息原语: 当前MODEM数据业务使用的MODEM ID*/ case ID_BST_CDS_CHANNEL_INFO_IND: BST_PAL_NetMsgCfgCallBack( (const BST_CDS_SEND_CB_INFO_STRU *)pstMsg ); break; default: BST_RLS_LOG( "BST_PAL_NetMsgEntry : Unknown Message." ); break; } return; }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ConfigedPriodic( BST_UINT16 usLen, const BST_VOID *const pData, BST_UINT8 **pucNewAddr ) { BST_UINT32 ulTimerTicks; BST_ERR_ENUM_UINT8 ucRtnVal; if ( usLen < BST_OS_SIZEOF ( BST_UINT32 ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::ConfigedPriodic usLen=%u", usLen ); return BST_ERR_PAR_LEN; } BST_OS_MEMCPY( &ulTimerTicks, pData, BST_OS_SIZEOF(BST_UINT32) ); ucRtnVal = ConfigCycleTicks ( ulTimerTicks ); if ( ucRtnVal == BST_NO_ERROR_MSG ) { *pucNewAddr = ( BST_UINT8 * )&m_ulCycle; BST_SetConfigFlag ( BST_CFGFLG_CYCL ); } else { *pucNewAddr = BST_NULL_PTR; } return ucRtnVal; }
BST_VOID BST_CTaskSchdler::TimerExpired( BST_OS_TIMERID_T ulId, BST_VOID *pvPara) { BST_CORE_PTASK_NODE_STRU *pstPtaskNode; BST_CORE_PTASK_NODE_STRU *pstPtaskNodeNext; if ( !BST_OS_IsTimerValid (m_ulTimerId) ) { BST_RLS_LOG1( "BST_CTaskSchdler::TimerExpired m_ulTimerId=%u is invalid", m_ulTimerId ); return; } if ( ulId != m_ulTimerId ) { BST_RLS_LOG2( "BST_CTaskSchdler::TimerExpired ulId=%u,m_ulTimerId=%u", ulId, m_ulTimerId ); return; } /* * 如果没有任务,则直接返回,不做任何操作 */ if ( 0 == lstCount( &g_stPTaskList ) ) { BST_RLS_LOG( "BST_CTaskSchdler::TimerExpired g_stPTaskList count=0" ); return; } /* * 更新系统TICK值 */ m_ulSystemTick += BST_TASK_SYS_TICKS; BST_DBG_LOG1 ( "BST_CTaskSchdler::TimerExpired Scheduler TimeOut, Tick=%d ", m_ulSystemTick ); /* * 遍历任务列表,获取任务并进行相应调度 */ for ( pstPtaskNode = ( BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList ); pstPtaskNode!= BST_NULL_PTR; pstPtaskNode = pstPtaskNodeNext ) { pstPtaskNodeNext = ( BST_CORE_PTASK_NODE_STRU *) lstNext((NODE *)pstPtaskNode); if ( BST_NULL_PTR == pstPtaskNode->pcTask ) { continue; } /* * 如果任务不为空,则根据状态进行调度 */ ScheduleTask ( pstPtaskNode->pcTask ); } /* * 再次启动系统TICK定时器 */ BST_OS_TimerStart ( m_ulTimerId, BST_TASK_SYS_BASE_TIMELEN ); }
BST_VOID BST_CTaskSchdler::Execute( BST_CORE_CPTask *pC_PTask ) { BST_RUN_MODE_ENUM_UINT8 enTaskRunMode; #if( 0 != BST_BLOCKED_THREAD_NUM ) BST_STATIC BST_UINT32 ulUnblkedCnt = 0; #endif enTaskRunMode = pC_PTask->GetRunMode (); pC_PTask->m_ulSuspCounter = 0; /* * 根据任务运行模式,调度执行相关任务 */ switch ( enTaskRunMode ) { /* * 如果阻塞性任务,且没有单独线程,则直接执行,如果有任务则发邮件 * 不同进程由ulUnblkedCnt统一分配,平均各线程任务负荷 */ case BST_TASK_RUN_BLOCKED: #if( 0 != BST_BLOCKED_THREAD_NUM ) if ( ulUnblkedCnt >= BST_BLOCKED_THREAD_NUM ) { ulUnblkedCnt = 0; } if ( BST_NULL_PTR == m_pastBlockTaskMbx[ulUnblkedCnt] ) { BST_RLS_LOG1 ( "BST_CTaskSchdler::Execute Blocked Thread %d is not ready", ulUnblkedCnt ); return; } BST_OS_SendMail ( m_pastBlockTaskMbx[ulUnblkedCnt], pC_PTask ); ulUnblkedCnt++; #else pC_PTask->PEntry(); #endif break; /* * 如果非阻塞性任务,且没有单独线程,则直接执行,如果有任务则发邮件 */ case BST_TASK_RUN_UNBLOCKED: #ifdef BST_UNBLOCKED_OWN_THREAD if ( BST_NULL_PTR == m_pstUnBlockTaskMbx ) { BST_RLS_LOG ( "BST_CTaskSchdler::Execute UnBlocked Thread is not ready" ); return; } BST_OS_SendMail ( m_pstUnBlockTaskMbx, pC_PTask ); #else pC_PTask->PEntry(); #endif break; default: break; } }
BST_VOID BST_SYS_MntnTrigReport( BST_VOID ) { OM_BST_MSG_STRU *pstBstOmIndMsg; OM_BST_AGENT_APP_NUM_STRU *pstBstAppNum; BST_UINT32 ulRslt; BST_UINT32 ulLength; BST_UINT16 usAppNum; OM_BST_APP_INFO_STRU *pstAppInfo; ulRslt = BST_TRUE; /* 申请的大小等于消息头BST_OM_MSG_STRU -4个字节的指针占位 + 实际代理信息大小 */ usAppNum = (BST_UINT16)BST_SYS_MNTN_GetAppNumber(); ulLength = (BST_OS_SIZEOF(OM_BST_MSG_STRU) - 4) + (BST_OS_SIZEOF(OM_BST_AGENT_APP_NUM_STRU)); pstBstOmIndMsg = (OM_BST_MSG_STRU *)BST_SYS_MntnGetSendExternalMsgBuffAddr(UEPS_PID_BASTET, ulLength); if (BST_NULL_PTR == pstBstOmIndMsg) { BST_DBG_LOG1("BST_SYS_MntnTrigReport, Agent Info Msg Alloc Mem Fail", 0); return; } /* 填写消息头 */ BST_SYS_MntnFillBstOmMsgHead( pstBstOmIndMsg, ulLength, ID_BST_OM_AGENT_INFO_IND, 0 ); pstBstAppNum = (OM_BST_AGENT_APP_NUM_STRU *)(pstBstOmIndMsg->aucData); pstBstAppNum->usAgentAppNum = usAppNum; pstAppInfo = ( (OM_BST_APP_INFO_STRU *)(pstBstAppNum->stBstAppList ) ); ulRslt = BST_SYS_MntnBuildAgentInfoInd( pstAppInfo, usAppNum ); if (BST_TRUE != ulRslt) { BST_DBG_LOG1("BST_SYS_MntnTrigReport, Get Bst Agent Info Error: ulRslt", ulRslt); return; } /* 发送IND消息 */ ulRslt = OM_SendData( (OM_RSP_PACKET_STRU *)pstBstOmIndMsg, (BST_UINT16)ulLength ); /* 释放传入的消息包 */ BST_FREE_MSG( UEPS_PID_BASTET, pstBstOmIndMsg ); if (VOS_OK != ulRslt) { BST_RLS_LOG1( "[Mntn] Send Maintain Message Fail:", ulRslt ); return; } BST_RLS_LOG( "[Mntn] Send Maintain Message Success" ); return; }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ConfigedSockeInfo( BST_UINT16 usLen, const BST_VOID *const pData, BST_UINT8 **pucNewAddr ) { BST_IP_ERR_T enIpErrMsg; BST_ERR_ENUM_UINT8 ucRtnVal; if ( usLen < BST_OS_SIZEOF ( BST_IP_SOCKET_ADD_T ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::ConfigedPriodic usLen=%u", usLen ); return BST_ERR_PAR_LEN; } if ( !BST_IP_IsValidIpAddress( ( BST_IP_SOCKET_ADD_T * )pData ) ) { Report( BST_TRAFFIC_FLOW_REPORT ); } enIpErrMsg = m_pSocket->IoCtrl ( BST_SCKT_CMD_SET_ADDRESS, ( BST_VOID *)pData ); BST_DBG_UPDATE_IP_INFO( m_usProcId, m_usTaskId, (( BST_IP_SOCKET_ADD_T * )pData) ); if ( BST_IP_ERR_OK == enIpErrMsg ) { enIpErrMsg = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_ADDRPTR, ( BST_VOID *)pucNewAddr ); if ( BST_IP_ERR_OK == enIpErrMsg ) { if ( BST_IP_IsValidIpAddress( ( BST_IP_SOCKET_ADD_T * )( *pucNewAddr ) ) ) { BST_SetConfigFlag ( BST_CFGFLG_ADDR ); } else { /* 清除Config, 防止Socket进行Clone,并挂起任务 */ BST_UnsetConfigFlag ( BST_CFGFLG_ADDR ); Suspend(); } ucRtnVal = BST_NO_ERROR_MSG; } else { BST_UnsetConfigFlag ( BST_CFGFLG_ADDR ); ucRtnVal = BST_ERR_ILLEGAL_PARAM; } } else { ucRtnVal = BST_ERR_ILLEGAL_PARAM; } return ucRtnVal; }
BST_VOID BST_CTaskSchdler::AsEventCallback( BST_AS_EVT_ENUM_UINT32 enEvent, BST_UINT32 ulLength, BST_VOID *pvData ) { BST_UINT32 ulPara; switch( enEvent ) { /* * 仅处理RRC状态信息,当RRC连接成功时,查看当前剩余时间是否靠近 */ case BST_AS_EVT_L3_RRC_STATE: if ( BST_OS_SIZEOF(ulPara) != ulLength ) { break; } if ( BST_NULL_PTR == pvData ) { break; } BST_OS_MEMCPY( &ulPara, pvData, ulLength ); if( BST_AS_RRC_CONNECTED == ulPara ) { ulPara = BST_OS_TimerIsStop( m_ulTimerId ); if ( BST_TRUE == ulPara ) { break; } ulPara = BST_OS_TimeGetRemain( m_ulTimerId ); if ( 0 == ulPara ) { break; } ulPara = NearRrcTrig ( ulPara ); BST_OS_TimerStart( m_ulTimerId, ulPara ); } break; case BST_AS_EVT_L3_BLOCK_INFO: if ( BST_OS_SIZEOF(BST_UINT32) != ulLength ) { BST_RLS_LOG1("BST_CTaskSchdler::AsEventCallback Error blockinfo Length = %u:", ulLength ); break; } UtranBlockInfoChgProc( (BST_UINT32 *)pvData ); break; default: break; } }
/*lint -e429*/ BST_VOID BST_CTaskSchdler::Attach ( BST_CORE_CPTask *pC_PTask ) { BST_CORE_PTASK_NODE_STRU *pstPtaskNode; if ( !BST_OS_IsTimerValid (m_ulTimerId) ) { BST_RLS_LOG1( "BST_CTaskSchdler::Attach m_ulTimerId=%u is invalid", m_ulTimerId ); return; } if ( BST_NULL_PTR == pC_PTask ) { BST_RLS_LOG( "BST_CTaskSchdler::Attach pC_PTask=NULL" ); return; } for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList ); pstPtaskNode!= BST_NULL_PTR; pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) ) { if( pstPtaskNode->pcTask == pC_PTask ) { return; } } /* * 申请链表节点资源,用于存储任务 */ pstPtaskNode = ( BST_CORE_PTASK_NODE_STRU *)BST_OS_MALLOC ( BST_OS_SIZEOF( BST_CORE_PTASK_NODE_STRU ) ); if( BST_NULL_PTR == pstPtaskNode ) { BST_RLS_LOG( "BST_CTaskSchdler::Attach pstPtaskNode=NULL" ); return; } /* * 初始化任务数据,添加如任务列表 */ pC_PTask->m_ulSuspCounter = 0; pstPtaskNode->pcTask = pC_PTask; lstAdd( &g_stPTaskList, (NODE *)pstPtaskNode ); /* * 如果此时系统TICK定时已经关闭,且PS域服务状态正常,那么需要再次启动定时 */ if( BST_TRUE == BST_OS_TimerIsStop( m_ulTimerId ) ) { m_ulSystemTick = 0; BST_OS_TimerStart ( m_ulTimerId, BST_TASK_SYS_BASE_TIMELEN ); BST_DBG_LOG1( "BST_CTaskSchdler::Attach Start Scheduler Timer:%u", BST_TASK_SYS_BASE_TIMELEN ); } }
BST_UINT32 BST_SRV_RcvTimerEvent( BST_OS_TIMERID_T ulTimerId ) { BST_SRV_CEvent *pEvtProc; BST_UINT32 ulRtnVal; pEvtProc = BST_SRV_CEvent::GetInstance(); BST_ASSERT_NULL_RTN( pEvtProc, 0 ); ulRtnVal = pEvtProc->RcvTimerExpired( ulTimerId ); if( BST_NO_ERROR_MSG == ulRtnVal ) { return BST_OS_SIZEOF(BST_OS_TIMER_STRU); } BST_RLS_LOG1( "BST_SRV_RcvTimerEvent pEvtProc->RcvTimerExpired Err=%u", ulRtnVal ); return 0; }
BST_ERR_ENUM_UINT8 BST_APP_CEmailIMAP::HandleQueryResp( BST_VOID ) { BST_ERR_ENUM_UINT8 enRtnVal; if ( BST_NULL_PTR == m_pstLastUID ) { return BST_ERR_PAR_UNKNOW; } if ( BST_NULL_PTR == m_pcHostTask ) { return BST_ERR_TASK_REMOVED; } if ( 0 != BST_OS_MEMCMP( m_pcServerResponse0, "*", 1 ) ) { return BST_ERR_UNREACHABLE; } if ( 0 != BST_OS_MEMCMP( m_pstLastUID->pLastUid->pData, m_pcServerResponse2, m_pstLastUID->pLastUid->usUsed) ) { /* * Modem自己更新邮件的UID值 */ enRtnVal = BST_LIB_StrFill( m_pstLastUID->pLastUid, ( BST_UINT8 *)m_pcServerResponse2, BST_LIB_StrLen( (BST_CHAR *)m_pcServerResponse2 ) ); if ( BST_NO_ERROR_MSG != enRtnVal ) { BST_RLS_LOG1( "CEmailIMAP::HandleQueryResp Write Error: %u", enRtnVal ); } enRtnVal = BST_NEW_EMAIL; } else { enRtnVal = BST_NO_ERROR_MSG; } if ( BST_NO_ERROR_MSG == QuitServer() ) { m_lServerState = BST_EMAIL_IMAP_QUERYED; return enRtnVal; } else { return BST_ERR_UNREACHABLE; } }
err_t BST_IP_TcpOverFlowCB( BST_UINT32 ulRealFlowValue ) { BST_APP_CMainTask *pMainTask; BST_ERR_ENUM_UINT8 enRtnVal; pMainTask = BST_APP_CMainTask::GetInstance(); if ( BST_NULL_PTR == pMainTask ) { return BST_IP_ERR_MEM; } enRtnVal = pMainTask->TrafficOverFlow( ulRealFlowValue ); if ( BST_NO_ERROR_MSG != enRtnVal ) { BST_RLS_LOG1( "BST_IP_TcpOverFlowCB Error=%u", enRtnVal ); return BST_IP_ERR_BUF; } return BST_IP_ERR_OK; }
BST_VOID BST_SYS_MntnCofigLoacalIpAddress( BST_UINT8 *aucLocalIp, BST_UINT16 usBufLen ) { if ( BST_NULL_PTR == aucLocalIp ) { BST_RLS_LOG( "[Mntn] BST_SYS_MntnCofigLoacalIpAddress Error Pointer" ); return; } if ( OM_BST_IP_ADDR_LEN > usBufLen ) { BST_RLS_LOG1( "[Mntn] BST_SYS_MntnCofigLoacalIpAddress Error Size:", usBufLen ); return; } BST_OS_MEMCPY( &g_stBstMntnEntity.aucLocalIp[0], aucLocalIp, OM_BST_IP_ADDR_LEN ); return; }
BST_UINT32 BST_PAL_NetIpStackInput( const BST_UINT32 const ulLength, const BST_UINT8 * const pucData, const TTF_MEM_ST * const pstPktItem ) { BST_NET_PBUF_T *pbuf; BST_NETIF_T *pstNetif; BST_INT32 lRtnVal; BST_UINT16 usPortNum; if( 0 == ulLength ) { return 0x00U; } if( BST_NULL_PTR == pucData ) { return 0x00U; } if( BST_NULL_PTR == pstPktItem ) { return 0x00U; } pbuf = pbuf_alloc( PBUF_LINK, (BST_UINT16)ulLength, PBUF_RAM ); BST_ASSERT_NULL_RTN( pbuf, 0x00U ); usPortNum = BST_IP_ApiRegistPacket( ( BST_IP_PKT_ID_T )pbuf, (BST_VOID*)pstPktItem ); BST_DBG_UPDATE_RX_FLOW( usPortNum, ulLength ); ( BST_VOID )pbuf_take( pbuf, pucData, (BST_UINT16)ulLength ); pstNetif = BST_DRV_NetGetMainIfHandle(); lRtnVal = pstNetif->input( pbuf, pstNetif ); if ( lRtnVal < 0 ) { BST_RLS_LOG1( "BST_PAL_NetIpStackInput, Write to Lwip Error=%s", lRtnVal ); BST_IP_ApiUnRegistPacket( ( BST_IP_PKT_ID_T )pbuf ); BST_PAL_NetApiPacketResume( (BST_VOID*)pstPktItem ); pbuf_free( pbuf ); return 0x00U; } else { return ulLength; } }
BST_ERR_ENUM_UINT8 BST_PAL_NetApiPacketSend( BST_UINT32 ulLength, BST_UINT8 *pucData ) { BST_PAL_NET_ENTITY_STRU *pstBstNetEntity; pstBstNetEntity = BST_PAL_NetGetEntity(); if( BST_NULL_PTR == pstBstNetEntity->pfSndItf ) { BST_RLS_LOG( "BST_PAL_NetApiPacketSend: pfSndItf is Void." ); return BST_ERR_UNREACHABLE; } if( ulLength != pstBstNetEntity->pfSndItf( pucData, ulLength ) ) { BST_RLS_LOG1( "BST_PAL_NetApiPacketSend: Send to OTA Error Len.", ulLength ); return BST_ERR_PAR_LEN; } return BST_NO_ERROR_MSG; }
BST_UINT32 BST_SRV_RcvAsEvent( BST_AS_EVT_ENUM_UINT32 enAsEvent, BST_UINT32 ulLength, BST_VOID *pvData ) { BST_SRV_CEvent *pEvtProc; BST_ERR_ENUM_UINT8 ucRtnVal; pEvtProc = BST_SRV_CEvent::GetInstance(); BST_ASSERT_NULL_RTN( pEvtProc, 0 ); ucRtnVal = pEvtProc->RcvAsEvent( enAsEvent, ulLength, pvData ); if( BST_NO_ERROR_MSG == ucRtnVal ) { return ulLength; } BST_RLS_LOG1( "BST_SRV_RcvAsEvent pEvtProc->RcvAsEvent Err=%u", ucRtnVal ); return 0; }
BST_IP_ERR_T BST_IP_BsdSend( BST_FD_T fd, BST_UINT8* pData, BST_UINT16 usLength ) { BST_INT32 lRtnVal; if( !BST_IP_IsBsdFdValid(fd) ) { return BST_IP_ERR_MEM; } if( BST_NULL_PTR == pData ) { return BST_IP_ERR_MEM; } lRtnVal = (BST_IP_ERR_T)lwip_write( fd.lFd, pData, usLength ); if (lRtnVal < 0) { BST_RLS_LOG1( "BST_IP_BsdSend Err No. is %d", lRtnVal ); return lRtnVal; } return BST_IP_ERR_OK; }
BST_VOID BST_OS_PalTimerStart( BST_UINT32 ulLength ) { BST_RLS_LOG1( "BST_OS_PalTimerStart : Length.", ulLength ); if ( VOS_NULL_PTR != g_BstTimer ) { if ( VOS_OK != PS_STOP_REL_TIMER( &g_BstTimer ) ) { BST_RLS_LOG( "BST_OS_PalTimerStart : Start(Stop) Tmr Fail." ); return; } } if ( VOS_OK != PS_START_REL_TIMER( &g_BstTimer, UEPS_PID_BASTET, ulLength, 0, 0, VOS_RELTIMER_NOLOOP) ) { BST_RLS_LOG( "BST_OS_PalTimerStart : Start Tmr Fail." ); return ; } }
/*lint -e438*/ BST_VOID BST_CTaskSchdler::Detach ( BST_CORE_CPTask *pC_PTask ) { BST_CORE_PTASK_NODE_STRU *pstPtaskNode; if ( !BST_OS_IsTimerValid (m_ulTimerId) ) { BST_RLS_LOG1( "BST_CTaskSchdler::Detach m_ulTimerId=%u is invalid", m_ulTimerId ); return; } if ( BST_NULL_PTR == pC_PTask ) { BST_RLS_LOG( "BST_CTaskSchdler::Detach pC_PTask=NULL" ); return; } /* * 遍历列表,找到pctask相符的任务,从链表删除,释放资源 */ for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList ); pstPtaskNode!= BST_NULL_PTR; pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) ) { if( pstPtaskNode->pcTask != pC_PTask ) { continue; } lstDelete( &g_stPTaskList, (NODE *)pstPtaskNode ); BST_OS_FREE( pstPtaskNode ); break; } /* * 注销后,如果认为列表为空,则直接关闭定时器,不进行任何调度 */ if ( 0 == lstCount( &g_stPTaskList ) ) { BST_DBG_LOG( "BST_CTaskSchdler::Detach Stop Scheduler Timer" ); BST_OS_TimerStop ( m_ulTimerId ); } }
BST_UINT16 BST_CORE_CNPTask::Inquired( BST_CORE_PID_ENUM_UINT16 enParamId, BST_UINT16 usDataSize, BST_VOID *const pData ) { if ( !BST_CORE_IsPidValid ( enParamId ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::Inquired enParamId=%u is invalid", usDataSize ); return BST_CORE_INVALID_INQUIRED_LEN; } if ( ( BST_NULL_PTR == pData ) || ( 0 == usDataSize ) ) { BST_RLS_LOG2( "BST_CORE_CNPTask::Inquired pData=%p,usDataSize=%u", pData, usDataSize ); return BST_CORE_INVALID_INQUIRED_LEN; } if ( BST_NULL_PTR == m_pSocket ) { BST_RLS_LOG( "BST_CORE_CNPTask::Inquired m_pSocket=NULL" ); return BST_CORE_INVALID_INQUIRED_LEN; } switch ( enParamId ) { case BST_PID_SOCKET_PROPERTY: return InquiredSocketProperty( usDataSize, pData ); case BST_PID_TRAFFIC_FLOW: return InquiredTrafficFlow( usDataSize, pData ); default: return PidInquired ( enParamId, usDataSize, pData ); } }
BST_UINT16 BST_CORE_CNPTask::InquiredTrafficFlow( BST_UINT16 usDataSize, BST_VOID *const pData ) { BST_IP_ERR_T enIpErr; BST_DBG_LOG( "BST_CORE_CNPTask::InquiredTrafficFlow email traffic flow info"); if ( usDataSize < BST_OS_SIZEOF ( BST_IP_TRAFFIC_FLOW_STRU ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::InquiredTrafficFlow usDataSize=%u", usDataSize ); return BST_CORE_INVALID_INQUIRED_LEN; } enIpErr = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_TRAFFIC_FLOW, pData ); ( BST_VOID )PidInquired ( BST_PID_TRAFFIC_FLOW, usDataSize, pData ); if ( BST_IP_ERR_OK == enIpErr ) { return ( BST_OS_SIZEOF ( BST_IP_TRAFFIC_FLOW_STRU ) ); } else { return BST_CORE_INVALID_INQUIRED_LEN; } }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ConfigedSockeProperty( BST_UINT16 usLen, const BST_VOID *const pData, BST_UINT8 **pucNewAddr ) { BST_IP_ERR_T enIpErrMsg; BST_ERR_ENUM_UINT8 ucRtnVal; if ( BST_NULL_PTR == m_pSocket ) { BST_RLS_LOG( "BST_CORE_CNPTask::ConfigedSockeProperty m_pSocket=NULL" ); return BST_ERR_ILLEGAL_PARAM; } if ( usLen < BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::ConfigedSockeProperty usLen=%u", usLen ); return BST_ERR_PAR_LEN; } enIpErrMsg = m_pSocket->IoCtrl ( BST_SCKT_CMD_SET_PROPERTY, ( BST_VOID *)pData ); BST_DBG_LOG1( "BST_CORE_CNPTask::ConfigedSockeProperty enIpErrMsg=%d", enIpErrMsg ); if( BST_IP_ERR_OK == enIpErrMsg ) { BST_SetConfigFlag ( BST_CFGFLG_PRTY ); ucRtnVal = BST_NO_ERROR_MSG; } else { ucRtnVal = BST_ERR_ILLEGAL_PARAM; } return ucRtnVal; }
BST_INT32 BST_OS_StaticMemGetIdleBlockNum( BST_MEM_TYPE_ENUM_UINT8 enType, BST_UINT32 ulSize) { BST_INT32 i; BST_MEM_BLOCK_INFO *pstMemInfo; BST_MEM_CTRL_BLOCK *pstMemCtrl; BST_INT32 lCycle; if(BST_MEM_TYPE_DYNAMIC == enType) { pstMemInfo = g_BstMemBlockInfo; lCycle = BST_MEM_CTRL_BLOCK_NUMBER; pstMemCtrl = g_BstMemCtrlBlk; } else if(BST_MEM_TYPE_PBUF == enType) { pstMemInfo = g_BstBufBlockInfo; lCycle = BST_BUF_CTRL_BLOCK_NUMBER; pstMemCtrl = g_BstBufCtrlBlk; } else { BST_RLS_LOG1("# BST_MemGetFreeBlockNum wrong type:%d", enType); return 0; } for ( i=0; i<lCycle; i++ ) { if(ulSize <= pstMemInfo[i].ulSize ) { return pstMemCtrl[i].lIdleBlockNumber; } } return 0; }