VOS_UINT32 TAF_MMA_GetNextCachedMsg( TAF_MMA_ENTRY_MSG_STRU *pstEntryMsg ) { TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); if (0 == pstMsgQueue->ucCacheMsgNum ) { TAF_INFO_LOG(WUEPS_PID_MMA, "TAF_MMA_GetNextCachedMsg:Empty buffer"); return VOS_FALSE; } if (VOS_TRUE == TAF_MMA_GetNextPrioCachedMsg(pstEntryMsg, TAF_MMA_MSG_CACHE_PRIO_HIGH)) { return VOS_TRUE; } if (VOS_TRUE == TAF_MMA_GetNextPrioCachedMsg(pstEntryMsg, TAF_MMA_MSG_CACHE_PRIO_MIDDLE)) { return VOS_TRUE; } if (VOS_TRUE == TAF_MMA_GetNextPrioCachedMsg(pstEntryMsg, TAF_MMA_MSG_CACHE_PRIO_LOW)) { return VOS_TRUE; } return VOS_FALSE; }
VOS_VOID TAF_MMA_LogBufferQueueMsg( VOS_UINT32 ulFullFlg ) { TAF_MMA_LOG_BUffER_MSG_INFO_STRU *pstBufferMsg = VOS_NULL_PTR; TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; pstBufferMsg = (TAF_MMA_LOG_BUffER_MSG_INFO_STRU*)PS_MEM_ALLOC(WUEPS_PID_MMA, sizeof(TAF_MMA_LOG_BUffER_MSG_INFO_STRU)); if ( VOS_NULL_PTR == pstBufferMsg ) { TAF_ERROR_LOG(WUEPS_PID_MMA, "TAF_MMA_LogBufferQueueMsg:ERROR:Alloc Mem Fail."); return; } pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); pstBufferMsg->stMsgHeader.ulReceiverCpuId = VOS_LOCAL_CPUID; pstBufferMsg->stMsgHeader.ulSenderPid = WUEPS_PID_MMA; pstBufferMsg->stMsgHeader.ulReceiverPid = WUEPS_PID_MMA; pstBufferMsg->stMsgHeader.ulLength = sizeof(TAF_MMA_LOG_BUffER_MSG_INFO_STRU) - VOS_MSG_HEAD_LENGTH; pstBufferMsg->stMsgHeader.ulMsgName = TAF_MMA_LOG_BUFFER_MSG_INFO_IND; pstBufferMsg->ulFullFlg = ulFullFlg; PS_MEM_CPY(&(pstBufferMsg->stMsgQueue), pstMsgQueue, sizeof(pstBufferMsg->stMsgQueue)); OM_TraceMsgHook(pstBufferMsg); PS_MEM_FREE(WUEPS_PID_MMA, pstBufferMsg); return; }
VOS_UINT32 TAF_MMA_GetNextPrioCachedMsg( TAF_MMA_ENTRY_MSG_STRU *pstEntryMsg, TAF_MMA_MSG_CACHE_PRIO_ENUM_UINT8 enPrio ) { TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; VOS_UINT32 i; pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); for (i = 0; i < pstMsgQueue->ucCacheMsgNum; i++) { if (enPrio == TAF_MMA_GetCachedMsgPrio(&pstMsgQueue->astMsgQueue[i].stMsgEntry)) { PS_MEM_CPY(pstEntryMsg, &(pstMsgQueue->astMsgQueue[i].stMsgEntry), sizeof(TAF_MMA_ENTRY_MSG_STRU)); /* 消息已经取出则清除当前缓存 */ TAF_MMA_ClearCacheMsg(pstEntryMsg->ulEventType); return VOS_TRUE; } } return VOS_FALSE; }
VOS_UINT32 TAF_MMA_GetCacheNum( VOS_VOID ) { TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); return pstMsgQueue->ucCacheMsgNum; }
VOS_UINT32 TAF_MMA_ClearCacheMsg( VOS_UINT32 ulEventType ) { TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; VOS_INT8 i; VOS_INT8 cCachePos; pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); cCachePos = -1; /* 先找到需要被清除的缓存 */ for ( i = 0 ; i < pstMsgQueue->ucCacheMsgNum ; i++ ) { if ( ulEventType == pstMsgQueue->astMsgQueue[i].stMsgEntry.ulEventType ) { PS_MEM_SET(&(pstMsgQueue->astMsgQueue[i].stMsgEntry), 0x00, sizeof(TAF_MMA_ENTRY_MSG_STRU)); cCachePos = (VOS_INT8)i; } } /* 未找到该消息类型直接返回 */ if ( -1 == cCachePos ) { TAF_INFO_LOG1(WUEPS_PID_MMA, "TAF_MMA_ClearCacheMsg:invalid msg type", ulEventType); return VOS_FALSE; } /* 为保证先入先出,需要将后面的消息移到前面 */ for ( i = cCachePos ; i < (pstMsgQueue->ucCacheMsgNum - 1) ; i++ ) { /* COPY消息内容 */ PS_MEM_CPY(&(pstMsgQueue->astMsgQueue[i].stMsgEntry), &(pstMsgQueue->astMsgQueue[i + 1].stMsgEntry), sizeof(TAF_MMA_ENTRY_MSG_STRU)); } /* 将缓存个数减一 */ pstMsgQueue->ucCacheMsgNum--; /* 将当前缓存给打印出来 */ TAF_MMA_LogBufferQueueMsg(VOS_FALSE); return VOS_TRUE; }
VOS_VOID TAF_MMA_SaveCacheMsgInMsgQueue( VOS_UINT32 ulEventType, VOS_VOID *pstMsg ) { TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; MSG_HEADER_STRU *pstMsgHeader = VOS_NULL_PTR; pstMsgHeader = (MSG_HEADER_STRU*)pstMsg; pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); if ( pstMsgQueue->ucCacheMsgNum >= TAF_MMA_MAX_MSG_QUEUE_NUM ) { TAF_ERROR_LOG(WUEPS_PID_MMA, "TAF_MMA_SaveCacheMsgInMsgQueue:buffer full"); TAF_MMA_LogBufferQueueMsg(VOS_TRUE); return; } /* 比较消息优先级,判断是否需要保存在缓存池中 */ if (VOS_FALSE == TAF_MMA_IsNeedCacheMsg(ulEventType, pstMsg)) { TAF_ERROR_LOG(WUEPS_PID_MMA, "TAF_MMA_SaveCacheMsgInMsgQueue:already exist msg"); return; } pstMsgQueue->astMsgQueue[pstMsgQueue->ucCacheMsgNum].stMsgEntry.ulEventType = ulEventType; PS_MEM_CPY((pstMsgQueue->astMsgQueue[pstMsgQueue->ucCacheMsgNum].stMsgEntry.aucEntryMsgBuffer), pstMsg, pstMsgHeader->ulLength + VOS_MSG_HEAD_LENGTH); pstMsgQueue->ucCacheMsgNum++; TAF_MMA_LogBufferQueueMsg(VOS_FALSE); TAF_INFO_LOG1(WUEPS_PID_MMA, "TAF_MMA_SaveCacheMsgInMsgQueue:Cache Num", pstMsgQueue->ucCacheMsgNum); return; }
VOS_UINT32 TAF_MMA_IsExistCacheMsg( VOS_UINT32 ulEventType, VOS_UINT32 *pulIndex ) { TAF_MMA_MSG_QUEUE_STRU *pstMsgQueue = VOS_NULL_PTR; VOS_UINT32 i; pstMsgQueue = TAF_MMA_GetCachMsgBufferAddr(); *pulIndex = 0; for ( i = 0 ; i < pstMsgQueue->ucCacheMsgNum ; i++ ) { if ( ulEventType == pstMsgQueue->astMsgQueue[i].stMsgEntry.ulEventType) { *pulIndex = i; return VOS_TRUE; } } TAF_INFO_LOG(WUEPS_PID_MMA, "TAF_MMA_IsExistCacheMsg:not match MSG"); return VOS_FALSE; }