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)); }
/***************************************************************************** 函 数 名 : Log_SelfTask 功能描述 : 打印自处理任务 输入参数 : VOS_UINT32 ulPara1 VOS_UINT32 ulPara2 VOS_UINT32 ulPara3 VOS_UINT32 ulPara4 输出参数 : 无 返 回 值 : VOS_VOID 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2007年4月24日 作 者 : 李霄 46160 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID Log_SelfTask(VOS_UINT32 ulPara1, VOS_UINT32 ulPara2, VOS_UINT32 ulPara3, VOS_UINT32 ulPara4) { VOS_INT32 sRet; VOS_UINT32 ulLen; /*lint -e813*/ VOS_CHAR acTmpStr[LOG_MAX_COLUMN_VAL_EX + 1]; /*lint +e813*/ ulPara1 = ulPara1; ulPara2 = ulPara2; ulPara3 = ulPara3; ulPara4 = ulPara4; Log_Init(); for(;;) { if(VOS_OK != VOS_SmP(g_stLogEnt.semOmPrint, 0)) { continue; } if (LOG_NULL_PTR == g_stLogEnt.rngOmRbufId) { continue; } if (LOG_TRUE == OM_RingBufferIsEmpty(g_stLogEnt.rngOmRbufId)) { continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, (VOS_CHAR*)(&ulLen), sizeof(VOS_UINT32)); if (sizeof(VOS_UINT32) != (VOS_UINT32)sRet) { continue; } if(LOG_MAX_COLUMN_VAL_EX < ulLen) { OM_RingBufferFlush(g_stLogEnt.rngOmRbufId); continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, acTmpStr, (VOS_INT32)ulLen); if (ulLen == (VOS_UINT32)sRet) { Log_Output(g_stLogEnt.ulLogOutput, acTmpStr, ulLen); } } }
VOS_VOID NFExt_FlushRingBuffer(OM_RING_ID rngId) { NF_EXT_DATA_RING_BUF_STRU stData; VOS_UINT32 ulFlags; while (!OM_RingBufferIsEmpty(rngId)) { NFExt_RingBufferGet(rngId, (VOS_CHAR*)(&stData), sizeof(NF_EXT_DATA_RING_BUF_STRU)); NF_EXT_MEM_FREE(ACPU_PID_NFEXT, stData.pData); } spin_lock_irqsave(&g_stExEntity.stLockTxTask, ulFlags); OM_RingBufferFlush(rngId); spin_unlock_irqrestore(&g_stExEntity.stLockTxTask, ulFlags); }
/******************************************************************************* * * OM_RingBufferCreateEx - create an empty ring buffer in exist buffer * * This routine creates a ring buffer of size <nbytes>, and initializes * it. Memory for the buffer is allocated by user. * * RETURNS * The ID of the ring buffer, or NULL if memory cannot be allocated. * * ERRNO: N/A. ************************************************************************/ OM_RING_ID OM_RingBufferCreateEx(char *pdata, int nbytes ) { OM_RING_ID ringId; VOS_INT i; VOS_INT lTempSufffix = VOS_NULL_WORD; VOS_UINT32 ulLockLevel; if ((VOS_NULL_PTR == pdata)||(OM_RING_BUFF_EX_MAX_LEN < nbytes)) { return VOS_NULL_PTR; } /*lLockLevel = VOS_SplIMP();*/ VOS_SpinLockIntLock(&g_stVosStaticMemSpinLock, ulLockLevel); for ( i=OM_MAX_RING_BUFFER_NUM -1; i>=0; i-- ) { if ( VOS_FALSE == g_ucOMBufferOccupiedFlag[i] ) { lTempSufffix = i; g_ucOMBufferOccupiedFlag[i] = VOS_TRUE; break; } } /*VOS_Splx(lLockLevel);*/ VOS_SpinUnlockIntUnlock(&g_stVosStaticMemSpinLock, ulLockLevel); if ( VOS_NULL_WORD == lTempSufffix ) { return VOS_NULL_PTR; } /* * bump number of bytes requested because ring buffer algorithm * always leaves at least one empty byte in buffer */ ringId = &(g_stOMControlBlock[lTempSufffix]); ringId->bufSize = nbytes; ringId->buf = pdata; OM_RingBufferFlush (ringId); return (ringId); }
/***************************************************************************** 函 数 名 : Log_SelfTask 功能描述 : 打印自处理任务 输入参数 : unsigned long ulPara1 unsigned long ulPara2 unsigned long ulPara3 unsigned long ulPara4 输出参数 : 无 返 回 值 : void 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2007年4月24日 作 者 : 李霄 46160 修改内容 : 新生成函数 *****************************************************************************/ void Log_SelfTask(unsigned long ulPara1, unsigned long ulPara2, unsigned long ulPara3, unsigned long ulPara4) { int sRet; unsigned long ulLen; /*lint -e813*/ char acTmpStr[LOG_MAX_COLUMN_VAL_EX + 1]; /*lint +e813*/ Log_Init(); for(;;) { if(VOS_OK != VOS_SmP(g_stLogEnt.semOmPrint, 0)) { continue; } if (LOG_NULL_PTR == g_stLogEnt.rngOmRbufId) { continue; } if (LOG_TRUE == OM_RingBufferIsEmpty(g_stLogEnt.rngOmRbufId)) { continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, (char*)(&ulLen), sizeof(unsigned long)); if (sizeof(unsigned long) != (unsigned long)sRet) { continue; } if(LOG_MAX_COLUMN_VAL_EX < ulLen) { OM_RingBufferFlush(g_stLogEnt.rngOmRbufId); continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, acTmpStr, (long)ulLen); if (ulLen == (unsigned long)sRet) { Log_Output(g_stLogEnt.ulLogOutput, acTmpStr, ulLen); } } }
VOS_UINT32 NAS_CC_PutErrLogRingBuf( VOS_CHAR *pbuffer, VOS_UINT32 ulbytes ) { VOS_UINT32 ulFreeSize; VOS_UINT32 ulCount; OM_RING_ID pTafRingBuffer; pTafRingBuffer = NAS_CC_GetErrLogRingBufAddr(); if (VOS_NULL_PTR == pTafRingBuffer) { return 0; } /* 如果写入比RING BUFFER还大则不写入 */ if (ulbytes > TAF_SDC_RING_BUFFER_SIZE) { return 0; } /* 获取RING BUFFER剩余空间大小 */ ulFreeSize = (VOS_UINT32)OM_RingBufferFreeBytes(pTafRingBuffer); ulCount = NAS_CC_GetErrlogOverflowCnt(); /* 如果剩余空间不足写入的大小,则清空RING BUFFER */ if (ulFreeSize < ulbytes) { ulCount++; NAS_CC_SetErrlogOverflowCnt(ulCount); OM_RingBufferFlush(pTafRingBuffer); } /* 写入RING BUFFER */ return (VOS_UINT32)OM_RingBufferPut(pTafRingBuffer, pbuffer, (VOS_INT)ulbytes); }
VOS_VOID SCM_SoftDecodeCfgRcvSelfTask( VOS_UINT32 ulPara1, VOS_UINT32 ulPara2, VOS_UINT32 ulPara3, VOS_UINT32 ulPara4) { VOS_INT32 sRet; VOS_INT32 lLen; VOS_INT32 lRemainlen; VOS_INT32 lReadLen; VOS_UINT32 ulPktNum; VOS_UINT32 i; VOS_ULONG ulLockLevel; ulPara1 = ulPara1; ulPara2 = ulPara2; ulPara3 = ulPara3; ulPara4 = ulPara4; for (;;) { if (VOS_OK != VOS_SmP(g_stSCMDataRcvTaskCtrlInfo.SmID, 0)) { continue; } diag_PTR(EN_DIAG_PTR_SCM_SELFTASK); lLen = OM_RingBufferNBytes(g_stSCMDataRcvTaskCtrlInfo.rngOmRbufId); if (lLen <= 0) { continue; } ulPktNum = (VOS_UINT32)((lLen + SCM_DATA_RCV_PKT_SIZE - 1) / SCM_DATA_RCV_PKT_SIZE); lRemainlen = lLen; for (i = 0; i < ulPktNum; i++) { if (SCM_DATA_RCV_PKT_SIZE < lRemainlen) { lReadLen = SCM_DATA_RCV_PKT_SIZE; sRet = OM_RingBufferGet(g_stSCMDataRcvTaskCtrlInfo.rngOmRbufId, g_stSCMDataRcvTaskCtrlInfo.pucBuffer, SCM_DATA_RCV_PKT_SIZE); } else { lReadLen = lRemainlen; sRet = OM_RingBufferGet(g_stSCMDataRcvTaskCtrlInfo.rngOmRbufId, g_stSCMDataRcvTaskCtrlInfo.pucBuffer, lRemainlen); } if (sRet != lReadLen) { VOS_SpinLockIntLock(&g_stScmSoftDecodeDataRcvSpinLock, ulLockLevel); OM_RingBufferFlush(g_stSCMDataRcvTaskCtrlInfo.rngOmRbufId); VOS_SpinUnlockIntUnlock(&g_stScmSoftDecodeDataRcvSpinLock, ulLockLevel); g_stScmSoftDecodeInfo.stRbInfo.ulRingBufferFlush++; diag_PTR(EN_DIAG_PTR_SCM_ERR3); continue; } lRemainlen -= lReadLen; g_stScmSoftDecodeInfo.stGetInfo.ulDataLen += lReadLen; diag_PTR(EN_DIAG_PTR_SCM_RCVDATA); /* 调用HDLC解封装函数 */ if (VOS_OK != SCM_SoftDecodeAcpuRcvData(&g_stScmHdlcSoftDecodeEntity, (VOS_UINT8 *)g_stSCMDataRcvTaskCtrlInfo.pucBuffer, (VOS_UINT32)lReadLen)) { /*lint -e534*/ vos_printf("SCM_SoftDecodeCfgRcvSelfTask: SCM_SoftDecodeAcpuRcvData Fail.\n"); /*lint +e534*/ } } #if (defined(DMT)) return; #endif } }
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; }
VOS_VOID OM_PrintfTask(VOS_VOID) { VOS_UINT32 ulBufLen; VOS_UINT32 ulBufAlignLen; #if (VOS_WIN32 == VOS_OS_VER) VOS_UINT32 i; #endif /*lint -e813 */ /* 前四字节用来存储模块ID */ VOS_CHAR acOutput[VOS_MAX_PRINT_LEN+8]; /*lint +e813 */ VOS_UINT32 ulRet; if ( VOS_OK != VOS_SmBCreate( "PRT", 0, VOS_SEMA4_FIFO, &g_ulPrintfTaskSem)) { return; } #if (VOS_WIN32 == VOS_OS_VER) for (i = 0; i < 1; i++) #else for (;;) #endif { if(VOS_OK != VOS_SmP(g_ulPrintfTaskSem, 0)) { g_ulPrintfErrType = OM_ERR_FAILTAKETASKSEM; continue; } /* ringbuf中无数据 */ #if (VOS_WIN32 == VOS_OS_VER) for (i = 0; i < 1; i++) #else while(VOS_FALSE == OM_RingBufferIsEmpty(g_pstOmPrintfBufId)) #endif { /* 获取数据长度 */ ulRet = (VOS_UINT32)OM_RingBufferGet(g_pstOmPrintfBufId, (VOS_CHAR *)&ulBufLen, sizeof(VOS_UINT32)); if (sizeof(VOS_UINT32) != ulRet) { g_ulPrintfErrType = OM_ERR_FAILPUTDATA; OM_RingBufferFlush(g_pstOmPrintfBufId); continue; } /* ringbuf中数据损坏 */ if (VOS_MAX_PRINT_LEN <= ulBufLen) { g_ulPrintfErrType = OM_ERR_DATADESTROY; OM_RingBufferFlush(g_pstOmPrintfBufId); continue; } ulBufAlignLen = (ulBufLen+OM_ALIGNMENT)&(~OM_ALIGNMENT); /* 获取数据内容 */ ulRet = (VOS_UINT32)OM_RingBufferGet(g_pstOmPrintfBufId, (VOS_CHAR *)acOutput, (VOS_INT)ulBufAlignLen); if (ulBufAlignLen != ulRet) { g_ulPrintfErrType = OM_ERR_FAILPUTDATA; OM_RingBufferFlush(g_pstOmPrintfBufId); continue; } /* 根据输出端口分发数据 */ switch(g_ulOmPrintfPort) { case OM_OUTPUT_SHELL: acOutput[ulBufLen] = 0; #if (VOS_OS_VER == VOS_LINUX) printk( "%s", acOutput + OM_PRINTF_OFFSET); #else printf( "%s", acOutput + OM_PRINTF_OFFSET); #endif break; case OM_OUTPUT_SDT: OM_SndPrintfToOm(acOutput, ulBufLen); break; default: break; } } } }
VOS_UINT32 OM_PrintfDataPut(VOS_CHAR *pucDataBuf, VOS_UINT32 ulDataLen) { VOS_UINT32 ulFreeSize; VOS_UINT32 ulRet; VOS_UINT32 ulReturn = OM_OK; VOS_UINT32 ulBufAlignLen; VOS_CHAR *pcWarning; /* OM Printf未初始化时,将打印输出到SHELL,打印时跳过模块ID四个字节 */ if(VOS_FALSE == g_bIsPrintfInit) { #if (VOS_OS_VER == VOS_LINUX) printk( "%s", pucDataBuf + OM_PRINTF_OFFSET); #else printf( "%s", pucDataBuf + OM_PRINTF_OFFSET); #endif return OM_OK; } g_stOmPrintfErrRecord.ulOmPrintfRecvLen += ulDataLen; g_stOmPrintfErrRecord.usOmPrintfRecvCount++; /* 获取buffer保护的信号量 */ if(VOS_OK != VOS_SmP(g_ulOmPrintfBuffSem, 0)) { g_ulPrintfErrType = OM_ERR_FAILTAKESEM; return OM_ERR_FAILTAKESEM; } /* 查看OM Printf ringbuffer 剩余空间 */ ulFreeSize = (VOS_UINT32)OM_RingBufferFreeBytes(g_pstOmPrintfBufId); ulBufAlignLen = (ulDataLen+OM_ALIGNMENT)&(~OM_ALIGNMENT); /* 数据长度加四字节长度字段 */ if ((ulBufAlignLen + sizeof(VOS_UINT32)) > ulFreeSize) { g_stOmPrintfErrRecord.ulOmPrintfNoPrintfBufferLostLen += ((OM_PRINTF_BUFFER_SIZE - ulFreeSize) + ulDataLen); g_stOmPrintfErrRecord.usOmPrintfNoPrintfBufferLostCount++; g_ulPrintfErrType = OM_ERR_NOBUF; /* OM Printf缓冲区满时,清空ringbuffer,提示用户有数据丢失 */ OM_RingBufferFlush(g_pstOmPrintfBufId); pcWarning = "OM_Printf:Warning!Some data lost!\n"; *((VOS_UINT32*)pucDataBuf) = WUEPS_PID_OM; *(((VOS_UINT32*)pucDataBuf)+1) = LOG_LEVEL_INFO; /* 跳过用于存放模块ID的前四字节 */ VOS_StrCpy(pucDataBuf + OM_PRINTF_OFFSET, pcWarning ); ulDataLen = VOS_StrLen(pcWarning)+OM_PRINTF_OFFSET; ulBufAlignLen = (ulDataLen+OM_ALIGNMENT)&(~OM_ALIGNMENT); ulReturn = OM_ERR_NOBUF; } /* 把长度字段放入OM Printf ringbuffer*/ ulRet = (VOS_UINT32)OM_RingBufferPut(g_pstOmPrintfBufId, (VOS_CHAR *)&ulDataLen, (VOS_INT)sizeof(VOS_UINT32)); if(sizeof(VOS_UINT32) != ulRet) { OM_RingBufferFlush(g_pstOmPrintfBufId); VOS_SmV(g_ulOmPrintfBuffSem); g_ulPrintfErrType = OM_ERR_FAILPUTDATA; return OM_ERR_FAILPUTDATA; } /* 把数据放入OM Printf ringbuffer*/ ulRet = (VOS_UINT32)OM_RingBufferPut(g_pstOmPrintfBufId, pucDataBuf,(VOS_INT)ulBufAlignLen); if(ulBufAlignLen != ulRet) { OM_RingBufferFlush(g_pstOmPrintfBufId); VOS_SmV(g_ulOmPrintfBuffSem); g_ulPrintfErrType = OM_ERR_FAILPUTDATA; return OM_ERR_FAILPUTDATA; } VOS_SmV(g_ulOmPrintfBuffSem); /* 释放自处理任务信号量 */ VOS_SmV(g_ulPrintfTaskSem); return ulReturn; }
/******************************************************************************* * * OM_RingBufferCreate - create an empty ring buffer * * This routine creates a ring buffer of size <nbytes>, and initializes * it. Memory for the buffer is allocated from the system memory partition. * * RETURNS * The ID of the ring buffer, or NULL if memory cannot be allocated. * * ERRNO: N/A. ************************************************************************/ OM_RING_ID OM_RingBufferCreate( int nbytes ) { char *buffer; OM_RING_ID ringId; VOS_INT i; VOS_INT lTempSufffix = VOS_NULL_WORD; VOS_UINT32 ulLockLevel; /*lLockLevel = VOS_SplIMP();*/ VOS_SpinLockIntLock(&g_stVosStaticMemSpinLock, ulLockLevel); for ( i=OM_MAX_RING_BUFFER_NUM -1; i>=0; i-- ) { if ( VOS_FALSE == g_ucOMBufferOccupiedFlag[i] ) { lTempSufffix = i; g_ucOMBufferOccupiedFlag[i] = VOS_TRUE; break; } } /*VOS_Splx(lLockLevel);*/ VOS_SpinUnlockIntUnlock(&g_stVosStaticMemSpinLock, ulLockLevel); if ( VOS_NULL_WORD == lTempSufffix ) { return VOS_NULL_PTR; } /* * bump number of bytes requested because ring buffer algorithm * always leaves at least one empty byte in buffer */ /* buffer = (char *) malloc ((unsigned) ++nbytes); */ buffer = (char *) DRV_CACHEDMAM_ALLOC((unsigned) ++nbytes); if ( VOS_NULL_PTR == buffer ) { /*lLockLevel = VOS_SplIMP();*/ VOS_SpinLockIntLock(&g_stVosStaticMemSpinLock, ulLockLevel); g_ucOMBufferOccupiedFlag[lTempSufffix] = VOS_FALSE; /*VOS_Splx(lLockLevel);*/ VOS_SpinUnlockIntUnlock(&g_stVosStaticMemSpinLock, ulLockLevel); OM_DRV_CACHEDMAM_ALLOC_ERROR(); return VOS_NULL_PTR; } ringId = &(g_stOMControlBlock[lTempSufffix]); ringId->bufSize = nbytes; ringId->buf = buffer; OM_RingBufferFlush (ringId); return (ringId); }
VOS_VOID NAS_CC_CleanErrLogRingBuf(VOS_VOID) { OM_RingBufferFlush(NAS_CC_GetErrLogRingBufAddr()); return; }
VOS_VOID TTF_MNTN_ErrlogBufRpt(VOS_UINT32 ulSenderPid, VOS_UINT32 ulReceiverPid, MODEM_ID_ENUM_UINT16 enModemId) { VOS_UINT32 ulRslt; VOS_UINT32 ulBufSize; VOS_UINT32 ulMsgLen; OM_RING_ID pRingId; VOS_UINT32 ulCpuID; OM_ERR_LOG_REPORT_CNF_STRU *pstLogRpt; if (enModemId >= MODEM_ID_BUTT) { PS_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 ) { PS_LOG1(ulSenderPid, 0, PS_PRINT_ERROR, "TTF_MNTN_ErrlogBufRpt: ulReceiverPid Invalid!", (VOS_INT32)ulReceiverPid); return; } pRingId = TTF_ERR_LOG_ENT_RINGID_GET(enModemId); /* Default没有异常 */ ulBufSize = 0; if (VOS_NULL_PTR != pRingId) { /* 保留的长度复位 */ TTF_ERR_LOG_ENT_RST_BUF_RSV_LEN(enModemId); /* 将各模块本地缓存的数据写入Buffer */ TTF_MNTN_ErrlogCbRun(enModemId); ulRslt = VOS_SmP(TTF_ERR_LOG_ENT_SEM_GET(enModemId), TTF_ERR_SEM_TIMEOUT_LEN); if(VOS_OK != ulRslt) { PS_LOG2(ulSenderPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufRpt: VOS_SmP <1>, ulRslt<2> fail!", enModemId, (VOS_INT32)ulRslt); return; } ulBufSize = (VOS_UINT32)OM_RingBufferNBytes(pRingId); if (ulBufSize > TTF_ERR_LOG_BUF_SIZE) { OM_RingBufferFlush(pRingId); PS_LOG1(ulSenderPid, 0, PS_PRINT_WARNING, "TTF_MNTN_ErrlogBufGet: ulBufSize invalid!", (VOS_INT32)ulBufSize); ulBufSize = 0; } VOS_SmV(TTF_ERR_LOG_ENT_SEM_GET(enModemId)); } /*lint -e413*/ ulMsgLen = (TTF_OFFSET_OF(OM_ERR_LOG_REPORT_CNF_STRU, aucContent[0])) + ulBufSize; pstLogRpt = (OM_ERR_LOG_REPORT_CNF_STRU *)PS_ALLOC_MSG_WITH_HEADER_LEN(ulSenderPid, ulMsgLen); if (VOS_NULL_PTR == pstLogRpt) { return; } if (0 != ulBufSize) { TTF_MNTN_ErrlogBufGet(ulSenderPid, enModemId, (VOS_CHAR *)(pstLogRpt->aucContent), ulBufSize); } pstLogRpt->ulReceiverPid = ulReceiverPid; pstLogRpt->ulMsgName = ID_OM_ERR_LOG_REPORT_CNF; pstLogRpt->ulMsgType = OM_ERR_LOG_MSG_ERR_REPORT; pstLogRpt->ulMsgSN = VOS_GetSlice(); pstLogRpt->ulRptlen = ulBufSize; /*lint +e413*/ PS_SEND_MSG(UEPS_PID_SN, pstLogRpt); }