diff --git a/mcfw/interfaces/link_api/system_common.h b/mcfw/interfaces/link_api/system_common.h index 7d719a1..4032fd3 100755 --- a/mcfw/interfaces/link_api/system_common.h +++ b/mcfw/interfaces/link_api/system_common.h @@ -86,6 +86,7 @@ #define SYSTEM_IPC_SR_VIDEO_FRAME (2) #define SYSTEM_IPC_SR_AVSYNC (0) #define SYSTEM_IPC_SR_EXTRA_HEAP (3) +#define SYSTEM_IPC_SR_MAX (16) #define SYSTEM_IPC_PROC_NAME_DSP "DSP" #define SYSTEM_IPC_PROC_NAME_M3VIDEO "VIDEO-M3" diff --git a/mcfw/src_linux/links/audio/audio_utils.c b/mcfw/src_linux/links/audio/audio_utils.c index 9348059..6c0ea96 100755 --- a/mcfw/src_linux/links/audio/audio_utils.c +++ b/mcfw/src_linux/links/audio/audio_utils.c @@ -17,6 +17,7 @@ #include #include #include +#include #define SR_FRAME_BUFFERS_ID 1 /* same as UTILS_MEM_VID_BITS_BUF_HEAP */ /** ------ Globals */ @@ -97,7 +98,7 @@ Void *Audio_allocateSharedRegionBuf (Int32 bufSize) IHeap_Handle heap = NULL; Void *tmp = NULL; - heap = SharedRegion_getHeap(SR_FRAME_BUFFERS_ID); + heap = System_ipcGetSRHeap(SR_FRAME_BUFFERS_ID); tmp = Memory_calloc (heap, bufSize, 128, NULL); if (tmp) { @@ -110,7 +111,7 @@ Void Audio_freeSharedRegionBuf (Void *buf, Int32 bufSize) { IHeap_Handle heap = NULL; - heap = SharedRegion_getHeap(SR_FRAME_BUFFERS_ID); + heap = System_ipcGetSRHeap(SR_FRAME_BUFFERS_ID); if (heap) { Memory_free(heap, buf, bufSize); diff --git a/mcfw/src_linux/links/ipcBitsOut/ipcBitsOutLink_tsk.c b/mcfw/src_linux/links/ipcBitsOut/ipcBitsOutLink_tsk.c index 854d45a..ad63c1d 100755 --- a/mcfw/src_linux/links/ipcBitsOut/ipcBitsOutLink_tsk.c +++ b/mcfw/src_linux/links/ipcBitsOut/ipcBitsOutLink_tsk.c @@ -238,7 +238,7 @@ static Int IpcBitsOutLink_createOutObj(IpcBitsOutLink_Obj * pObj) const UInt32 srIndex = SYSTEM_IPC_SR_CACHED; elemId = 0; - srBitBufHeapHandle = SharedRegion_getHeap(srIndex); + srBitBufHeapHandle = System_ipcGetSRHeap(srIndex); OSA_assert(srBitBufHeapHandle != NULL); cacheLineSize = SharedRegion_getCacheLineSize(srIndex); @@ -316,7 +316,7 @@ static Int IpcBitsOutLink_deleteOutObj(IpcBitsOutLink_Obj * pObj) IHeap_Handle srBitBufHeapHandle; const UInt32 srIndex = SYSTEM_IPC_SR_CACHED; - srBitBufHeapHandle = SharedRegion_getHeap(srIndex); + srBitBufHeapHandle = System_ipcGetSRHeap(srIndex); OSA_assert(srBitBufHeapHandle != NULL); for (chId = 0; chId < pObj->numChn; chId++) { @@ -747,7 +747,7 @@ Void ipcbitsoutlink_do_delete_ch_buffer_pool(IpcBitsOutLink_Obj * pObj, Int status,i; SystemIpcBits_ListElem *pListElem; - srBitBufHeapHandle = SharedRegion_getHeap(srIndex); + srBitBufHeapHandle = System_ipcGetSRHeap(srIndex); OSA_assert(srBitBufHeapHandle != NULL); OSA_assert(OSA_queGetQueuedCount(&pObj->listElemQue[chId]) == @@ -888,7 +888,7 @@ Int32 IpcBitsOutLink_doChBufCreate(IpcBitsOutLink_Obj * pObj, totBufSize = OSA_align(bufCreatePrms->totalBitStreamBufferSize , cacheLineSize); - srBitBufHeapHandle = SharedRegion_getHeap(srIndex); + srBitBufHeapHandle = System_ipcGetSRHeap(srIndex); OSA_assert(srBitBufHeapHandle != NULL); Memory_getStats(srBitBufHeapHandle,&memstats); if (memstats.largestFreeSize >= totBufSize) diff --git a/mcfw/src_linux/links/system/system_ipc.c b/mcfw/src_linux/links/system/system_ipc.c index f3a1901..12a395f 100755 --- a/mcfw/src_linux/links/system/system_ipc.c +++ b/mcfw/src_linux/links/system/system_ipc.c @@ -42,11 +42,30 @@ Int32 System_printProcId(UInt32 procId) return 0; } +static +Void system_ipc_reset_srheaps() +{ + memset(gSystem_ipcObj.srHeaps,0,sizeof(gSystem_ipcObj.srHeaps)); +} + +IHeap_Handle System_ipcGetSRHeap(UInt32 srIndex) +{ + OSA_assert(srIndex < OSA_ARRAYSIZE(gSystem_ipcObj.srHeaps)); + if (NULL == gSystem_ipcObj.srHeaps[srIndex]) + { + gSystem_ipcObj.srHeaps[srIndex] = SharedRegion_getHeap(srIndex); + } + + return gSystem_ipcObj.srHeaps[srIndex]; +} + + Int32 System_ipcInit() { printf(" %u: SYSTEM: IPC init in progress !!!\n", OSA_getCurTimeInMsec()); SysLink_setup (); + system_ipc_reset_srheaps(); { UInt32 procId; @@ -69,10 +88,13 @@ Int32 System_ipcDeInit() { printf(" %u: SYSTEM: IPC de-init in progress !!!\n", OSA_getCurTimeInMsec()); + System_ipcNotifyDeInit(); System_ipcMsgQDeInit(); + system_ipc_reset_srheaps(); + SysLink_destroy (); printf(" %u: SYSTEM: IPC de-init DONE !!!\n", OSA_getCurTimeInMsec()); diff --git a/mcfw/src_linux/links/system/system_ipc_listMP.c b/mcfw/src_linux/links/system/system_ipc_listMP.c index 09edee6..9de8462 100755 --- a/mcfw/src_linux/links/system/system_ipc_listMP.c +++ b/mcfw/src_linux/links/system/system_ipc_listMP.c @@ -200,7 +200,7 @@ UInt32 System_ipcListMPAllocListElemMem(UInt32 regionId, UInt32 size) Error_Block eb; UInt32 shAddr; - heapHndl = SharedRegion_getHeap(regionId); + heapHndl = System_ipcGetSRHeap(regionId); UTILS_assert(heapHndl!=NULL); Error_init(&eb); @@ -222,7 +222,7 @@ Int32 System_ipcListMPFreeListElemMem(UInt32 regionId, UInt32 shAddr, UInt32 siz { IHeap_Handle heapHndl; - heapHndl = SharedRegion_getHeap(regionId); + heapHndl = System_ipcGetSRHeap(regionId); UTILS_assert(heapHndl!=NULL); Memory_free(heapHndl, (Ptr)shAddr, size); diff --git a/mcfw/src_linux/links/system/system_ipc_msgq.c b/mcfw/src_linux/links/system/system_ipc_msgq.c index d534949..89db70a 100755 --- a/mcfw/src_linux/links/system/system_ipc_msgq.c +++ b/mcfw/src_linux/links/system/system_ipc_msgq.c @@ -115,7 +115,7 @@ Int32 System_ipcMsgQHeapCreate() printf(" %d: SYSTEM: Creating MsgQ Heap [%s] ...\n", OSA_getCurTimeInMsec(), msgq_heap_name); - srHeap = SharedRegion_getHeap(SYSTEM_IPC_SR_NON_CACHED_DEFAULT); + srHeap = System_ipcGetSRHeap(SYSTEM_IPC_SR_NON_CACHED_DEFAULT); UTILS_assert(srHeap != NULL); gSystem_ipcObj.msgQHeapBaseAddr = @@ -166,7 +166,7 @@ Int32 System_ipcMsgQHeapDelete() status = HeapMemMP_delete(&gSystem_ipcObj.msgQHeapHndl); UTILS_assert(status == OSA_SOK); - srHeap = SharedRegion_getHeap(SYSTEM_IPC_SR_NON_CACHED_DEFAULT); + srHeap = System_ipcGetSRHeap(SYSTEM_IPC_SR_NON_CACHED_DEFAULT); UTILS_assert(srHeap != NULL); Memory_free(srHeap, @@ -586,7 +586,7 @@ static Void system_ipc_msgq_register_rpe_msgq_heap() IHeap_Handle srHeap; UTILS_assert(Rpe_messageqHeapId != SYSTEM_IPC_MSGQ_HEAP); - srHeap = SharedRegion_getHeap(SYSTEM_IPC_SR_NON_CACHED_DEFAULT); + srHeap = System_ipcGetSRHeap(SYSTEM_IPC_SR_NON_CACHED_DEFAULT); UTILS_assert(srHeap != NULL); MessageQ_registerHeap(srHeap, diff --git a/mcfw/src_linux/links/system/system_priv_ipc.h b/mcfw/src_linux/links/system/system_priv_ipc.h index 6b4e192..ba0dbe0 100755 --- a/mcfw/src_linux/links/system/system_priv_ipc.h +++ b/mcfw/src_linux/links/system/system_priv_ipc.h @@ -35,6 +35,7 @@ typedef struct { MessageQ_Msg freeMsgQueMem[(SYSTEM_IPC_MSGQ_HEAP_SIZE/SYSTEM_IPC_MSGQ_MSG_SIZE_MAX)]; System_ipcNotifyCb notifyCb[SYSTEM_LINK_ID_MAX]; + IHeap_Handle srHeaps[SYSTEM_IPC_SR_MAX]; } System_IpcObj; @@ -73,5 +74,6 @@ Int32 System_ipcCopySlaveCoreSymbolContents(char *symbolName, UInt16 procId, Ptr dstPtr, UInt32 copySize); +IHeap_Handle System_ipcGetSRHeap(UInt32 srIndex); #endif diff --git a/mcfw/src_linux/mcfw_api/ti_vsys.c b/mcfw/src_linux/mcfw_api/ti_vsys.c index 6d6a101..200c62a 100755 --- a/mcfw/src_linux/mcfw_api/ti_vsys.c +++ b/mcfw/src_linux/mcfw_api/ti_vsys.c @@ -41,7 +41,7 @@ #include "ti_vsys_priv.h" - +#include /* ============================================================================= * Globals * ============================================================================= @@ -394,7 +394,7 @@ Int32 Vsys_allocBuf(UInt32 srRegId, UInt32 bufSize, UInt32 bufAlign, Vsys_AllocB { IHeap_Handle heapHndl; - heapHndl = SharedRegion_getHeap(srRegId); + heapHndl = System_ipcGetSRHeap(srRegId); OSA_assert(heapHndl != NULL); bufInfo->virtAddr = NULL; @@ -420,7 +420,7 @@ Int32 Vsys_freeBuf(UInt32 srRegId, UInt8 *virtAddr, UInt32 bufSize) { IHeap_Handle heapHndl; - heapHndl = SharedRegion_getHeap(srRegId); + heapHndl = System_ipcGetSRHeap(srRegId); OSA_assert(heapHndl != NULL); OSA_assert(virtAddr != NULL);