/***************************************************************************** Function : VOS_GetCurrentTaskID Description: Get current task's ID Input : none Output : none Return : Return task's ID if success or fail information if fail Other : none *****************************************************************************/ VOS_UINT32 VOS_GetCurrentTaskID( VOS_VOID ) { NU_TASK *task_ptr; VOS_INT i; VOS_INT intLockLevel; task_ptr = NU_Current_Task_Pointer(); if( VOS_NULL_PTR == task_ptr ) { return( VOS_NULL_LONG ); } intLockLevel = VOS_SplIMP(); for ( i=0; i<(VOS_INT)vos_TaskCtrlBlkNumber; i++ ) { if( VOS_TASK_CTRL_BLK_BUSY == vos_TaskCtrlBlk[i].Flag ) { if ( task_ptr == &(vos_TaskCtrlBlk[i].NuTid) ) { VOS_Splx(intLockLevel); return (VOS_UINT32)i; } } } VOS_Splx(intLockLevel); LogPrint("# VOS_GetCurrentTaskID fatal error.\r\n"); return( VOS_NULL_LONG ); }
/***************************************************************************** Function : VOS_TaskCtrlBlkGet Description: allocate a block Input : void : void Return : VOS_OK on success or errno on failure. Other : *****************************************************************************/ VOS_UINT32 VOS_TaskCtrlBlkGet(VOS_VOID) { VOS_UINT32 i; int intLockLevel; intLockLevel = VOS_SplIMP(); for(i=0; i<vos_TaskCtrlBlkNumber; i++) { if(vos_TaskCtrlBlk[i].Flag == VOS_TASK_CTRL_BLK_IDLE) { vos_TaskCtrlBlk[i].Flag = VOS_TASK_CTRL_BLK_BUSY; break; } } VOS_Splx(intLockLevel); if( i < vos_TaskCtrlBlkNumber) { return i; } else { Print("# allocate task control block fail.\r\n"); return(VOS_TASK_CTRL_BLK_NULL); } }
/***************************************************************************** 函 数 名 : OM_LOG_InnerRecord 功能描述 : 添加日志到内部记录 输入参数 : OM_LOG_ID_ENUM_UINT32 enLogId - log id 输出参数 : 无 返 回 值 : VOS_VOID 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2011年6月18日 作 者 : 苏庄銮 59026 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID OM_LOG_InnerRecord( OM_LOG_ID_ENUM_UINT32 enLogId, VOS_UINT16 uhwFileID, VOS_UINT16 uhwLineID) { OM_LOG_INNER_OBJ_STRU *pstInnerObj = OM_LOG_GetInnerObjPtr(); OM_LOG_INNER_RECORD_STRU *pstRecord = VOS_NULL; VOS_UINT32 uwIndx; VOS_CPU_SR srSave; /* 未初始化则直接退出 */ if (!OM_LOG_CheckInit()) { return; } /* 锁中断 */ srSave = VOS_SplIMP(); /* 写入记录 */ uwIndx = pstInnerObj->uwCurrIdx; pstRecord = OM_LOG_GetInnerRecord(uwIndx); pstRecord->enLogId = enLogId; pstRecord->uwTimeStamp = DRV_TIMER_ReadSysTimeStamp(); pstRecord->uhwFileID = uhwFileID; pstRecord->uhwLineID = uhwLineID; pstInnerObj->uwCurrIdx = (uwIndx + 1) % OM_LOG_INNER_MAX_NUM; /* 释放中断 */ VOS_Splx(srSave); }
/****************************************************************************** Prototype : CpuView_IntLevChgOutHook Description : 中断切换钩子函数 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID CpuView_IntLevChgOutHook(VOS_UINT32 ulOldLev) { VOS_INT32 lLockValue; VOS_UINT32 ulCurrentSlice; if (CPU_VIEW_NO == g_ulTaskWatch) { return; } lLockValue = VOS_SplIMP(); if (CPU_VIEW_YES == CpuView_IsOverturn()) { VOS_Splx(lLockValue); return; } /* get current time */ mdrv_timer_get_rest_time(CPU_VIEW_CLK_ID, TIMER_UNIT_NONE, (unsigned int *)&ulCurrentSlice); g_pstCpuView[g_ulCpuViewCnt].ulId = ulOldLev; g_pstCpuView[g_ulCpuViewCnt].ucType = CPU_VIEW_TYPE_INT; g_pstCpuView[g_ulCpuViewCnt].ucLev = CPU_VIEW_LEV_EXIT; g_pstCpuView[g_ulCpuViewCnt].ulSlice = ulCurrentSlice; g_pstCpuView[g_ulCpuViewCnt].ulTick = CPU_VIEW_GET_TICK(); g_pstCpuView[g_ulCpuViewCnt].ulPC = 0xFFFFFFFF; g_pstCpuView[g_ulCpuViewCnt].ulPara1 = 0; g_ulCpuViewCnt++; VOS_Splx(lLockValue); return; } /* CpuView_IntLevChgOutHook */
/***************************************************************************** Function : VOS_SemCtrlBlkFree Description: fress a block Input : Sem_Address -- address Return : VOS_OK on success or errno on failure. Other : *****************************************************************************/ VOS_UINT32 VOS_SemCtrlBlkFree( SEM_CONTROL_BLOCK *Sem_Address ) { int intLockLevel; if( Sem_Address == Sem_Address->SemId ) { if(Sem_Address->Flag == VOS_SEM_CTRL_BLK_IDLE) { return(VOS_ERR); } else { intLockLevel = VOS_SplIMP(); Sem_Address->Flag = VOS_SEM_CTRL_BLK_IDLE; VOS_Splx(intLockLevel); } return(VOS_OK); } else { /*lint -e534*/ Print("# VOS_FreeSemCtrlBlk free NULL Sem.\r\n"); /*lint +e534*/ return(VOS_ERR); } }
/****************************************************************************** Prototype : __cyg_profile_func_exit Description : 函数退出钩子函数 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID __cyg_profile_func_exit(VOS_VOID *this_fn, VOS_VOID *call_site) { VOS_INT32 lLockValue; VOS_UINT32 ulCurrentSlice; if (CPU_VIEW_NO == g_ulFuncWatch) { return; } lLockValue = VOS_SplIMP(); if (CPU_VIEW_YES == CpuView_IsOverturn()) { VOS_Splx(lLockValue); return; } /* get current time */ mdrv_timer_get_rest_time(CPU_VIEW_CLK_ID, TIMER_UNIT_NONE, (unsigned int *)&ulCurrentSlice); g_pstCpuView[g_ulCpuViewCnt].ulId = (VOS_UINT32)this_fn; g_pstCpuView[g_ulCpuViewCnt].ucType = CPU_VIEW_TYPE_FUNC; g_pstCpuView[g_ulCpuViewCnt].ucLev = CPU_VIEW_LEV_EXIT; g_pstCpuView[g_ulCpuViewCnt].ulSlice = ulCurrentSlice; g_pstCpuView[g_ulCpuViewCnt].ulTick = CPU_VIEW_GET_TICK(); g_pstCpuView[g_ulCpuViewCnt].ulPC = (VOS_UINT32)call_site; g_pstCpuView[g_ulCpuViewCnt].ulPara1 = 0; g_ulCpuViewCnt++; VOS_Splx(lLockValue); return; } /* __cyg_profile_func_exit */
/****************************************************************************** Prototype : R_ITF_SetWFlowLev Description : 业务切换为W模时,更改流控门限 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2009-02-27 Modification: Created function ******************************************************************************/ VOS_VOID R_ITF_SetWFlowLev(VOS_VOID) { R_ITF_FLOW_LEV_STRU *pFlowLev; VOS_INT32 lLockKey; /* PS融合后, W模在C核流控是在A核上控制, 因此在C核上将门限改为无穷大, 这样不再起流控 */ /* 进入流控临界区 */ lLockKey = VOS_SplIMP(); pFlowLev = &g_stRItfFlowCtrl.astFlowCtrl[R_ITF_FLOW_CTRL_TYPE_MEM_CNT]; pFlowLev->ulNormalLev = 0xffffffff;/*1000*/ pFlowLev->ulWarningLev = 0xffffffff;/*2000*/ pFlowLev->ulMaxLev = 0; /* PS融合后, W模由于使用A核内存, 因此将门限设置为无穷大, 避免内存起流控 */ pFlowLev = &g_stRItfFlowCtrl.astFlowCtrl[R_ITF_FLOW_CTRL_TYPE_MEM_SIZE]; pFlowLev->ulNormalLev = 0xffffffff;/*1200000*/ pFlowLev->ulWarningLev = 0xffffffff;/*2000000*/ pFlowLev->ulMaxLev = 0; /* 离开流控临界区 */ VOS_Splx(lLockKey); R_ITF_ResetFlowCtrl(); /* 到W模下, 内存在A核监测, 因此C核上不需要内存监测钩子 */ TTF_MemRegEventCallBack(TTF_MEM_POOL_ID_UL_DATA, VOS_NULL_PTR, VOS_NULL_PTR); return; }
/****************************************************************************** Prototype : CpuView_CloseTaskWatch Description : 关闭任务跟踪 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID CpuView_CloseTaskWatch(VOS_VOID) { VOS_INT32 lLockValue; if (CPU_VIEW_NO == g_ulTaskWatch) { return; } lLockValue = VOS_SplIMP(); g_ulTaskWatch = CPU_VIEW_NO; /* 关闭中断切换跟踪 */ mdrv_int_unregister_enterhook(); mdrv_int_unregister_exithook(); /* 关闭任务切换跟踪 */ if ( VOS_OK != CPU_VIEW_DEL_TASK_SWITCH_HOOK( (FUNCPTR)CpuView_TaskSwitchHook ) ) { VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("CpuView_CloseTaskWatch CPU_VIEW_DEL_TASK_SWITCH_HOOK fail!\r\n"); return; } VOS_Splx(lLockValue); return; } /* CpuView_CloseTaskWatch */
/****************************************************************************** Prototype : CpuView_SetPoint Description : 在代码中设置观察点的函数 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID CpuView_SetPoint(VOS_UINT32 ulId, VOS_UINT8 ucLev, VOS_UINT32 ulPara0, VOS_UINT32 ulPara1) { VOS_INT32 lLockValue; VOS_UINT32 ulCurrentSlice; if (CPU_VIEW_NO == g_ulPointWatch) { return; } lLockValue = VOS_SplIMP(); if (CPU_VIEW_YES == CpuView_IsOverturn()) { VOS_Splx(lLockValue); return; } /* get current time */ mdrv_timer_get_rest_time(CPU_VIEW_CLK_ID, TIMER_UNIT_NONE, (unsigned int *)&ulCurrentSlice); g_pstCpuView[g_ulCpuViewCnt].ulId = ulId; g_pstCpuView[g_ulCpuViewCnt].ucType = CPU_VIEW_TYPE_POINT; g_pstCpuView[g_ulCpuViewCnt].ucLev = ucLev; g_pstCpuView[g_ulCpuViewCnt].ulSlice = ulCurrentSlice; g_pstCpuView[g_ulCpuViewCnt].ulTick = CPU_VIEW_GET_TICK(); g_pstCpuView[g_ulCpuViewCnt].ulPC = ulPara0; g_pstCpuView[g_ulCpuViewCnt].ulPara1 = ulPara1; g_ulCpuViewCnt++; VOS_Splx(lLockValue); return; } /* CpuView_SetPoint */
VOS_VOID CpuView_Start(VOS_UINT32 ulMode) { VOS_INT32 lLockValue; if (CPU_VIEW_NO == g_ulCpuViewInitFlag) { /* 按照默认值初始化 */ CpuView_Init(CPU_VIEW_MEMORY_MODE_DYNAMIC, 0); } if (CPU_VIEW_YES == g_ulCpuViewStartFlag) { CPU_VIEW_LOG_PRINT("CpuView is already started!\r\n"); return; } g_ulCpuViewMode = ulMode; CpuView_OpenPointWatch(); CpuView_OpenTaskWatch(); CpuView_OpenFuncWatch(); lLockValue = VOS_SplIMP(); g_ulCpuViewCnt = 0; g_ulCpuViewOC = CPU_VIEW_RECORD_OVERTURN_NO; g_ulCpuViewStartFlag = CPU_VIEW_YES; VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("CpuView Start......\r\n"); return; } /* CpuView_Start */
VOS_VOID CpuView_CloseTaskWatch(VOS_VOID) { VOS_INT32 lLockValue; if (CPU_VIEW_NO == g_ulTaskWatch) { return; } lLockValue = VOS_SplIMP(); g_ulTaskWatch = CPU_VIEW_NO; /* 关闭中断切换跟踪 */ DRV_VICINT_LVLCHG_HOOK_DEL(); DRV_VICINT_EXIT_HOOK_DEL(); /* 关闭任务切换跟踪 */ if ( VOS_OK != CPU_VIEW_DEL_TASK_SWITCH_HOOK( (FUNCPTR)CpuView_TaskSwitchHook ) ) { VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("CpuView_CloseTaskWatch CPU_VIEW_DEL_TASK_SWITCH_HOOK fail!\r\n"); return; } VOS_Splx(lLockValue); return; } /* CpuView_CloseTaskWatch */
int CpuView_IntLevChgInHook(VOS_UINT32 ulNewLev) { VOS_INT32 lLockValue; VOS_UINT32 ulCurrentSlice; if (CPU_VIEW_NO == g_ulTaskWatch) { return VOS_ERR; } lLockValue = VOS_SplIMP(); if (CPU_VIEW_YES == CpuView_IsOverturn()) { VOS_Splx(lLockValue); return VOS_ERR; } /* get current time */ DRV_TIMER_GET_REST_TIME(CPU_VIEW_CLK_ID, TIMER_UNIT_NONE, (unsigned int *)&ulCurrentSlice); g_pstCpuView[g_ulCpuViewCnt].ulId = ulNewLev; g_pstCpuView[g_ulCpuViewCnt].ucType = CPU_VIEW_TYPE_INT; g_pstCpuView[g_ulCpuViewCnt].ucLev = CPU_VIEW_LEV_ENTRY; g_pstCpuView[g_ulCpuViewCnt].ulSlice = ulCurrentSlice; g_pstCpuView[g_ulCpuViewCnt].ulTick = CPU_VIEW_GET_TICK(); g_pstCpuView[g_ulCpuViewCnt].ulPC = 0xFFFFFFFF; g_pstCpuView[g_ulCpuViewCnt].ulPara1 = 0; g_ulCpuViewCnt++; VOS_Splx(lLockValue); return VOS_OK; } /* CpuView_IntLevChgInHook */
/***************************************************************************** Function : VOS_SemCtrlBlkFree Description: fress a block Input : Sem_Address -- address Return : VOS_OK on success or errno on failure. Other : *****************************************************************************/ VOS_UINT32 VOS_SemCtrlBlkFree( SEM_CONTROL_BLOCK *Sem_Address ) { VOS_CPU_SR CpuLockLevel; if( Sem_Address == Sem_Address->SemId ) { if(Sem_Address->Flag == CONTROL_BLOCK_IDLE) { return(VOS_ERR); } else { CpuLockLevel = VOS_SplIMP(); Sem_Address->Flag = CONTROL_BLOCK_IDLE; VOS_Splx(CpuLockLevel); } return(VOS_OK); } else { Print("# VOS_FreeSemCtrlBlk free NULL Sem.\r\n"); return(VOS_ERR); } }
/***************************************************************************** 函 数 名 : OM_CPUVIEW_AddSliceRecord 功能描述 : 新添加一条CPU负载详细记录 输入参数 : OM_CPUVIEW_TARGET_ENUM_UINT8 enTarget - 记录对象类型 VOS_UINT8 ucTargetId - 记录对象编号 OM_CPUVIEW_ACTION_ENUM_UINT8 enAction - 记录动作类型 VOS_UINT32 uwTimeStamp- 时戳 输出参数 : 无 返 回 值 : VOS_VOID 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2011年6月18日 作 者 : 苏庄銮 59026 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID OM_CPUVIEW_AddSliceRecord( OM_CPUVIEW_TARGET_ENUM_UINT8 enTarget, VOS_UINT8 ucTargetId, OM_CPUVIEW_ACTION_ENUM_UINT8 enAction, VOS_UINT32 uwTimeStamp) { VOS_UINT16 uhwIdx; OM_CPUVIEW_SLICE_RECORD_STRU *pstRec; OM_CPUVIEW_DETAILS_STRU *pstDetails; VOS_CPU_SR srSave; /* 锁中断 */ srSave = VOS_SplIMP(); /* 获取可写入位置 */ pstDetails = OM_CPUVIEW_GetDetailPtr(); uhwIdx = pstDetails->uhwCurrIdx; pstRec = &(pstDetails->astRecords[uhwIdx]); /* 写入一条新的详细记录 */ pstRec->uwTarget = (enTarget & 0x3); /* 取低2比特 */ pstRec->uwTargetId = (ucTargetId & 0x1f); /* 取低5比特 */ pstRec->uwAction = (enAction & 0x1); /* 取低1比特 */ pstRec->uwTimeStamp = (uwTimeStamp & 0xffffff); /* 取低24比特*/ pstDetails->uhwCurrIdx = ((uhwIdx + 1) % OM_CPUVIEW_DETAIL_MAX_NUM); /* 释放中断 */ VOS_Splx(srSave); }
/***************************************************************************** Function : VOS_TaskCtrlBlkFree Description: free a block Input : Tid -- task ID Return : VOS_OK on success or errno on failure. Other : *****************************************************************************/ VOS_UINT32 VOS_TaskCtrlBlkFree(VOS_UINT32 Tid) { int intLockLevel; if( Tid < vos_TaskCtrlBlkNumber ) { if(vos_TaskCtrlBlk[Tid].Flag == VOS_TASK_CTRL_BLK_IDLE) { Print("# VOS_TaskCtrlBlkFree free Idle Task.\r\n"); return VOS_ERR; } else { intLockLevel = VOS_SplIMP(); vos_TaskCtrlBlk[Tid].Flag = VOS_TASK_CTRL_BLK_IDLE; VOS_Splx(intLockLevel); return VOS_OK; } } else { Print("# VOS_TaskCtrlBlkFree Error.\r\n"); return VOS_ERR; } }
/***************************************************************************** Function : VOS_ResetFidsTask Description: Resume tasks of all FIDs Input : VOS_VOID : VOS_VOID Return : VOS_OK on success or errno on failure *****************************************************************************/ VOS_UINT32 VOS_ResetFidsTask(VOS_FID ulFid) { VOS_CPU_SR CpuLockLevel; VOS_UINT32 iThePid; VOS_UINT32 Msg_Address; MSG_CB *pMsg; if( (ulFid >= VOS_FID_BUTT) || (ulFid < VOS_FID_DOPRAEND) ) { return VOS_ERR; } CpuLockLevel = VOS_SplIMP(); if ( VOS_OK != VOS_FixedQueueClean(vos_FidCtrlBlk[ulFid].Qid, &Msg_Address) ) { VOS_Splx(CpuLockLevel); return VOS_ERR; } if ( VOS_OK != VOS_ResetTask(vos_FidCtrlBlk[ulFid].Tid) ) { VOS_Splx(CpuLockLevel); return VOS_ERR; } if ( FALSE == VOS_IsMemUsed(Msg_Address) ) { VOS_Splx(CpuLockLevel); return VOS_OK; } Msg_Address += VOS_MSG_BLK_HEAD_LEN; pMsg = (MSG_CB *)Msg_Address; iThePid = pMsg->uwReceiverPid; if(!VOS_PidCheck(iThePid)) { VOS_Splx(CpuLockLevel); return VOS_ERR; } if( VOS_ID_PID_BELONG_TO_FID == vos_FidCtrlBlk[ulFid].PidsBelong[iThePid - VOS_PID_DOPRAEND] ) { VOS_FreeMsg( iThePid, pMsg ); } VOS_Splx(CpuLockLevel); return VOS_OK; }
/***************************************************************************** 函 数 名 : OM_CPUVIEW_ReportBasicInfo 功能描述 : 上报CPU负载统计基本信息 输入参数 : VOS_VOID 输出参数 : 无 返 回 值 : VOS_VOID 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2011年6月20日 作 者 : 苏庄銮 59026 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID OM_CPUVIEW_ReportBasicInfo(VOS_VOID) { OM_CPUVIEW_BASIC_STRU *pstBasic = OM_CPUVIEW_GetBasicPtr(); CODEC_OM_CPUVIEW_BASIC_IND_STRU stBasicMsg; VOS_UINT32 uwCnt; VOS_UINT32 uwRate; VOS_CPU_SR srSave; UCOM_MemSet(&stBasicMsg, 0, sizeof(stBasicMsg)); /* CPU负载统计未使能则直接返回 */ if (OM_SWITCH_OFF == OM_CPUVIEW_GetBasicEn()) { return; } /* 接口宏定义一致性检查 */ /*lint --e(506)*/ if ( (HIFI_TASK_NUM != OM_CPUVIEW_TASK_NUM) || (HIFI_INTR_NUM != OM_CPUVIEW_INTR_NUM)) { OM_LogError(OM_CPUVIEW_ReportBasicInfo_MacroDefErr); return; } /* 填充上报消息 */ stBasicMsg.uhwMsgId = ID_CODEC_OM_CPUVIEW_BASIC_IND; /* 填充任务信息 */ for (uwCnt = 0; uwCnt < OM_CPUVIEW_TASK_NUM; uwCnt++) { uwRate = OM_CPUVIEW_GetStackUsed(OM_CPUVIEW_GetStackId(uwCnt)); uwRate = (uwRate << OM_CPUVIEW_Q8) / OM_CPUVIEW_GetStackSize(uwCnt); stBasicMsg.auwStackRate[uwCnt] = uwRate; stBasicMsg.auwTaskTime[uwCnt] = pstBasic->astTaskRec[uwCnt].uwRunTime; } /* 填充中断时长信息 */ for (uwCnt = 0; uwCnt < OM_CPUVIEW_INTR_NUM; uwCnt++) { stBasicMsg.auwIntrTime[uwCnt] = pstBasic->astIntrRec[uwCnt].uwRunTime; } /* 上报消息 */ OM_COMM_SendTranMsg(&stBasicMsg, sizeof(stBasicMsg)); /* 锁中断 */ srSave = VOS_SplIMP(); /* 清空此前的记录 */ UCOM_MemSet(pstBasic->astIntrRec, 0, sizeof(pstBasic->astIntrRec)); UCOM_MemSet(pstBasic->astTaskRec, 0, sizeof(pstBasic->astTaskRec)); /* 释放中断 */ VOS_Splx(srSave); }
/***************************************************************************** Function : atomic_dec Description: decrease atomic counter.comes from linux Input : atomic counter Return : void Other : *****************************************************************************/ void atomic_dec( hpa_atomic_t *v ) { int flags; flags = VOS_SplIMP(); (v->counter)--; VOS_Splx(flags); return; }
/****************************************************************************** Prototype : CpuView_TaskSwitchHook Description : 任务切换钩子函数 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID CpuView_TaskSwitchHook(CPUVIEW_TCB *pOldTcb, CPUVIEW_TCB *pNewTcb) { VOS_INT32 lLockValue; VOS_UINT32 ulCurrentSlice; if (CPU_VIEW_NO == g_ulTaskWatch) { return; } lLockValue = VOS_SplIMP(); if (CPU_VIEW_YES == CpuView_IsOverturn()) { VOS_Splx(lLockValue); return; } /* get current time */ mdrv_timer_get_rest_time(CPU_VIEW_CLK_ID, TIMER_UNIT_NONE, (unsigned int *)&ulCurrentSlice); g_pstCpuView[g_ulCpuViewCnt].ulId = (VOS_UINT32)pOldTcb; g_pstCpuView[g_ulCpuViewCnt].ucType = CPU_VIEW_TYPE_TASK; g_pstCpuView[g_ulCpuViewCnt].ucLev = CPU_VIEW_LEV_EXIT; g_pstCpuView[g_ulCpuViewCnt].ulSlice = ulCurrentSlice; g_pstCpuView[g_ulCpuViewCnt].ulTick = CPU_VIEW_GET_TICK(); g_pstCpuView[g_ulCpuViewCnt].ulPC = (VOS_UINT32)CPU_VIEW_GET_TASK_PC(pOldTcb); g_pstCpuView[g_ulCpuViewCnt].ulPara1 = 0; g_ulCpuViewCnt++; if (CPU_VIEW_YES == CpuView_IsOverturn()) { VOS_Splx(lLockValue); return; } g_pstCpuView[g_ulCpuViewCnt].ulId = (VOS_UINT32)pNewTcb; g_pstCpuView[g_ulCpuViewCnt].ucType = CPU_VIEW_TYPE_TASK; g_pstCpuView[g_ulCpuViewCnt].ucLev = CPU_VIEW_LEV_ENTRY; g_pstCpuView[g_ulCpuViewCnt].ulSlice = ulCurrentSlice; g_pstCpuView[g_ulCpuViewCnt].ulTick = CPU_VIEW_GET_TICK(); g_pstCpuView[g_ulCpuViewCnt].ulPC = (VOS_UINT32)CPU_VIEW_GET_TASK_PC(pNewTcb); g_pstCpuView[g_ulCpuViewCnt].ulPara1 = 0; g_ulCpuViewCnt++; VOS_Splx(lLockValue); return; } /* CpuView_TaskSwitchHook */
/***************************************************************************** Function : atomic_inc_return() Description: add atomic Var then return Input : atomic Var Return : current value *****************************************************************************/ VOS_UINT32 atomic_inc_return(atomic_t *pstV) { VOS_INT32 lFlags; VOS_UINT32 ulCounter; lFlags = VOS_SplIMP(); (pstV->ulCounter)++; ulCounter = pstV->ulCounter; VOS_Splx(lFlags); return ulCounter; }
VOS_VOID CDS_UlProcImsData(MODEM_ID_ENUM_UINT16 enModemId) { VOS_UINT32 ulCnt; TTF_MEM_ST *pstIpPkt; VOS_INT32 lLock; CDS_ENTITY_STRU *pstCdsEntity; VOS_UINT16 usResult; pstCdsEntity = CDS_GetCdsEntity(enModemId); if (VOS_NULL_PTR == pstCdsEntity) { return; } for (ulCnt = 0; ulCnt < CDS_IMS_QUE_SIZE; ulCnt ++) { lLock = VOS_SplIMP(); if (PS_SUCC != LUP_DeQue(pstCdsEntity->pstIMSDataQue, (VOS_VOID**)(&pstIpPkt))) { VOS_Splx(lLock); break; } VOS_Splx(lLock); /*上行软过滤*/ usResult = 0; if (PS_SUCC != CDS_IpSoftFilter(pstIpPkt, &usResult,pstCdsEntity)) { TTF_MemFree(UEPS_PID_CDS, pstIpPkt); CDS_DBG_IMS_UL_SOFT_FILTER_FAIL_NUM(1); continue; } /*将过滤结果存到TTF中*/ CDS_UL_SAVE_IPFRSLT_TO_TTF(pstIpPkt,usResult); /*鈎包*/ CDS_SendIpPacket2PC(pstIpPkt); /*发送到空口*/ CDS_UlDispatchDataByRanMode(pstCdsEntity,pstIpPkt); CDS_DBG_IMS_UL_SEND_PKT_TO_RAN_NUM(1); } return; }
VOS_UINT32 VOS_EventWrite( VOS_UINT32 ulTaskID, VOS_UINT32 ulEvents ) { /* the functin should be full later */ int intLockLevel; VOS_UINT32 ulTempQueue; VOS_SEM ulTempSem; if ( VOS_OK != VOS_CheckEvent(ulTaskID) ) { /*lint -e534*/ LogPrint("# VOS_EventWrite EVENT not exist.\r\n"); /*lint +e534*/ return VOS_ERR; } intLockLevel = VOS_SplIMP(); vos_TaskCtrlBlk[ulTaskID].ulEvents |= ulEvents; VOS_Splx( intLockLevel ); ulTempQueue = VOS_GetQueueIDFromFid(vos_TaskCtrlBlk[ulTaskID].ulFid); if ( 0xffffffff == ulTempQueue ) { return VOS_ERR; } ulTempSem = VOS_GetSemIDFromQueue(ulTempQueue); if ( 0xffffffff == ulTempSem ) { return VOS_ERR; } if ( VOS_OK != VOS_SmV( ulTempSem ) ) { /*lint -e534*/ LogPrint("# VOS_EventWrite error.\r\n"); /*lint +e534*/ return VOS_ERR; } else { return VOS_OK; } }
/****************************************************************************** Prototype : R_ITF_IPSCH_FlowCtrlCntIsOverFlow Description : 判断流控统计计数是否超过拥塞避免门限,超过则重置流控统计计数 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2011-09-26 Modification: Created function ******************************************************************************/ VOS_UINT32 R_ITF_FlowCtrlCntIsOverFlow(VOS_VOID) { VOS_INT32 lLockKey; if (RITF_FLOWCTRL_WRED_THRESHOLD < g_ulRItfFlowCtrlCnt) { /* 进入流控临界区 */ lLockKey = VOS_SplIMP(); g_ulRItfFlowCtrlCnt = 0; VOS_Splx(lLockKey); return VOS_YES; } return VOS_NO; }
/***************************************************************************** Function Name : NAS_ERABM_SetEmmSrState Description : 设置Service流程发起标识 Input : None Output : None Return : VOS_VOID History : 1.sunbing49683 2010-9-16 Draft Enact *****************************************************************************/ VOS_VOID NAS_ERABM_SetEmmSrState( NAS_ERABM_SERVICE_STATE_ENUM_UINT32 enSrState ) { VOS_INT32 intLockLevel; if(enSrState >= NAS_ERABM_SERVICE_STATE_BUTT ) { NAS_ERABM_WARN_LOG("NAS_ERABM_SetEmmSrState: Para is err."); return; } intLockLevel = VOS_SplIMP(); g_enERabmSrState = enSrState; VOS_Splx(intLockLevel); }
/****************************************************************************** Prototype : R_ITF_SetLFlowLev Description : 业务切换为LTE模时,更改流控门限 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2011-04-01 Modification: Created function ******************************************************************************/ VOS_VOID R_ITF_SetLFlowLev(VOS_VOID) { R_ITF_FLOW_LEV_STRU *pFlowLev; VOS_INT32 lLockKey; /* PS融合后, L模在C核流控是在A核上控制, 因此在C核上将门限改为无穷大, 这样不再起流控 */ /* 进入流控临界区 */ lLockKey = VOS_SplIMP(); pFlowLev = &g_stRItfFlowCtrl.astFlowCtrl[R_ITF_FLOW_CTRL_TYPE_MEM_CNT]; pFlowLev->ulNormalLev = 600; pFlowLev->ulWarningLev = 1200; pFlowLev->ulMaxLev = 0; if ( VOS_FALSE == g_ulLteFlowCtrl ) { pFlowLev->ulWarningLev = 0xffffffff; pFlowLev->ulNormalLev = 0xffffffff; } pFlowLev = &g_stRItfFlowCtrl.astFlowCtrl[R_ITF_FLOW_CTRL_TYPE_MEM_SIZE]; pFlowLev->ulNormalLev = 900000; pFlowLev->ulWarningLev = 1800000; pFlowLev->ulMaxLev = 0; if ( VOS_FALSE == g_ulLteFlowCtrl ) { pFlowLev->ulWarningLev = 0xffffffff; pFlowLev->ulNormalLev = 0xffffffff; } /* 离开流控临界区 */ VOS_Splx(lLockKey); R_ITF_ResetFlowCtrl(); /* 到L模下, 内存在A核监测, 因此C核上不需要内存监测钩子 */ TTF_MemRegEventCallBack(TTF_MEM_POOL_ID_UL_DATA, VOS_NULL_PTR, VOS_NULL_PTR); return; }
/***************************************************************************** Function : VOS_SemCtrlBlkGet Description: allocate a control block Input : void Return : address Other : *****************************************************************************/ SEM_CONTROL_BLOCK *VOS_SemCtrlBlkGet(VOS_VOID) { VOS_UINT32 i; int intLockLevel; intLockLevel = VOS_SplIMP(); for(i=0; i<vos_SemCtrlBlkNumber; i++) { if(vos_SemCtrlBlk[i].Flag == VOS_SEM_CTRL_BLK_IDLE) { vos_SemCtrlBlk[i].Flag = VOS_SEM_CTRL_BLK_BUSY; break; } } VOS_Splx(intLockLevel); if( i < vos_SemCtrlBlkNumber) { /* record the max usage of SEM */ if ( i > vos_SemMaxSemId ) { vos_SemMaxSemId = i; } return vos_SemCtrlBlk+i; } else { /*lint -e534*/ LogPrint("# VOS_GetSemCtrlBlk no Idle.\r\n"); VOS_SetErrorNo(VOS_ERRNO_SEMA4_FULL); /*lint +e534*/ return(VOS_MAX_SEM_ID_NULL); } }
/****************************************************************************** Prototype : CpuView_Restart Description : 重启监测 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID CpuView_Restart(VOS_VOID) { VOS_INT32 lLockValue; if (CPU_VIEW_NO == g_ulCpuViewStartFlag) { CPU_VIEW_LOG_PRINT("CpuView is not started,please start first!\r\n"); return; } lLockValue = VOS_SplIMP(); g_ulPointWatch = CPU_VIEW_YES; g_ulTaskWatch = CPU_VIEW_YES; g_ulFuncWatch = CPU_VIEW_YES; g_ulCpuViewOC = CPU_VIEW_RECORD_OVERTURN_NO; g_ulCpuViewCnt = 0; VOS_Splx(lLockValue); return; } /* CpuView_Restart */
/***************************************************************************** Function : VOS_SemCtrlBlkGet Description: allocate a control block Input : VOS_VOID Return : address Other : *****************************************************************************/ SEM_CONTROL_BLOCK *VOS_SemCtrlBlkGet(VOS_VOID) { VOS_UINT32 i; VOS_CPU_SR CpuLockLevel; CpuLockLevel = VOS_SplIMP(); for(i=0; i<vos_SemCtrlBlkNumber; i++) { if(vos_SemCtrlBlk[i].Flag == CONTROL_BLOCK_IDLE) { vos_SemCtrlBlk[i].Flag = CONTROL_BLOCK_BUSY; break; } } VOS_Splx(CpuLockLevel); if( i < vos_SemCtrlBlkNumber) { /* record the max usage of SEM */ if ( i > vos_SemMaxSemId ) { vos_SemMaxSemId = i; } return vos_SemCtrlBlk+i; } else { LogPrint("# VOS_GetSemCtrlBlk no Idle.\r\n"); VOS_SetErrorNo(VOS_ERRNO_SEMA4_FULL); return(VOS_NULL_PTR); } }
/****************************************************************************** Prototype : CpuView_OpenTaskWatch Description : 开启任务跟踪 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2007-1-24 Author : g45205 Modification: Created function ******************************************************************************/ VOS_VOID CpuView_OpenTaskWatch(VOS_VOID) { VOS_INT32 lLockValue; if (CPU_VIEW_NO == g_ulCpuViewInitFlag) { CPU_VIEW_LOG_PRINT("CpuView_OpenTaskWatch, CpuView is not initialized!\r\n"); return; } if (CPU_VIEW_YES == g_ulTaskWatch) { CPU_VIEW_LOG_PRINT("WatchTask is already opened!\r\n"); return; } CpuView_GetTaskName(); lLockValue = VOS_SplIMP(); if ( VOS_OK != CPU_VIEW_ADD_TASK_SWITCH_HOOK( (FUNCPTR)CpuView_TaskSwitchHook ) ) { VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("CpuView_OpenTaskWatch CPU_VIEW_ADD_TASK_SWITCH_HOOK fail!\r\n"); return; } mdrv_int_register_enterhook((FUNCPTR_1)CpuView_IntLevChgInHook); mdrv_int_register_exithook((FUNCPTR_1)CpuView_IntLevChgOutHook); g_ulTaskWatch = CPU_VIEW_YES; VOS_Splx(lLockValue); CPU_VIEW_LOG_PRINT("WatchTask open successfully!\r\n"); return; } /* CpuView_OpenTaskWatch */
/****************************************************************************** Prototype : R_ITF_SetGFlowLev Description : 业务切换为G模时,更改流控门限 Input : Output : Return Value : Calls : Called By : History : --- 1.Date : 2009-02-27 Modification: Created function ******************************************************************************/ VOS_VOID R_ITF_SetGFlowLev(VOS_VOID) { R_ITF_FLOW_LEV_STRU *pFlowLev; VOS_INT32 lLockKey; /* 进入流控临界区 */ lLockKey = VOS_SplIMP(); pFlowLev = &g_stRItfFlowCtrl.astFlowCtrl[R_ITF_FLOW_CTRL_TYPE_MEM_CNT]; pFlowLev->ulNormalLev = 600; pFlowLev->ulWarningLev = 600; pFlowLev->ulMaxLev = 0; pFlowLev = &g_stRItfFlowCtrl.astFlowCtrl[R_ITF_FLOW_CTRL_TYPE_MEM_SIZE]; pFlowLev->ulNormalLev = 30000; pFlowLev->ulWarningLev = 30000; pFlowLev->ulMaxLev = 0; /* 离开流控临界区 */ VOS_Splx(lLockKey); R_ITF_ResetFlowCtrl(); /* V9R1中使用流控NV项中GPRS流控使能位来判断是否注册钩子函数 */ if ( (FC_POLICY_MASK(FC_POLICY_ID_GPRS) == FC_POLICY_GetEnableMask(FC_POLICY_ID_GPRS) )) { /* 到G模下, A核内存需要拷贝到C核TTF_MEM中, 因此C核上需要内存监测钩子 */ TTF_MemRegEventCallBack(TTF_MEM_POOL_ID_UL_DATA, R_ITF_TtfMemAllocEvent, R_ITF_TtfMemFreeEvent); } else { /* V9R1中使用宏来判断,如果是V9R1,则不注册钩子函数 */ TTF_MemRegEventCallBack(TTF_MEM_POOL_ID_UL_DATA, VOS_NULL_PTR, VOS_NULL_PTR); } return; }