Int32 System_ipcListMPReset(ListMP_Handle pOutHndl, ListMP_Handle pInHndl) { Ptr listElem; listElem = ListMP_getHead(pOutHndl); while(listElem != NULL) { listElem = ListMP_getHead(pOutHndl); //OSA_printf("SYSTEM:Freeing leftover listElem in outQue:[%p]", // listElem); } listElem = ListMP_getHead(pInHndl); while(listElem != NULL) { listElem = ListMP_getHead(pInHndl); //OSA_printf("SYSTEM:Freeing leftover listElem in inQue:[%p]", // listElem); } return OSA_SOK; }
/* * ======== TransportShm_swiFxn ======== */ Void TransportShm_swiFxn(UArg arg) { UInt32 queueId; TransportShm_Object *obj = (TransportShm_Object *)arg; MessageQ_Msg msg = NULL; /* * While there are messages, get them out and send them to * their final destination. */ msg = (MessageQ_Msg)ListMP_getHead((ListMP_Handle)obj->localList); while (msg != NULL) { /* Get the destination message queue Id */ queueId = MessageQ_getDstQueue(msg); /* put the message to the destination queue */ MessageQ_put(queueId, msg); /* check to see if there are more messages */ msg = (MessageQ_Msg)ListMP_getHead((ListMP_Handle)obj->localList); } }
/* * ======== SemaphoreMP_post ======== */ Void SemaphoreMP_post(SemaphoreMP_Object *obj) { UInt tskKey; SemaphoreMP_PendElem *elem; IArg gateMPKey; Int status; /* Enter the gate */ gateMPKey = GateMP_enter((GateMP_Handle)obj->gate); if (ListMP_empty((ListMP_Handle)obj->pendQ)) { if (obj->mode == SemaphoreMP_Mode_BINARY) { obj->attrs->count = 1; } else { obj->attrs->count++; } if (obj->cacheEnabled) { Cache_wbInv(obj->attrs, sizeof(SemaphoreMP_Attrs), Cache_Type_ALL, TRUE); } /* Leave the gate */ GateMP_leave((GateMP_Handle)obj->gate, gateMPKey); return; } /* lock task scheduler */ tskKey = Task_disable(); /* dequeue tsk from semaphore queue */ elem = (SemaphoreMP_PendElem *)ListMP_getHead((ListMP_Handle)obj->pendQ); if (elem->procId != MultiProc_self()) { /* Unblock remote task */ status = Notify_sendEvent(elem->procId, 0, SemaphoreMP_notifyEventId, elem->task, TRUE); Assert_isTrue(status >= 0, ti_sdo_ipc_Ipc_A_internal); } else { /* put task back into readyQ */ Task_unblock((Task_Handle)elem->task); } /* Leave the gate */ GateMP_leave((GateMP_Handle)obj->gate, gateMPKey); Task_restore(tskKey); }
Int32 IpcOutM3Link_releaseFrames(IpcOutM3Link_Obj * pObj) { System_LinkInQueParams *pInQueParams; SystemIpcM3_ListElem *pListElem = NULL; Int32 status; pInQueParams = &pObj->createArgs.inQueParams; do { pObj->freeFrameList.numFrames = 0; while (pObj->freeFrameList.numFrames < FVID2_MAX_FVID_FRAME_PTR) { pListElem = ListMP_getHead(pObj->listMPInHndl); if (pListElem == NULL) break; pObj->freeFrameList.frames[pObj->freeFrameList.numFrames] = pListElem->pFrame; pObj->freeFrameList.numFrames++; UTILS_assert(pObj->freeFrameList.numFrames <= FVID2_MAX_FVID_FRAME_PTR); /* release ListElem back to queue */ status = Utils_quePut(&pObj->listElemQue, pListElem, BIOS_NO_WAIT); UTILS_assert(status == FVID2_SOK); } #ifdef SYSTEM_DEBUG_IPC_RT Vps_printf(" %d: IPC_OUT_M3 : Releasing %d frames !!!\n", Utils_getCurTimeInMsec(), pObj->freeFrameList.numFrames); #endif if (pObj->freeFrameList.numFrames) { // Vps_printf("Ipc out ret !!!\n"); System_putLinksEmptyFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &pObj->freeFrameList); } } while (pListElem != NULL); return FVID2_SOK; }
Int32 IpcFramesInLink_processFrameBufs(IpcFramesInLink_Obj * pObj) { FVID2_Frame *pFrameBuf; SystemIpcFrames_ListElem *pListElem; UInt32 numFrameBufs; Int32 status; UInt32 curTime; numFrameBufs = 0; curTime = Utils_getCurTimeInMsec(); while (1) { pListElem = ListMP_getHead(pObj->listMPOutHndl); if (pListElem == NULL) break; IpcFramesInLink_getFrameBuf(pObj, pListElem, &pFrameBuf); UTILS_assert(SYSTEM_IPC_FRAMES_GET_BUFSTATE(pListElem->bufState) == IPC_FRAMEBUF_STATE_OUTQUE); pListElem->frameBuf.reserved[0] = curTime; SYSTEM_IPC_FRAMES_SET_BUFOWNERPROCID(pListElem->bufState); SYSTEM_IPC_FRAMES_SET_BUFSTATE(pListElem->bufState, IPC_FRAMEBUF_STATE_DEQUEUED); pObj->stats.recvCount++; status = Utils_quePut(&pObj->outFrameBufQue, pFrameBuf, BIOS_NO_WAIT); UTILS_assert(status == FVID2_SOK); numFrameBufs++; } #ifdef SYSTEM_DEBUG_IPC_RT Vps_printf(" %d: IPC_FRAMES_IN : Recevived %d framebufs !!!\n", Utils_getCurTimeInMsec(), numFrameBufs); #endif if (numFrameBufs && pObj->createArgs.baseCreateParams.notifyNextLink) { UTILS_assert(pObj->createArgs.baseCreateParams.numOutQue == 1); System_sendLinkCmd(pObj->createArgs.baseCreateParams.outQueParams[0]. nextLink, SYSTEM_CMD_NEW_DATA); } return IPC_FRAMES_IN_LINK_S_SUCCESS; }
static Int32 IpcFramesInLink_freeQueuedInputBufs(IpcFramesInLink_Obj * pObj) { SystemIpcFrames_ListElem *pListElem; Int32 status; UInt32 freeCount; freeCount = 0; while (1) { pListElem = ListMP_getHead(pObj->listMPOutHndl); if (pListElem == NULL) break; UTILS_assert(SYSTEM_IPC_FRAMES_GET_BUFSTATE(pListElem->bufState) == IPC_FRAMEBUF_STATE_OUTQUE); SYSTEM_IPC_FRAMES_SET_BUFOWNERPROCID(pListElem->bufState); SYSTEM_IPC_FRAMES_SET_BUFSTATE(pListElem->bufState, IPC_FRAMEBUF_STATE_INQUE); status = ListMP_putTail(pObj->listMPInHndl, (ListMP_Elem *) pListElem); UTILS_assert(status == ListMP_S_SUCCESS); pObj->stats.droppedCount++; freeCount++; } if (freeCount) { if(pObj->createArgs.baseCreateParams.notifyPrevLink) { // Vps_printf("271:System_ipcSendNotify,id=%d\n",pObj->createArgs.baseCreateParams.inQueParams.prevLinkId); System_ipcSendNotify(pObj->createArgs.baseCreateParams.inQueParams. prevLinkId); } } return IPC_FRAMES_IN_LINK_S_SUCCESS; }
Int32 IpcFramesInLink_create(IpcFramesInLink_Obj * pObj, IpcFramesInLinkRTOS_CreateParams * pPrm) { Int32 status; System_LinkInQueParams *pInQueParams; Int i; #ifdef SYSTEM_DEBUG_IPC Vps_printf(" %d: IPC_FRAMES_IN : Create in progress !!!\n", Utils_getCurTimeInMsec()); #endif UTILS_MEMLOG_USED_START(); memcpy(&pObj->createArgs, pPrm, sizeof(pObj->createArgs)); status = System_ipcListMPOpen(pObj->createArgs.baseCreateParams.inQueParams. prevLinkId, &pObj->listMPOutHndl, &pObj->listMPInHndl); UTILS_assert(status == FVID2_SOK); UTILS_assert(pObj->listMPInHndl != NULL); while(!ListMP_empty(pObj->listMPInHndl)) { Ptr listElem = ListMP_getHead(pObj->listMPInHndl); if (listElem != NULL) { IPCFRAMESINLINK_INFO_LOG(pObj->tskId, "InList not empty!!!" "Stale entry:[%p]", listElem); } } status = Utils_queCreate(&pObj->outFrameBufQue, SYSTEM_IPC_FRAMES_MAX_LIST_ELEM, pObj->outFrameBufQueMem, UTILS_QUE_FLAG_NO_BLOCK_QUE); UTILS_assert(status == FVID2_SOK); status = Utils_queCreate(&pObj->freeFrameQue, SYSTEM_IPC_FRAMES_MAX_LIST_ELEM, pObj->freeFrameQueMem, UTILS_QUE_FLAG_NO_BLOCK_QUE); UTILS_assert(status == FVID2_SOK); for (i = 0; i < SYSTEM_IPC_FRAMES_MAX_LIST_ELEM; i++) { pObj->freeFrameMem[i].appData = &pObj->freeFrameInfoMem[i]; Utils_quePut(&pObj->freeFrameQue,&pObj->freeFrameMem[i],BIOS_NO_WAIT); } pInQueParams = &pObj->createArgs.baseCreateParams.inQueParams; status = System_linkGetInfo(pInQueParams->prevLinkId, &pObj->inQueInfo); UTILS_assert(status == FVID2_SOK); IpcFramesInLink_setOutQueInfo(pObj); IpcFramesInLink_initStats(pObj); IpcFramesInLink_createPrdObj(pObj); if (TRUE == pObj->createArgs.baseCreateParams.noNotifyMode) { if (FALSE == pObj->prd.clkStarted) { IpcFramesInLink_startPrdObj(pObj, IPC_FRAMES_IN_LINK_DONE_PERIOD_MS, FALSE); } } pObj->state = IPC_FRAMES_IN_LINK_STATE_ACTIVE; UTILS_MEMLOG_USED_END(pObj->memUsed); UTILS_MEMLOG_PRINT("IPC_FRAMES_IN", pObj->memUsed, UTILS_ARRAYSIZE(pObj->memUsed)); #ifdef SYSTEM_DEBUG_IPC Vps_printf(" %d: IPC_FRAMES_IN : Create Done !!!\n", Utils_getCurTimeInMsec()); #endif return IPC_FRAMES_IN_LINK_S_SUCCESS; }