Ejemplo n.º 1
0
/*****************************************************************************
 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;
}
Ejemplo n.º 2
0
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 != 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;
}
Ejemplo n.º 3
0
VOS_UINT32 OM_LittleImgWriteLogFile(VOS_CHAR *pcLogData, VOS_UINT32 ulLength)
{
    VOS_UINT32 ulResult;

    /* 过滤消息 */
    ulResult = OM_LittleImgFilterMsg((VOS_UINT8*)pcLogData);

    /* 判断是否使能 */
    if (LOG_FILE_DISABLE == g_ulLogFileSaveFlg)
    {
        /*LogPrint("\r\n OM_LittleImgWriteLogFile: LOG_FILE_SAVE is Disable. \r\n"); */
        return ulResult;
    }

        /* 对临界资源g_astLogFileInfo进行保护 */
    if (VOS_OK != VOS_SmP(g_stLogFileSaveInfo.ulSem, LOG_SEM_TIMEOUT_VALUE))
    {
        g_ulLittleImgLogErr = LOG_OPERATION_POST_SEM_FAIL;
        return ulResult;
    }

    if (VOS_NULL_PTR == g_lFileHandle)
    {
        /*LogPrint("\r\n OM_LittleImgWriteLogFile: The file handle is null. \r\n"); */
        VOS_SmV(g_stLogFileSaveInfo.ulSem);
        return ulResult;
    }

    if (VOS_NULL_PTR == pcLogData)
    {
        VOS_SmV(g_stLogFileSaveInfo.ulSem);
        return ulResult;
    }

    /* 写入长度大于LOG文件的最大值 */
    if (ulLength > (g_stLogFileSaveInfo.ulCurLogFileMaxSize*FILE_SIZE_THRESHOLD_PERCENT))
    {
        LogPrint("\r\n OM_LittleImgWriteLogFile: The file size is too large. \r\n");
        VOS_SmV(g_stLogFileSaveInfo.ulSem);
        return ulResult;
    }

    /* LOG文件写满后 */
    if ((ulLength + g_stLogFileSaveInfo.ulCurLogFileSize) >
                (g_stLogFileSaveInfo.ulCurLogFileMaxSize * FILE_SIZE_THRESHOLD_PERCENT))
    {
        /* 关闭当前LOG文件句柄 */
        OM_LittleImgCloseLogFile();

        /* 如果创建文件失败,停止LOG文件保存功能 */
        if (VOS_OK != OM_LittleImgCreateLogFile(g_stLogFileSaveInfo.ulCurLogFileMaxSize))
        {
            g_ulLogFileSaveFlg = LOG_FILE_DISABLE;

            g_ulLittleImgLogErr = LOG_OPERATION_OPEN_FILE_FAIL;

            VOS_SmV(g_stLogFileSaveInfo.ulSem);

            return ulResult;
        }
    }

    /* 写LOG文件失败 */
    if ( DRV_ERROR == DRV_FILE_WRITE(pcLogData, sizeof(VOS_CHAR), (DRV_SIZE_T)ulLength, g_lFileHandle))
    {
        /* 关闭当前LOG文件 */
        OM_LittleImgCloseLogFile();

        g_ulLogFileSaveFlg = LOG_FILE_DISABLE;

        g_ulLittleImgLogErr = LOG_OPERATION_WRITE_FILE_FAIL;

        VOS_SmV(g_stLogFileSaveInfo.ulSem);

        return ulResult;
    }

    /* 更新当前LOG文件的大小 */
    g_stLogFileSaveInfo.ulCurLogFileSize += ulLength;

    VOS_SmV(g_stLogFileSaveInfo.ulSem);

    return ulResult;

}
Ejemplo n.º 4
0
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 */