WTTF_MAC_DL_INFO_STRU * TTF_MNTN_ErrlogGetCommInfoBuffAddrForWDL(VOS_UINT32 ulPid) { MODEM_ID_ENUM_UINT16 enModemId = VOS_GetModemIDFromPid(ulPid); WTTF_MAC_DL_INFO_STRU *pstWttfDLInfo; if (enModemId >= MODEM_ID_BUTT) { TTF_LOG1(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogGetCommInfoBuffAddrForGUL: Invalid ModemId ", enModemId); enModemId = MODEM_ID_0; } if (VOS_NULL_PTR == TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)) { TTF_LOG1(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogGetCommInfoBuffAddrForWDL: No Mem ", enModemId); return VOS_NULL_PTR; } pstWttfDLInfo = &(TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)->astWttfMacDlInfo[TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)->ucWMacDlIndex]); pstWttfDLInfo->ulSlice = mdrv_timer_get_normal_timestamp(); TTF_ERR_LOG_COMM_COUNTER_INCR(TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)->ucWMacDlIndex, TTF_ERR_LOG_COMM_INFO_CNT); return pstWttfDLInfo; }
VOS_UINT32 TTF_MemRbFreeFidInit ( enum VOS_INIT_PHASE_DEFINE ip ) { VOS_UINT32 ulRslt; VOS_UINT32 ulReturnCode; switch( ip ) { case VOS_IP_LOAD_CONFIG: /* TTF_MemRb 模块注册PID */ ulRslt = VOS_RegisterPIDInfo(UEPS_PID_TTF_MEM_RB_FREE, (Init_Fun_Type)TTF_MemRbFreePidInit, (Msg_Fun_Type)TTF_MemRbFreeMsgProc); if( VOS_OK != ulRslt ) { TTF_LOG1(UEPS_PID_TTF_MEM_RB_FREE, PS_PRINT_ERROR, "reg TTF_MEM_RB_MemFreeFidInit VOS_RegisterPIDInfo FAIL! ulRslt: %d\n", (VOS_INT32)ulRslt); return (VOS_UINT32)VOS_ERROR; } ulRslt = VOS_RegisterTaskPrio(UEPS_FID_TTF_MEM_RB_FREE, TTF_MEM_RB_FREE_TASK_PRIO ); if( VOS_OK != ulRslt ) { TTF_LOG1(UEPS_PID_TTF_MEM_RB_FREE, PS_PRINT_ERROR, "reg MEM FREE task priority register FAIL ulRslt : %d !\n", (VOS_INT32)ulRslt); return (VOS_UINT32)VOS_ERROR; } /* TTF_MemRbRxFreeMemTask自处理任务注册 */ ulReturnCode = VOS_RegisterSelfTask(UEPS_FID_TTF_MEM_RB_FREE,(VOS_TASK_ENTRY_TYPE)TTF_MemRbRxFreeMemTask,VOS_PRIORITY_P5, (VOS_UINT32)TTF_MEM_RB_RX_MEM_FREE_TASK_STACK_SIZE); if ( VOS_NULL_BYTE == ulReturnCode ) { TTF_LOG(UEPS_PID_TTF_MEM_RB_FREE, PS_PRINT_ERROR, "TTF_MemRb, TTF_MEM_RB_MemFreeFidInit, ERROR, Fail regist IMM_RxFreeMemTask \n" ); return (VOS_UINT32)VOS_ERROR; } break; case VOS_IP_FARMALLOC: case VOS_IP_INITIAL: case VOS_IP_ENROLLMENT: case VOS_IP_LOAD_DATA: case VOS_IP_FETCH_DATA: case VOS_IP_STARTUP: case VOS_IP_RIVAL: case VOS_IP_KICKOFF: case VOS_IP_STANDBY: case VOS_IP_BROADCAST_STATE: case VOS_IP_RESTART: break; default: break; } return VOS_OK; }/* TTF_MemRbFreeFidInit */
VOS_VOID GTTF_MNTN_ErrlogTbfAbnmlEvt(VOS_UINT32 ulPid, VOS_UINT16 usType) { TTF_MNTN_ERR_LOG_GRLC_TBF_ABNML_STRU stTbfAbnml; VOS_UINT8 ucAlmLev; MODEM_ID_ENUM_UINT16 enModemId; ucAlmLev = TTF_ERR_LOG_GET_ALM_LEV(TTF_ERR_LOG_ALM_ID_GPRS_TBF_ABNML); enModemId = VOS_GetModemIDFromPid(ulPid); if (MODEM_ID_BUTT <= enModemId) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "GTTF_MNTN_ErrlogTbfAbnmlEvt: Invalid ModemId ", enModemId); return; } if (!TTF_ERR_LOG_NEED_RPT_LEV(enModemId, ucAlmLev)) { return; } TTF_ERR_LOG_FILL_HEADER( &stTbfAbnml.stHeader, enModemId, TTF_ERR_LOG_ALM_ID_GPRS_TBF_ABNML, ucAlmLev, (sizeof(TTF_MNTN_ERR_LOG_GRLC_TBF_ABNML_STRU) - sizeof(OM_ERR_LOG_HEADER_STRU))); stTbfAbnml.usAbnmlType = (VOS_UINT16)usType; TTF_MNTN_ErrlogBufPut(ulPid, (VOS_CHAR *)&stTbfAbnml, sizeof(TTF_MNTN_ERR_LOG_GRLC_TBF_ABNML_STRU)); }
VOS_UINT32 TTF_MemRbIsrInit(VOS_UINT32 ulPid, VOS_UINT32 ulIntLevel, VOIDFUNCPTR pfuncRecvIsr) { VOS_INT32 lIntRet; /* 挂接中断 */ #ifndef WTTF_PS_FUSION_PC_ST lIntRet = TTF_MEM_CONNECT_IPC_MEMFREE_INT(((IPC_INT_LEV_E)ulIntLevel), ((VOIDFUNCPTR)pfuncRecvIsr), VOS_NULL); #else lIntRet = VHW_IPC_IntConnect(ulPid,((IPC_INT_LEV_E)ulIntLevel), ((VOIDFUNCPTR)pfuncRecvIsr), VOS_NULL); #endif if (lIntRet != VOS_OK) { TTF_LOG1(UEPS_PID_TTF_MEM_RB_FREE, PS_PRINT_ERROR, "TTF_MemRbIsrInit connect %d ISR fail", (VOS_INT32)ulIntLevel); return VOS_ERR; } /* 使能通知中断 */ #ifndef WTTF_PS_FUSION_PC_ST TTF_MEM_ENABLE_IPC_INT((IPC_INT_LEV_E)ulIntLevel); #else VHW_IPC_IntEnable(ulPid,ulIntLevel); #endif return VOS_OK; } /* IMM_RbIsrInit */
VOS_VOID PS_Qnode_ResetCtrlInitNvPara(VOS_VOID) { VOS_UINT32 ulRslt; NV_NODE_RESET_CTRL_STRU stNvNodeResetCtrl; PS_MEM_SET(&g_stNvPsQnodeResetCtrl, 0x00, sizeof(NV_RATIO_RESET_CTRL_STRU)); ulRslt = NV_Read(en_NV_Item_NODE_RESET_CTRL, &stNvNodeResetCtrl, sizeof(NV_NODE_RESET_CTRL_STRU)); if (NV_OK != ulRslt) { TTF_LOG1(MSPS_PID_1X_RMAC, DIAG_MODE_COMM, PS_PRINT_WARNING, "PS_Qnode_ResetCtrlInitNvPara, Read Nv Fail", ulRslt); /* 若NV读取失败, 将复位控制参数置为默认置 */ g_stNvPsQnodeResetCtrl.enResetEnable = PS_TRUE; g_stNvPsQnodeResetCtrl.ucFailPercent = 95; g_stNvPsQnodeResetCtrl.usTotalStat = 500; return; } PS_MEM_CPY(&g_stNvPsQnodeResetCtrl, &(stNvNodeResetCtrl.astNvResetCtrl[PS_QNODE_RESET_TYPE]), sizeof(NV_RATIO_RESET_CTRL_STRU)); return; }
VOS_VOID TTF_MNTN_ErrlogCbReg(VOS_UINT32 ulPid, TTF_MNTN_ERR_LOG_RPT_CB pErrlogCb) { TTF_MODULE_ID_ENUM_UINT8 enModuleId; MODEM_ID_ENUM_UINT16 enModemId; enModuleId = TTF_MNTN_ErrLogGetModuleId(ulPid); if (MODULE_ID_BUTT <= enModuleId) { return; } enModemId = VOS_GetModemIDFromPid(ulPid); if (enModemId >= MODEM_ID_BUTT) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogCbReg: Invalid ModemId ", enModemId); return; } TTF_ERR_LOG_RPT_CB_SET(enModemId, enModuleId, pErrlogCb); }
VOS_VOID TTF_MNTN_ErrlogBufGet(VOS_UINT32 ulPid, MODEM_ID_ENUM_UINT16 enModemId, VOS_CHAR *pBuffer, VOS_UINT32 ulBytes) { VOS_UINT32 ulRslt; OM_RING_ID pRingId; if (VOS_NULL_PTR == pBuffer) { TTF_LOG(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufGet: pBuffer NULL PTR"); return; } if (enModemId >= MODEM_ID_BUTT) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufGet: Invalid ModemId ", enModemId); return; } pRingId = TTF_ERR_LOG_ENT_RINGID_GET(enModemId); if (VOS_NULL_PTR == pRingId) { TTF_LOG(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufGet: pRingId NULL PTR"); return; } ulRslt = VOS_SmP(TTF_ERR_LOG_ENT_SEM_GET(enModemId), TTF_ERR_SEM_TIMEOUT_LEN); if(VOS_OK != ulRslt) { TTF_LOG2(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufGet: VOS_SmP <1>, ulRslt<2> fail!", enModemId, (VOS_INT32)ulRslt); return; } ulRslt = (VOS_UINT32)OM_RingBufferGet(pRingId, pBuffer, (VOS_INT)ulBytes); if (ulRslt != ulBytes) { OM_RingBufferFlush(pRingId); TTF_LOG2(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufGet: ERROR OM_RingBufferGet fail!", (VOS_INT32)ulRslt, (VOS_INT32)ulBytes); } VOS_SmV(TTF_ERR_LOG_ENT_SEM_GET(enModemId)); }
TTF_MNTN_GSM_COMM_INFO_STRU * TTF_MNTN_ErrlogGetGsmCommInfo(VOS_UINT32 ulPid) { MODEM_ID_ENUM_UINT16 enModemId = VOS_GetModemIDFromPid(ulPid); if (enModemId >= MODEM_ID_BUTT) { TTF_LOG1(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogGetGsmCommInfo: Invalid ModemId ", enModemId); enModemId = MODEM_ID_0; } return TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId); }
VOS_VOID TTF_MemRbRxFreeMemTask(VOS_VOID) { /* 解决UT死循环问题 */ #ifdef __UT_CENTER__ VOS_UINT32 ulLoop; #endif VOS_UINT32 ulLoopCnt = 0; VOS_UINT32 ulSmRst = VOS_OK; TTF_RbRxFreeMemTaskInit(); #ifndef __UT_CENTER__ for ( ; ; ) #else for (ulLoop = 0; ulLoop < 1; ulLoop++) #endif { ulSmRst = VOS_SmP(g_ulTtfMemRbFreeSem, 0); /* take信号量失败是异常失败 */ if(VOS_OK != ulSmRst) { ulLoopCnt++; if (ulLoopCnt >= TTF_MEM_RB_TASK_FAIL_CNT_MAX) { DRV_SYSTEM_ERROR((VOS_INT)(TTF_MEM_RB_TASK_FAIL_SEM_ERR), (VOS_INT)ulSmRst, (VOS_INT)g_ulTtfMemRbFreeSem, (VOS_VOID *)&g_ulFreeTtfMemBlkNoticNum, 2 * sizeof(VOS_UINT32)); } TTF_LOG1(UEPS_PID_TTF_MEM_RB_FREE, PS_PRINT_ERROR, "TTF_MemRb, TTF_MEM_RB_RxFreeMemTask : ERROR : VOS_SmP Failed, Error Code = %d !\n", (VOS_INT)ulSmRst); VOS_TaskDelay(2); continue; } /* 释放 */ TTF_MemFreeFromQue(); } }/* TTF_MemRbRxFreeMemTask */
VOS_UINT32 TTF_MNTN_ErrLogRcvCtrlInd(MsgBlock *pstMsg, void *p) { OM_ERROR_LOG_CTRL_IND_STRU *pstCtrlInd; MODEM_ID_ENUM_UINT16 enModemId; pstCtrlInd = (OM_ERROR_LOG_CTRL_IND_STRU *)pstMsg; enModemId = (MODEM_ID_ENUM_UINT16)VOS_GetModemIDFromPid(pstCtrlInd->ulReceiverPid); if (MODEM_ID_BUTT <= enModemId) { TTF_LOG1(WUEPS_PID_RLC, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrLogRcvCtrlInd: Invalid ModemId ", enModemId); return VOS_ERR; } TTF_ERR_LOG_ENT_CTRL_STATUS_SET(enModemId, pstCtrlInd->ucAlmStatus); TTF_ERR_LOG_ENT_CTRL_LEV_SET(enModemId, pstCtrlInd->ucAlmLevel); return VOS_OK; }
VOS_VOID WTTF_MNTN_ErrlogTfciFailEvt(VOS_UINT32 ulPid, VOS_UINT8 ucMacState, TTF_MNTN_ERR_LOG_TFC_ERR_NO_CHOICE_ENUM8 enType) { VOS_UINT8 ucAlmLev; WTTF_MNTN_TFCI_FAIL_STRU stTtfMNtnTfciFail; MODEM_ID_ENUM_UINT16 enModemId; ucAlmLev = TTF_ERR_LOG_GET_ALM_LEV(TTF_ERR_LOG_ALM_ID_WRLC_TFCI_FAIL); enModemId = VOS_GetModemIDFromPid(ulPid); if (MODEM_ID_BUTT <= enModemId) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "WTTF_MNTN_ErrlogTfciFailEvt: Invalid ModemId ", enModemId); return; } if (!TTF_ERR_LOG_NEED_RPT_LEV(enModemId, ucAlmLev)) { return; } TTF_ERR_LOG_FILL_HEADER( &stTtfMNtnTfciFail.stHeader, enModemId, TTF_ERR_LOG_ALM_ID_WRLC_TFCI_FAIL, ucAlmLev, (sizeof(WTTF_MNTN_TFCI_FAIL_STRU) - sizeof(OM_ERR_LOG_HEADER_STRU))); stTtfMNtnTfciFail.ucMacState = ucMacState; stTtfMNtnTfciFail.enType = enType; /* 异常事件写入缓存中 */ TTF_MNTN_ErrlogBufPut(ulPid, (VOS_CHAR *)&stTtfMNtnTfciFail, sizeof(WTTF_MNTN_TFCI_FAIL_STRU)); return; }
VOS_VOID GTTF_MNTN_ErrlogMdlErrEvt(VOS_UINT32 ulPid, VOS_VOID *pMdlErr) { TTF_MNTN_ERR_LOG_GDL_MDL_ERR_STRU stMdlErrEvt; VOS_UINT8 ucAlmLev; MODEM_ID_ENUM_UINT16 enModemId; if (VOS_NULL_PTR == pMdlErr) { return; } ucAlmLev = TTF_ERR_LOG_GET_ALM_LEV(TTF_ERR_LOG_ALM_ID_GSM_MDL_ERR); enModemId = VOS_GetModemIDFromPid(ulPid); if (MODEM_ID_BUTT <= enModemId) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "GTTF_MNTN_ErrlogMdlErrEvt: Invalid ModemId ", enModemId); return; } if (!TTF_ERR_LOG_NEED_RPT_LEV(enModemId, ucAlmLev)) { return; } TTF_ERR_LOG_FILL_HEADER( &stMdlErrEvt.stHeader, enModemId, TTF_ERR_LOG_ALM_ID_GSM_MDL_ERR, ucAlmLev, (sizeof(TTF_MNTN_ERR_LOG_GDL_MDL_ERR_STRU) - sizeof(OM_ERR_LOG_HEADER_STRU))); PS_MEM_CPY(&stMdlErrEvt.stDlMdlErrInfo, pMdlErr, sizeof(TTF_MNTN_GDL_MDL_ERR_INFO_STRU)); TTF_MNTN_ErrlogBufPut(ulPid, (VOS_CHAR *)&stMdlErrEvt, sizeof(TTF_MNTN_ERR_LOG_GDL_MDL_ERR_STRU)); }
VOS_VOID WTTF_MNTN_ErrlogRlcResetEvt(VOS_UINT32 ulPid, VOS_UINT8 ucRbId, TTF_MNTN_ERR_LOG_WRLC_RESET_TYPE_ENUM_UINT8 enResetType) { TTF_MNTN_ERR_LOG_WRLC_RESET_STRU stTtfMntnWrlcReset; VOS_UINT8 ucAlmLev; MODEM_ID_ENUM_UINT16 enModemId; ucAlmLev = TTF_ERR_LOG_GET_ALM_LEV(TTF_ERR_LOG_ALM_ID_WRLC_RESET); enModemId = VOS_GetModemIDFromPid(ulPid); if (MODEM_ID_BUTT <= enModemId) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "WTTF_MNTN_ErrlogRlcResetEvt: Invalid ModemId ", enModemId); return; } if (!TTF_ERR_LOG_NEED_RPT_LEV(enModemId, ucAlmLev)) { return; } TTF_ERR_LOG_FILL_HEADER( &stTtfMntnWrlcReset.stHeader, enModemId, TTF_ERR_LOG_ALM_ID_WRLC_RESET, ucAlmLev, (sizeof(TTF_MNTN_ERR_LOG_WRLC_RESET_STRU) - sizeof(OM_ERR_LOG_HEADER_STRU))); stTtfMntnWrlcReset.ucRbId = ucRbId; stTtfMntnWrlcReset.enResetType = enResetType; stTtfMntnWrlcReset.usResetCnt = 1; /* 生成Reset事件 */ TTF_MNTN_ErrlogBufPut(ulPid, (VOS_CHAR *)&stTtfMntnWrlcReset, sizeof(TTF_MNTN_ERR_LOG_WRLC_RESET_STRU)); }
PS_RSLT_CODE_ENUM_UINT32 PS_Qnode_FreeNode(VOS_UINT16 usFileId, VOS_UINT16 usLineId, VOS_UINT32 ulOpPid, PS_QNODE_STRU *pstQnode) { VOS_UINT32 ulTick; VOS_INT32 lLockKey; PS_QNODE_TAMPERED_EVENT_STRU stEvent; const VOS_UINT16 us32Bit = 32; VOS_UINT16 usCurrPos; VOS_UINT16 usCurrOffset; VOS_UINT32 ulQnodeAddr; VOS_UINT32 ulFirstQnodeAddr; VOS_UINT32 ulLastQnodeAddr; ulTick = VOS_GetTick(); if (VOS_NULL_PTR == pstQnode) { lLockKey = VOS_SplIMP(); g_stMgmt.stStat.ulFreeNullPtrCnt++; g_stMgmt.stStat.ulFreeTotalCnt++; VOS_Splx(lLockKey); TTF_LOG4(ulOpPid, DIAG_MODE_COMM, PS_PRINT_WARNING, "FileId, LineId, Pid, tick, pstQnode is NULL", usFileId, usLineId, (VOS_INT32)ulOpPid, (VOS_INT32)ulTick); return PS_FAIL; } ulQnodeAddr = (VOS_UINT32)pstQnode; ulFirstQnodeAddr = (VOS_UINT32)(&g_astQnode[0]); ulLastQnodeAddr = (VOS_UINT32)(&g_astQnode[MAX_PS_QNODE_NUM - 1]); if ((0 != (ulQnodeAddr - ulFirstQnodeAddr) % sizeof(g_astQnode[0])) || ((ulQnodeAddr > ulLastQnodeAddr) || (ulQnodeAddr < ulFirstQnodeAddr))) { lLockKey = VOS_SplIMP(); g_stMgmt.stStat.ulFreeInvalidPrtCnt++; g_stMgmt.stStat.ulFreeTotalCnt++; VOS_Splx(lLockKey); TTF_LOG4(ulOpPid, DIAG_MODE_COMM, PS_PRINT_WARNING, "FileId, LineId, Pid, tick, pstQnode is invalid", usFileId, usLineId, (VOS_INT32)ulOpPid, (VOS_INT32)ulTick); return PS_FAIL; } if (PS_QNODE_MAGICNUM == pstQnode->usMagic) /* 未篡改 */ { if (PS_QNODE_USED_STATE != pstQnode->enState) { lLockKey = VOS_SplIMP(); g_stMgmt.stStat.ulFreePtrBeforeCnt++; g_stMgmt.stStat.ulFreeTotalCnt++; VOS_Splx(lLockKey); TTF_LOG4(ulOpPid, DIAG_MODE_COMM, PS_PRINT_WARNING, "FileId, LineId, Pid, tick, pstQnode has already been freed before", usFileId, usLineId, (VOS_INT32)ulOpPid, (VOS_INT32)ulTick); return PS_FAIL; } } else /* 被篡改 */ { lLockKey = VOS_SplIMP(); g_stMgmt.stStat.ulMagicTamperedCnt++; /* 强制恢复 */ pstQnode->usMagic = PS_QNODE_MAGICNUM; pstQnode->usIndex = (VOS_UINT16)((ulQnodeAddr - ulFirstQnodeAddr) / sizeof(g_astQnode[0])); VOS_Splx(lLockKey); /* 填写event */ stEvent.usFileId = usFileId; stEvent.usLineId = usLineId; stEvent.ulPid = ulOpPid; stEvent.ulTick = ulTick; stEvent.usEventId = ID_PS_QNODE_FOUND_TAMPERED; mdrv_memcpy(&(stEvent.stQnode), pstQnode, sizeof(stEvent.stQnode)); /* SDT要求event id必须挂接在某个固定的PID下, 暂决定挂在WRLC下 */ PS_Qnode_SendEvent(WUEPS_PID_RLC, ID_PS_QNODE_FOUND_TAMPERED, &stEvent, sizeof(stEvent)); TTF_LOG4(ulOpPid, 0, PS_PRINT_ERROR, "FileId, LineId, Pid, Qnode magic number tampered pstQnode", usFileId, usLineId, (VOS_INT32)ulOpPid, (VOS_INT32)pstQnode); TTF_LOG1(ulOpPid, 0, PS_PRINT_ERROR, "found magic number tampered pstQnode at tick", (VOS_INT32)ulTick); } lLockKey = VOS_SplIMP(); PS_MEM_SET(&(pstQnode->stMemSrc), 0x0, sizeof(pstQnode->stMemSrc)); PS_MEM_SET(&(pstQnode->aucPara[0]), 0x0, sizeof(pstQnode->aucPara)); pstQnode->stDbg.ulTraceTick = ulTick; pstQnode->stDbg.usTraceFileId = usFileId; pstQnode->stDbg.usTraceLineNum = usLineId; /* 刷新快表 */ usCurrPos = (pstQnode->usIndex) / us32Bit; usCurrOffset = (pstQnode->usIndex) % us32Bit; TTF_CLEAR_A_BIT(g_stMgmt.aulQuickMap[usCurrPos], ((us32Bit - 1) - usCurrOffset)); /* 刷新统计 */ g_stMgmt.stStat.ulFreeTotalCnt++; /* 把更新状态放在最后, 因为放前面, 可能出现getnode中一旦发现state可以申请就取走结点了, 多线程下会出现freenode未结束, 结点已经被取走使用 */ pstQnode->enState = PS_QNODE_FREE_STATE; VOS_Splx(lLockKey); return PS_SUCC; } /* PS_Qnode_FreeNode */
VOS_UINT32 TTF_MNTN_InitErrLogEnt(VOS_UINT32 ulPid) { VOS_UINT32 ulRslt; VOS_UINT32 ulTtfCommInfoBufLen; MODEM_ID_ENUM_UINT16 enModemId = VOS_GetModemIDFromPid(ulPid); if (MODEM_ID_BUTT <= enModemId) { enModemId = MODEM_ID_0; } if (VOS_YES == TTF_ERR_LOG_ENT_STATE_GET(enModemId)) { return VOS_OK; } PS_MEM_SET(apErrLogRptCb, 0, sizeof(apErrLogRptCb)); if (TTF_MEMCTRL_MODEL_SUPPORT_YES == TTF_MEM_GET_SUPPORT_WCDMA(enModemId)) { /* 初始化WCDMA基本配置信息结构体 */ ulTtfCommInfoBufLen = sizeof(TTF_MNTN_WCDMA_COMM_INFO_STRU); TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId) = (TTF_MNTN_WCDMA_COMM_INFO_STRU *)PS_ALLOC_STATIC_MEM(ulPid, ulTtfCommInfoBufLen); if (VOS_NULL_PTR == TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_InitErrLogEnt: PS_ALLOC_STATIC_MEM fail!", enModemId); return VOS_ERR; } PS_MEM_SET(TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId), 0, sizeof(TTF_MNTN_WCDMA_COMM_INFO_STRU)); TTF_ERR_LOG_FILL_HEADER( &(TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)->stHeader), enModemId, TTF_ERR_LOG_ALM_ID_WCDMA_COMM_INFO, TTF_ERR_LOG_ALM_LEV_CRITICAL, (sizeof(TTF_MNTN_WCDMA_COMM_INFO_STRU) - sizeof(OM_ERR_LOG_HEADER_STRU))); } if (TTF_MEMCTRL_MODEL_SUPPORT_YES == TTF_MEM_GET_SUPPORT_GSM(enModemId)) { /* 初始化GSM基本配置信息结构体 */ ulTtfCommInfoBufLen = sizeof(TTF_MNTN_GSM_COMM_INFO_STRU); TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId) = (TTF_MNTN_GSM_COMM_INFO_STRU *)PS_ALLOC_STATIC_MEM(ulPid, ulTtfCommInfoBufLen); if (VOS_NULL_PTR == TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId)) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_InitErrLogEnt: PS_ALLOC_STATIC_MEM fail!", enModemId); return VOS_ERR; } PS_MEM_SET(TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId), 0, sizeof(TTF_MNTN_GSM_COMM_INFO_STRU)); TTF_ERR_LOG_FILL_HEADER( &(TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId)->stHeader), enModemId, TTF_ERR_LOG_ALM_ID_GSM_COMM_INFO, TTF_ERR_LOG_ALM_LEV_CRITICAL, (sizeof(TTF_MNTN_GSM_COMM_INFO_STRU) - sizeof(OM_ERR_LOG_HEADER_STRU))); } /* 创建互斥信号量,每个Modem 1个 */ ulRslt = VOS_SmMCreate("TFEL", VOS_SEMA4_FIFO, (VOS_SEM *)(&TTF_ERR_LOG_ENT_SEM_GET(enModemId))); if (VOS_OK != ulRslt) { TTF_LOG2(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_InitErrLogEnt: Create TTF_ERR_LOG_ENT_SEM<1>, ulRslt<2> fail!", enModemId, (VOS_INT32)ulRslt); return ulRslt; } /* 读NV项获取当前上报状态 */ ulRslt = NV_ReadEx(enModemId, en_NV_Item_ErrLogCtrlInfo, &g_stTtfMntnErrlogEnt.stCtrlInfo[enModemId], sizeof(NV_ID_ERR_LOG_CTRL_INFO_STRU)); if (VOS_OK != ulRslt) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_InitErrLogEnt: NV_ReadEx fail!", (VOS_INT32)ulRslt); TTF_ERR_LOG_ENT_CTRL_STATUS_SET(enModemId, OM_APP_STATUS_CLOSE); } TTF_MNTN_InitErrlogBuffer(enModemId); TTF_ERR_LOG_ENT_STATE_SET(enModemId, VOS_YES); return VOS_OK; }
VOS_VOID TTF_MNTN_ErrlogBufPut(VOS_UINT32 ulPid, VOS_CHAR *pBuffer, VOS_UINT32 ulBytes) { MODEM_ID_ENUM_UINT16 enModemId; VOS_UINT32 ulRslt; VOS_UINT32 ulBuffFreeSize; OM_RING_ID pRingId; if (VOS_NULL_PTR == pBuffer) { TTF_LOG(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufPut: pBuffer NULL PTR"); return; } enModemId = VOS_GetModemIDFromPid(ulPid); if (enModemId >= MODEM_ID_BUTT) { TTF_LOG1(ulPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufPut: Invalid ModemId ", enModemId); return; } pRingId = TTF_ERR_LOG_ENT_RINGID_GET(enModemId); if (VOS_NULL_PTR == pRingId) { TTF_LOG(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufPut: pRingId NULL PTR"); return; } ulRslt = VOS_SmP(TTF_ERR_LOG_ENT_SEM_GET(enModemId), TTF_ERR_SEM_TIMEOUT_LEN); if(VOS_OK != ulRslt) { TTF_LOG2(ulPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufPut: Create TTF_ERR_LOG_ENT_SEM<1>, ulRslt<2> fail!", enModemId, (VOS_INT32)ulRslt); return; } ulBuffFreeSize =(VOS_UINT32) OM_RingBufferFreeBytes(pRingId); /* Buffer不足,溢出处理 */ if (ulBuffFreeSize < (ulBytes + TTF_ERR_LOG_ENT_GET_BUF_RSV_LEN(enModemId))) { TTF_ERR_LOG_ENT_UPDT_BUFFER_OVER_CNT(enModemId, 1); OM_RingBufferFlush(pRingId); } ulRslt = (VOS_UINT32)OM_RingBufferPut(pRingId, pBuffer, (VOS_INT)ulBytes); if (ulBytes != ulRslt) { OM_RingBufferFlush(pRingId); } VOS_SmV(TTF_ERR_LOG_ENT_SEM_GET(enModemId)); return; }
/*lint -e{416,419,831} */ VOS_VOID TTF_MNTN_ErrlogBufRpt(VOS_UINT32 ulSenderPid, VOS_UINT32 ulReceiverPid, MODEM_ID_ENUM_UINT16 enModemId) { VOS_UINT32 ulRslt; VOS_UINT32 ulErrLogBufSize; VOS_UINT32 ulTtfCommInfoBufSize; VOS_UINT32 ulMsgLen; OM_RING_ID pRingId; VOS_UINT32 ulCpuID; OM_ERR_LOG_REPORT_CNF_STRU *pstLogRpt; VOS_UINT32 ulOffSetLen; VOS_CHAR *pucContent; if (enModemId >= MODEM_ID_BUTT) { TTF_LOG1(ulSenderPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufRpt: enModemId Invalid!", enModemId); return; } ulCpuID = VOS_GET_CPU_ID(ulReceiverPid); if ( ulCpuID >= VOS_SUPPORT_CPU_NUM_MAX ) { TTF_LOG1(ulSenderPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufRpt: ulReceiverPid Invalid!", (VOS_INT32)ulReceiverPid); return; } /* 初始化没有异常 */ ulErrLogBufSize = 0; pRingId = TTF_ERR_LOG_ENT_RINGID_GET(enModemId); if (VOS_NULL_PTR != pRingId) { /* 将各模块本地缓存的数据写入Buffer */ TTF_MNTN_ErrlogCbRun(enModemId); /* 保留的长度复位 */ TTF_ERR_LOG_ENT_RST_BUF_RSV_LEN(enModemId); ulRslt = VOS_SmP(TTF_ERR_LOG_ENT_SEM_GET(enModemId), TTF_ERR_SEM_TIMEOUT_LEN); if(VOS_OK != ulRslt) { TTF_LOG2(ulSenderPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufRpt: VOS_SmP <1>, ulRslt<2> fail!", enModemId, (VOS_INT32)ulRslt); return; } ulErrLogBufSize = (VOS_UINT32)OM_RingBufferNBytes(pRingId); if (ulErrLogBufSize > TTF_ERR_LOG_BUF_SIZE) { OM_RingBufferFlush(pRingId); TTF_LOG1(ulSenderPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufRpt: ulErrLogBufSize invalid!", (VOS_INT32)ulErrLogBufSize); ulErrLogBufSize = 0; } VOS_SmV(TTF_ERR_LOG_ENT_SEM_GET(enModemId)); } ulTtfCommInfoBufSize = 0; if (VOS_NULL_PTR != TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)) { ulTtfCommInfoBufSize += sizeof(TTF_MNTN_WCDMA_COMM_INFO_STRU); TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)->usRingBufferOverCounter = TTF_ERR_LOG_ENT_BUFFER_OVER_CNT_GET(enModemId); } if (VOS_NULL_PTR != TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId)) { ulTtfCommInfoBufSize += sizeof(TTF_MNTN_GSM_COMM_INFO_STRU); TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId)->usRingBufferOverCounter = TTF_ERR_LOG_ENT_BUFFER_OVER_CNT_GET(enModemId); } /* Reset环形Buffer溢出标识 */ TTF_ERR_LOG_ENT_BUFFER_OVER_CNT_SET(enModemId, 0); /* 计算消息总的长度 */ TTF_GET_OFFSET(ulOffSetLen, OM_ERR_LOG_REPORT_CNF_STRU, aucContent); ulMsgLen = ulOffSetLen + ulTtfCommInfoBufSize + ulErrLogBufSize; pstLogRpt = (OM_ERR_LOG_REPORT_CNF_STRU *)PS_ALLOC_MSG_WITH_HEADER_LEN(ulSenderPid, ulMsgLen); if (VOS_NULL_PTR == pstLogRpt) { TTF_LOG1(ulSenderPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufRpt: PS_ALLOC_MSG_WITH_HEADER_LEN fail!", (VOS_INT32)ulMsgLen); return; } /* 开始拷贝基本信息 */ pucContent = (VOS_CHAR *)(pstLogRpt->aucContent); if (VOS_NULL_PTR != TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId)) /*lint -e{662,669} */ { /* 拷贝WCDMA基本配置信息 */ PS_MEM_CPY((VOS_VOID *)pucContent, (VOS_VOID *)TTF_ERR_LOG_ENT_WCDMA_COMM_INFO_GET(enModemId), (VOS_UINT32)(sizeof(TTF_MNTN_WCDMA_COMM_INFO_STRU))); pucContent += (VOS_UINT32)(sizeof(TTF_MNTN_WCDMA_COMM_INFO_STRU)); } if (VOS_NULL_PTR != TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId)) /*lint -e{662,669} */ { /* 拷贝GSM基本配置信息 */ PS_MEM_CPY((VOS_VOID *)pucContent, (VOS_VOID *)TTF_ERR_LOG_ENT_GSM_COMM_INFO_GET(enModemId), (VOS_UINT32)(sizeof(TTF_MNTN_GSM_COMM_INFO_STRU))); pucContent += (VOS_UINT32)(sizeof(TTF_MNTN_GSM_COMM_INFO_STRU)); } /* 拷贝异常事件信息 */ if (0 != ulErrLogBufSize) { TTF_MNTN_ErrlogBufGet( ulSenderPid, enModemId, pucContent, ulErrLogBufSize); } pstLogRpt->ulReceiverPid = ulReceiverPid; pstLogRpt->ulMsgName = ID_OM_ERR_LOG_REPORT_CNF; pstLogRpt->ulMsgType = OM_ERR_LOG_MSG_ERR_REPORT; pstLogRpt->ulMsgSN = mdrv_timer_get_normal_timestamp(); pstLogRpt->ulRptlen = ulTtfCommInfoBufSize + ulErrLogBufSize; PS_SEND_MSG(UEPS_PID_SN, pstLogRpt); return; }