/***************************************************************************** 函 数 名 : Log_Init 功能描述 : 打印初始化 输入参数 : VOS_VOID 输出参数 : 无 返 回 值 : VOS_VOID 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2007年4月24日 作 者 : 李霄 46160 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID Log_Init(VOS_VOID) { OM_PORT_CFG_STRU stPortCfg; g_stLogEnt.ulPrintSwitch = LOG_FALSE; if (VOS_OK != VOS_SmMCreate("LOG_MSem", VOS_SEMA4_PRIOR | VOS_SEMA4_INVERSION_SAFE, &g_logBuffSem)) { vos_printf("Log: Error, semMCreate Fail"); return ; } if (VOS_OK != VOS_SmCCreate("LOG_CSem", 0, VOS_SEMA4_FIFO, &(g_stLogEnt.semOmPrint))) { VOS_SmDelete(g_logBuffSem); vos_printf("Log: Error, semCCreate Fail"); return ; } g_stLogEnt.rngOmRbufId = OM_RingBufferCreate(LOG_BUF_VOLUMN); if (LOG_NULL_PTR == g_stLogEnt.rngOmRbufId) { VOS_SmDelete(g_logBuffSem); VOS_SmDelete(g_stLogEnt.semOmPrint); vos_printf("Log: Error, rngCreate Fail"); return; } /* 从NV项中读出LOG的输出方式和文件支持的最大大小 */ if(NV_OK != NV_Read(en_NV_Item_Om_PsLog_Port, &stPortCfg, sizeof(OM_PORT_CFG_STRU))) { vos_printf("Log_InitFile: NV_Read fail, NV Id :%d\n", en_NV_Item_Om_PsLog_Port); stPortCfg.ulMaxFileSize = 0; } else { /*参数检测*/ if (OM_OUTPUT_BUTT > stPortCfg.enPortType) { g_stLogEnt.ulLogOutput = stPortCfg.enPortType; } } g_stLogEnt.ulPrintSwitch = LOG_TRUE; return; }
VOS_UINT32 OM_StopLogSaveReq(APP_OM_MSG_EX_STRU *pstAppToOmMsg, VOS_UINT16 usReturnPrimId) { VOS_UINT32 ulResult = VOS_ERR; /* 获取校准结果 */ ulResult = *(VOS_UINT32*)(pstAppToOmMsg->aucPara); if ( LOG_FILE_DISABLE == g_ulLogFileSaveFlg ) { OM_SendResult(pstAppToOmMsg->ucFuncType, ulResult, usReturnPrimId); return VOS_OK; } /* 对临界资源g_stLogFileInfo进行保护 */ if (VOS_OK != VOS_SmP(g_stLogFileSaveInfo.ulSem, LOG_SEM_TIMEOUT_VALUE)) { g_ulLittleImgLogErr = LOG_OPERATION_POST_SEM_FAIL; OM_SendResult(pstAppToOmMsg->ucFuncType, ulResult, usReturnPrimId); return VOS_ERR; } /* 更新使能标记 */ g_ulLogFileSaveFlg = LOG_FILE_DISABLE; if (VOS_OK == ulResult) { /*清除LOG文件*/ OM_LittleImgClearAllLogFile(); } else { OM_LittleImgCloseLogFile(); } VOS_SmV(g_stLogFileSaveInfo.ulSem); /* 将结果保存到NV项中 */ ulResult = NV_WritePart(en_NV_Item_LOG_FILE_SAVE, 0, (VOS_UINT32*)(pstAppToOmMsg->aucPara), sizeof(VOS_UINT32)); OM_SendResult(pstAppToOmMsg->ucFuncType, ulResult, usReturnPrimId); /* 释放信号量资源 */ if (VOS_OK != VOS_SmDelete(g_stLogFileSaveInfo.ulSem)) { g_ulLittleImgLogErr = LOG_OPERATION_DELETE_SEM_FAIL; return VOS_ERR; } return VOS_OK; }
VOS_UINT32 CSD_InitSem(VOS_VOID) { VOS_UINT32 ulRslt; VOS_UINT32 *pULDataSem; VOS_UINT32 *pDLDataSem; pDLDataSem = CSD_GetDownLinkDataSem(); pULDataSem = CSD_GetUpLinkDataSem(); /* 初始下行信号量 */ ulRslt = VOS_SmBCreate("ulDldataSem", CSD_SEMAPHORE_INIT_CNT, VOS_SEMA4_FIFO, pDLDataSem); if (VOS_OK != ulRslt) { VOS_SmDelete(*pDLDataSem); CSD_ERROR_LOG(ACPU_PID_CSD, "CSD_InitSem:: VOS_SmBCreate pDLDataSem fail"); return VOS_ERR; } /* 初始上行信号量 */ ulRslt = VOS_SmBCreate("ulUldataSem", CSD_SEMAPHORE_INIT_CNT, VOS_SEMA4_FIFO, pULDataSem); if (VOS_OK != ulRslt) { VOS_SmDelete(*pULDataSem); CSD_ERROR_LOG(ACPU_PID_CSD, "CSD_InitSem:: VOS_SmBCreate pULDataSem fail"); return VOS_ERR; } return VOS_OK; }
BST_ERR_ENUM_UINT8 BST_OS_PalDeleteSem( BST_OS_PAL_SEM_T stSemHandle ) { if( BST_PAL_IsSemInValid( stSemHandle ) ) { return BST_ERR_ILLEGAL_PARAM; } #if (VOS_RTOSCK == VOS_OS_VER) VOS_SmDelete( stSemHandle ); #else semDelete( stSemHandle ); #endif return BST_NO_ERROR_MSG; }
VOS_UINT32 OM_PrintfInit(VOS_VOID) { OM_PORT_CFG_STRU stPortCfg; NAS_NVIM_SYSTEM_APP_CONFIG_STRU stAPPConfig; stAPPConfig.usSysAppConfigType = SYSTEM_APP_BUTT; if(NV_OK != NV_Read(en_NV_Item_System_APP_Config, &stAPPConfig, sizeof(NAS_NVIM_SYSTEM_APP_CONFIG_STRU))) { PS_LOG(WUEPS_PID_OM, 0, PS_PRINT_ERROR, "OM_AcpuSelfTaskReg:Read NV en_NV_Item_System_APP_Config fail!"); } if(SYSTEM_APP_WEBUI != stAPPConfig.usSysAppConfigType) { return VOS_OK; } VOS_MemSet(&g_stOmPrintfErrRecord, 0, sizeof(OM_PRINTF_ERROR_RECORD_STRU)); VOS_MemSet(g_astOmPrintfOutPutLev, LOG_LEVEL_OFF, OM_PRINTF_MODULE_MAX_NUM*sizeof(LOG_LEVEL_EN)); /* 读NV项获取输出端口配置和文件大小,若失败则默认输出端口为SHELL口, 文件大小为0表示取默认文件大小 */ if(NV_OK != NV_Read(en_NV_Item_Om_Printf_Port, &stPortCfg, sizeof(OM_PORT_CFG_STRU))) { stPortCfg.ulMaxFileSize = 0; } else { /* 判断端口范围 */ if (OM_OUTPUT_BUTT > stPortCfg.enPortType) { g_ulOmPrintfPort = (VOS_UINT32)stPortCfg.enPortType; } } /* 创建Printf BUFFER 保护信号量 */ if(VOS_OK != VOS_SmMCreate("Pt", VOS_SEMA4_PRIOR | VOS_SEMA4_INVERSION_SAFE, &g_ulOmPrintfBuffSem)) { return VOS_ERR; } /*创建存储OM_Printf数据的环形缓冲区*/ g_pstOmPrintfBufId = OM_RingBufferCreate(OM_PRINTF_BUFFER_SIZE); if (VOS_NULL_PTR == g_pstOmPrintfBufId) { VOS_SmDelete(g_ulOmPrintfBuffSem); return VOS_ERR; } #if (VOS_OS_VER == VOS_LINUX) if (VOS_OK != OmPrintf_VFInit()) { VOS_SmDelete(g_ulOmPrintfBuffSem); return VOS_ERR; } #endif DRV_MSP_PROC_REG(OM_PRINTF_WITH_MODULE, (BSP_MspProc)OM_PrintfWithModule); DRV_MSP_PROC_REG(OM_PRINTF, (BSP_MspProc)OM_Printf); DRV_MSP_PROC_REG(OM_PRINTF_GET_MODULE_IDLEV,(BSP_MspProc)OM_PrintfGetModuleIdLev); /* 模块初始化完后将全局变量置TRUE*/ g_bIsPrintfInit = VOS_TRUE; return VOS_OK; }
/***************************************************************************** 函 数 名 : Log_Init 功能描述 : 打印初始化 输入参数 : void 输出参数 : 无 返 回 值 : void 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2007年4月24日 作 者 : 李霄 46160 修改内容 : 新生成函数 *****************************************************************************/ void Log_Init(void) { OM_PORT_CFG_STRU stPortCfg; g_stLogEnt.ulPrintSwitch = LOG_FALSE; if (VOS_OK != VOS_SmMCreate("LOG_MSem", VOS_SEMA4_PRIOR | VOS_SEMA4_INVERSION_SAFE, &g_logBuffSem)) { vos_printf("Log: Error, semMCreate Fail"); return ; } if (VOS_OK != VOS_SmCCreate("LOG_CSem", 0, VOS_SEMA4_FIFO, &(g_stLogEnt.semOmPrint))) { VOS_SmDelete(g_logBuffSem); vos_printf("Log: Error, semCCreate Fail"); return ; } g_stLogEnt.rngOmRbufId = OM_RingBufferCreate(LOG_BUF_VOLUMN); if (LOG_NULL_PTR == g_stLogEnt.rngOmRbufId) { VOS_SmDelete(g_logBuffSem); VOS_SmDelete(g_stLogEnt.semOmPrint); vos_printf("Log: Error, rngCreate Fail"); return; } /* 从NV项中读出LOG的输出方式和文件支持的最大大小 */ if(NV_OK != NV_Read(en_NV_Item_Om_PsLog_Port, &stPortCfg, sizeof(OM_PORT_CFG_STRU))) { vos_printf("Log_InitFile: NV_Read fail, NV Id :%d\n", en_NV_Item_Om_PsLog_Port); stPortCfg.ulMaxFileSize = 0; } else { /*参数检测*/ if (OM_OUTPUT_BUTT > stPortCfg.enPortType) { g_stLogEnt.ulLogOutput = (LOG_ULONG)stPortCfg.enPortType; } } g_stLogEnt.ulPrintSwitch = LOG_TRUE; /* 注册底软的回调函数,定义OM_Log...... */ #ifdef __LOG_BBIT__ LOG_RegisterDrv((LOG_PFUN)OM_Log, (LOG_PFUN)OM_Log1, (LOG_PFUN)OM_Log2, (LOG_PFUN)OM_Log3, (LOG_PFUN)OM_Log4); #endif #ifdef __LOG_RELEASE__ LOG_RegisterDrv((LOG_PFUN)OM_LogId, (LOG_PFUN)OM_LogId1, (LOG_PFUN)OM_LogId2, (LOG_PFUN)OM_LogId3, (LOG_PFUN)OM_LogId4); #endif return; }