/***************************************************************************** 函 数 名 : Debug_DiagCreateFile 功能描述 : 创建诊断debug文件,如果已经存在则进行删除 输入参数 : VOS_VOID 输出参数 : VOS_VOID 返 回 值 : VOS_VOID *****************************************************************************/ VOS_VOID Debug_DiagCreateFile(VOS_VOID) { #if 0 FILE *logfp = NULL; logfp = DRV_FILE_OPEN(DecoderDestReadCB_LogPath, "w+"); if (VOS_NULL_PTR == logfp) { diag_printf("Create DecoderDestReadCB_LogPath txt fail\n"); } else { DRV_FILE_CLOSE(logfp); } logfp = DRV_FILE_OPEN(UsbCtrlRdCB_LogPath, "w+"); if (VOS_NULL_PTR == logfp) { diag_printf("Create UsbCtrlRdCB_LogPath txt fail\n"); } else { DRV_FILE_CLOSE(logfp); } #endif return; }
/*lint -e960 */ VOS_VOID SC_Printf(const VOS_CHAR *pcformat, ...) /*lint +e960 */ { VOS_CHAR aucIMEILogFilePath[100]; VOS_CHAR acOutput[SC_LOG_MAX_LEN]; va_list argument; VOS_UINT32 ulRetLen; FILE *fp; VOS_UINT32 ulFileSize; /* 将格式化字符串和可变参数转换为字符串 */ va_start(argument, pcformat); ulRetLen = (VOS_UINT32)vsnprintf(acOutput, SC_LOG_MAX_LEN, pcformat, argument); va_end(argument); if ((SC_LOG_MAX_LEN < ulRetLen) || (0 == ulRetLen)) { return ; } if (VOS_OK != OM_GetLogPath(aucIMEILogFilePath, SC_IMEI_LOG_FILE_PATH, SC_IMEI_UNITARY_LOG_FILE_PATH)) { return ; } #if ((VOS_WIN32 == VOS_OS_VER)||(VOS_VXWORKS == VOS_OS_VER)||(VOS_RTOSCK == VOS_OS_VER)) fp = DRV_FILE_OPEN(aucIMEILogFilePath, "a"); if (VOS_NULL_PTR == fp) { return ; } (VOS_VOID)DRV_FILE_LSEEK(fp, 0, SC_FILE_SEEK_END); ulFileSize = (VOS_UINT32)DRV_FILE_TELL(fp); /* If the log file is too large, we need empty it. */ if (ulFileSize > SC_LOG_FILE_MAX_SIZE) { DRV_FILE_CLOSE(fp); fp = DRV_FILE_OPEN(aucIMEILogFilePath, "w"); if (VOS_NULL_PTR == fp) { return ; } } DRV_FILE_WRITE(acOutput, ulRetLen, 1, fp); DRV_FILE_CLOSE(fp); #endif return ; }
/***************************************************************************** Function : NV_File_Create Description: Create empty file. Input : pcDir - the directory of NV file. pcFile- the name of NV file. Return : OK, or ERROR Other : *****************************************************************************/ VOS_INT32 NV_File_Create(VOS_CHAR *pcDir, VOS_CHAR *pcFile) { FILE *fp; VOS_CHAR acFilePath[MAX_PATH] = {0}; strncpy(acFilePath, pcDir, (MAX_PATH - 1)); if (VOS_NULL_PTR != pcFile) { strncat(acFilePath, pcFile, (MAX_PATH - VOS_StrLen(acFilePath) - 1)); } fp = DRV_FILE_OPEN(acFilePath, NV_FILE_OPEN_MODE_NEW_RW); if (VOS_NULL_PTR == fp) { return VOS_ERR; } if (VOS_OK != DRV_FILE_CLOSE(fp)) { return VOS_ERR; } return VOS_OK; }
/***************************************************************************** 函 数 名 : diag_PrintToFile 功能描述 : 保存二进制数据到文件系统 输入参数 : VOS_CHAR* logpath:文件路径 VOS_CHAR* pdata:要存储的数据的指针 VOS_UINT len:要存储的数据的长度 输出参数 : VOS_VOID 返 回 值 : VOS_VOID *****************************************************************************/ VOS_VOID diag_PrintToFile(VOS_CHAR* logpath, VOS_CHAR* pdata, VOS_UINT len) { #if 0 FILE * logfp = NULL; VOS_UINT32 ulRet; if((VOS_NULL == pdata)||(0 == len)) { return; } logfp = DRV_FILE_OPEN(logpath,"wb+"); if(!logfp) { return; } ulRet = DRV_FILE_WRITE(pdata, 1, len, logfp); if(ulRet!= len) { } DRV_FILE_CLOSE(logfp); #endif }
VOS_UINT32 OM_LittleImgCloseLogFile() { if (VOS_NULL_PTR != g_lFileHandle) { DRV_FILE_CLOSE(g_lFileHandle); g_lFileHandle = VOS_NULL_PTR; return VOS_OK; } return VOS_ERR; }
/***************************************************************************** 函 数 名 : USIMM_File_Close 功能描述 : 关闭文件 输入参数 : Fp --- 文件句柄 输出参数 : 无 返 回 值 : SI_UINT32 函数执行结果 调用函数 : 被调函数 : 外部接口 修改历史 : 1.日 期 : 2013年08月28日 作 者 : zhuli 修改内容 : Create *****************************************************************************/ VOS_INT32 USIMM_File_Close(FILE *Fp) { VOS_INT32 lRslt = VOS_ERR; lRslt = DRV_FILE_CLOSE(Fp); if ( VOS_OK != lRslt ) { USIMM_WARNING_LOG("Close File fail!"); } return lRslt; }
/***************************************************************************** Function : NV_File_Close Description: Close File Input : FILE *Fp -> File ptr Return : OK or ERR Other : *****************************************************************************/ VOS_INT32 NV_File_Close( FILE *Fp ) { VOS_INT32 lRslt = VOS_ERR; lRslt = DRV_FILE_CLOSE(Fp); if ( VOS_OK != lRslt ) { NV_Printf("NV:Close File fail.\r\n"); } return lRslt; }
SC_ERROR_CODE_ENUM_UINT32 SC_COMM_WriteFile( VOS_CHAR *pcFilePath, VOS_UINT8 *pucContent, VOS_UINT32 ulContentLen ) { VOS_INT32 lWriteSize; FILE *pFile; /* 创建安全文件 */ pFile = DRV_FILE_OPEN(pcFilePath, "wb+"); /* 返回空指针,返回错误值 */ if (VOS_NULL_PTR == pFile) { SC_ERROR_LOG("SC_COMM_WriteFile: DRV_FILE_OPEN is failed."); return SC_ERROR_CODE_OPEN_FILE_FAIL; } /* 写入安全文件码流,返回长度与实际长度不一致,返回错误值并关闭文件 */ lWriteSize = DRV_FILE_WRITE((VOS_CHAR*)pucContent, sizeof(VOS_CHAR), ulContentLen, pFile); if (lWriteSize != (VOS_INT32)ulContentLen) { DRV_FILE_CLOSE(pFile); SC_ERROR_LOG("SC_COMM_WriteFile: DRV_FILE_WRITE is failed."); return SC_ERROR_CODE_WRITE_FILE_FAIL; } /* 关闭文件 */ DRV_FILE_CLOSE(pFile); return SC_ERROR_CODE_NO_ERROR; }
/***************************************************************************** Prototype : OM_WriteLogProc Description : 处理ACPU发来的write Log请求 Input : pMsg - 指向消息地址 Output : None Return Value : VOS_VOID History : --- Date : 2012-05-08 Author : zhuli Modification : Created function *****************************************************************************/ VOS_VOID OM_WriteLogProc(MsgBlock* pMsg) { OM_WRITELOG_REQ_STRU *pstLogReq; VOS_UINT32 ulLen; FILE *fp; pstLogReq = (OM_WRITELOG_REQ_STRU*)pMsg; fp = DRV_FILE_OPEN((VOS_CHAR*)pstLogReq->aucFileName, "ab+"); /*按照追加方式打开文件*/ if(VOS_NULL_PTR == fp) /*如果文件打开失败说明建立文件也不成功*/ { return; } (VOS_VOID)DRV_FILE_LSEEK(fp, 0, DRV_SEEK_END); ulLen = (VOS_UINT32)DRV_FILE_TELL(fp); if(ulLen >= OM_LOG_FILE_MAX_SIZE) /*文件大小超过限制*/ { DRV_FILE_CLOSE(fp); fp = DRV_FILE_OPEN((VOS_CHAR*)pstLogReq->aucFileName, "wb+"); /*清空文件内容*/ } if(VOS_NULL_PTR == fp) /*如果文件打开失败说明建立文件也不成功*/ { return; } DRV_FILE_WRITE(pstLogReq->aucData, sizeof(VOS_CHAR), pstLogReq->ulLen, fp); DRV_FILE_CLOSE(fp); return; }
VOS_VOID OM_AcpuReadNVLog(VOS_VOID) { FILE *fp; #if(VOS_WIN32 == VOS_OS_VER) VOS_CHAR acLogPath[] = ".\\yaffs0\\A_NV_OmLog.bin"; #else #if (FEATURE_ON == FEATURE_MULTI_FS_PARTITION) VOS_CHAR acLogPath[] = "/modem_log/A_NV_OmLog.bin"; #else VOS_CHAR acLogPath[] = "/yaffs0/A_NV_OmLog.bin"; #endif #endif fp = DRV_FILE_OPEN(acLogPath, "w+"); if (VOS_NULL_PTR == fp) { return; } if ((VOS_NULL_PTR == g_pstRecordAppToOm)||(VOS_NULL_PTR == g_pstRecordOmToApp)) { vos_printf("g_pstRecordAppToOm is null\n"); DRV_FILE_CLOSE(fp); return; } DRV_FILE_WRITE((VOS_VOID*)g_pstRecordAppToOm, sizeof(VOS_CHAR), SAVE_MAX_SEND_INFO*sizeof(OM_NV_MNTN_RECORD_STRU), fp); DRV_FILE_WRITE((VOS_VOID*)g_pstRecordOmToApp, sizeof(VOS_CHAR), SAVE_MAX_SEND_INFO*sizeof(OM_NV_MNTN_RECORD_STRU), fp); DRV_FILE_CLOSE(fp); }
SC_ERROR_CODE_ENUM_UINT32 SC_COMM_ReadFile( VOS_CHAR *pcFilePath, VOS_UINT8 *pucContent, VOS_UINT32 ulContentLen ) { VOS_INT32 lReadSize; FILE *pFile; /* 打开指定类型的签名文件 */ pFile = DRV_FILE_OPEN(pcFilePath, "rb"); if (VOS_NULL_PTR == pFile) { SC_ERROR_LOG("SC_COMM_ReadFile: DRV_FILE_OPEN is failed."); return SC_ERROR_CODE_OPEN_FILE_FAIL; } /* 读取文件内容 */ lReadSize = DRV_FILE_READ((VOS_CHAR*)pucContent, sizeof(VOS_CHAR), ulContentLen, pFile); if ((VOS_INT32)ulContentLen != lReadSize) { DRV_FILE_CLOSE(pFile); SC_ERROR_LOG("SC_COMM_ReadFile: DRV_FILE_READ is failed."); return SC_ERROR_CODE_READ_FILE_FAIL; } /* 关闭文件 */ DRV_FILE_CLOSE(pFile); return SC_ERROR_CODE_NO_ERROR; }
VOS_VOID OM_AcpuLogShowToFile(VOS_BOOL bIsSendMsg) { FILE *fp; OM_AUTOCONFIG_CNF_STRU *pstSendCnf; VOS_UINT32 ulTemp = 0x5a5a5a5a; #if(VOS_WIN32 == VOS_OS_VER) VOS_CHAR g_acLogPath[] = ".\\yaffs0\\A_OmLog.bin"; #else #if (FEATURE_ON == FEATURE_MULTI_FS_PARTITION) VOS_CHAR g_acLogPath[] = "/modem_log/A_OmLog.bin"; #else VOS_CHAR g_acLogPath[] = "/yaffs0/A_OmLog.bin"; #endif #endif fp = DRV_FILE_OPEN(g_acLogPath, "w+"); if (VOS_NULL_PTR == fp) { return; } DRV_FILE_WRITE((VOS_VOID*)&g_stAcpuPcToUeSucRecord, sizeof(VOS_CHAR), sizeof(g_stAcpuPcToUeSucRecord), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)&g_stAcpuPcToUeErrRecord, sizeof(VOS_CHAR), sizeof(g_stAcpuPcToUeErrRecord), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)&g_stAcpuUeToPcSucRecord, sizeof(VOS_CHAR), sizeof(g_stAcpuUeToPcSucRecord), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)&g_stAcpuUeToPcErrRecord, sizeof(VOS_CHAR), sizeof(g_stAcpuUeToPcErrRecord), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)&g_stAcpuDebugInfo , sizeof(VOS_CHAR), sizeof(g_stAcpuDebugInfo), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)&g_stVComDebugInfo , sizeof(VOS_CHAR), sizeof(g_stVComDebugInfo), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)g_astAcpuRecordInfo , sizeof(VOS_CHAR), sizeof(g_astAcpuRecordInfo), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_WRITE((VOS_VOID*)&g_ulAcpuOMSwitchOnOff , sizeof(VOS_CHAR), sizeof(g_ulAcpuOMSwitchOnOff), fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); /* SCM 相关*/ SCM_LogToFile(fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); /* SOCP 相关*/ SOCP_LogToFile(fp); DRV_FILE_WRITE((VOS_VOID*)&ulTemp, sizeof(VOS_CHAR), sizeof(VOS_UINT32), fp); DRV_FILE_CLOSE(fp); OM_AcpuReadNVLog(); /* 发送消息給 Acpu */ if(VOS_FALSE == bIsSendMsg) { return; } pstSendCnf = (OM_AUTOCONFIG_CNF_STRU*)VOS_AllocMsg(ACPU_PID_OMAGENT, sizeof(OM_AUTOCONFIG_CNF_STRU) - VOS_MSG_HEAD_LENGTH); /* 分配消息失败 */ if (VOS_NULL_PTR == pstSendCnf) { return; } pstSendCnf->ulReceiverPid = CCPU_PID_OMAGENT; pstSendCnf->usPrimId = OM_RECORD_DBU_INFO_REQ; (VOS_VOID)VOS_SendMsg(ACPU_PID_OMAGENT, pstSendCnf); return; }
VOS_UINT32 NV_Printf(const VOS_CHAR *pcformat, ...) /*lint +e960 */ { VOS_CHAR acOutput[NV_LOG_MAX_LEN]; va_list argument; VOS_UINT32 ulRetLen; #if ((VOS_WIN32 == VOS_OS_VER)||(VOS_VXWORKS == VOS_OS_VER)||(VOS_RTOSCK == VOS_OS_VER)) FILE *fp; VOS_UINT32 ulFileSize; #endif /* 将格式化字符串和可变参数转换为字符串 */ va_start(argument, pcformat); ulRetLen = (VOS_UINT32)vsnprintf(acOutput, NV_LOG_MAX_LEN, pcformat, argument); va_end(argument); if ((NV_LOG_MAX_LEN < ulRetLen) || (0 == ulRetLen)) { return VOS_ERR; } #if (VOS_LINUX == VOS_OS_VER) printk("%s", acOutput); #elif (VOS_VXWORKS == VOS_OS_VER) logMsg("%s", acOutput); #elif (VOS_RTOSCK == VOS_OS_VER) SRE_Printf("%s", acOutput); #endif #if ((VOS_WIN32 == VOS_OS_VER)||(VOS_VXWORKS == VOS_OS_VER)||(VOS_RTOSCK == VOS_OS_VER)) fp = DRV_FILE_OPEN(g_acNvLogFilePath, "a"); if (VOS_NULL_PTR == fp) { return VOS_ERR; } DRV_FILE_LSEEK(fp, 0, NV_FILE_SEEK_END); ulFileSize = (VOS_UINT32)DRV_FILE_TELL(fp); /* If the log file is too large, we need empty it. */ if (ulFileSize > NV_LOG_FILE_MAX_SIZE) { DRV_FILE_CLOSE(fp); fp = DRV_FILE_OPEN(g_acNvLogFilePath, "w"); if (VOS_NULL_PTR == fp) { return VOS_ERR; } } DRV_FILE_WRITE(acOutput, ulRetLen, 1, fp); DRV_FILE_CLOSE(fp); #endif return VOS_OK; }
VOS_VOID CpuView_Dump(VOS_UINT32 ulDumpMode) { FILE *fp; VOS_CHAR acDumpFileName[500]; static VOS_UINT8 s_ucDumpFileNO = 0; VOS_INT iRet; VOS_INT32 lLockValue; /* cpu_View未初始化,则按照默认值进行初始化 */ if (CPU_VIEW_NO == g_ulCpuViewInitFlag) { /* 按照默认值初始化 */ CpuView_Init(CPU_VIEW_MEMORY_MODE_DYNAMIC, 0); /* 非循环模式 */ CpuView_Start(CPU_VIEW_RECORD_MODE_CYCLE_NO); /* 等待10s */ CPU_VIEW_TASK_DELAY(1000); } /* cpu_View未开始,则按照默认值开始 */ if (CPU_VIEW_NO == g_ulCpuViewStartFlag) { /* 非循环模式 */ CpuView_Start(CPU_VIEW_RECORD_MODE_CYCLE_NO); /* 等待10s */ CPU_VIEW_TASK_DELAY(1000); } if ( (VOS_NULL == g_pstCpuView) || ((0 == g_ulCpuViewCnt) && (CPU_VIEW_RECORD_OVERTURN_NO == g_ulCpuViewOC)) ) { CPU_VIEW_LOG_PRINT("CpuView_DumpTrace, No Trace need dump!\r\n"); return; } CpuView_End(); CPU_VIEW_LOG_PRINT("CpuView Dump Begin ............\r\n"); lLockValue = VOS_SplIMP(); if (CPU_VIEW_DUMP_GEN_MODE_FLASH == ulDumpMode) /* 输出到FLASH */ { #if (FEATURE_ON == FEATURE_MULTI_FS_PARTITION) /* SFT board*/ sprintf(acDumpFileName,"/data/cp-log/CpuView%d.dump", s_ucDumpFileNO); #else sprintf(acDumpFileName,"/yaffs0/CpuView%d.dump", s_ucDumpFileNO); #endif fp = DRV_FILE_OPEN(acDumpFileName, "wb"); } /* 暂不支持输出到网卡 */ #if 0 else if (CPU_VIEW_DUMP_GEN_MODE_NETCARD == ulDumpMode) /* 输出到网卡 */ { CPU_VIEW_LOG_PRINT("Dump to Host!\r\n"); fp = DRV_FILE_OPEN("host:CpuView.dump", "wb"); } #endif else { VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("Not support Dump file mode,Please check again!\r\n"); return; } if (VOS_NULL == fp) { VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("Open File Fail!\r\n"); return; } iRet = DRV_FILE_WRITE(g_pstCpuViewCtrl, sizeof(CPU_VIEW_CTRL_STRU), 1, fp); if (-1 == iRet) { DRV_FILE_CLOSE(fp); VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("Write Control Info Fail!\r\n"); return; } iRet = DRV_FILE_WRITE(g_pstCpuView, sizeof(CPU_VIEW_STRU), g_ulCpuViewTraceCnt, fp); if (-1 == iRet) { DRV_FILE_CLOSE(fp); VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("Write Cpu View Fail!\r\n"); return; } DRV_FILE_CLOSE(fp); VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("CpuView Dump End ............\r\n"); CPU_VIEW_LOG_PRINT1("Dump File Name:%s......\r\n", (VOS_INT)acDumpFileName); s_ucDumpFileNO++; return; } /* CpuView_Dump */