MPLIST 示例阐明了如何使用 DSP/BIOSLINK 中的 MPLIST 的部件以及在 GPP 与使用多个处理器列表的 DSP 之间的数据流的方法。它实现了 GPP 端和 DSP 端之间的数据转换与传递。在 DSP 端,应用程序通过 MPLIST 实现了 TSK。
---------------------------------------------GPP端--------------------------------------------------------
status = MP_LIST_Create (dspExecutable,strNumIterations,strNumElem,processorId) ;
--------status = PROC_setup (NULL) ;
-------- status = PROC_attach (processorId, NULL) ;
--------status = POOL_open (POOL_makePoolId(processorId, SAMPLE_POOL_ID), &poolAttrs) ;
--------status = MPLIST_create (processorId,SampleGppMpListName,NULL,&mplistAttrs ) ;
--------status = MPLIST_open (processorId,SampleGppMpListName,&MP_LIST_MplistHandle) ;
--------status = MP_LIST_CreateSem (&MP_LIST_SemPtr) ;
--------status = NOTIFY_register (processorId,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(FnNotifyCbck) MP_LIST_Notify,MP_LIST_SemPtr) ;
--------status = POOL_alloc (POOL_makePoolId(processorId, SAMPLE_POOL_ID),(Pvoid *) &MP_LIST_Data [i],(listElemSize)) ;
--------status = PROC_load (processorId, (Char8 *) &imageInfo, numArgs, args) ;
--------status = PROC_start (processorId) ;
-------- status = MP_LIST_WaitSem (MP_LIST_SemPtr) ;//等待DSP侧应用程序表明已经完成设置。当DSP应用程序准备好了可进行进一步处理发出IPS 事件信息。
status = MP_LIST_Execute (numIterations,numElem,processorId) ;
--------
POOL_writeback (POOL_makePoolId(processorId, SAMPLE_POOL_ID),MP_LIST_Data [j],sizeof (MP_LIST_ListData)) ;
--------
status = MPLIST_putTail (MP_LIST_MplistHandle,(MPLIST_Elem) MP_LIST_Data [j]); //把数据添加到表中
--------
status = NOTIFY_notify (processorId,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(Uint32 ) 0) ;//GPP向DSP侧发出通知,它已经把数据添加到链表中了
--------status = MP_LIST_WaitSem (MP_LIST_SemPtr) ;//等待DSP已经修改链表的通知,当DSP修改链表后它会返回一个通知到GPP。
--------验证数据的正确性
1 status =
MPLIST_getHead (MP_LIST_MplistHandle,
2 (MPLIST_Elem *) &
currentElement) ;
3 if (DSP_SUCCEEDED(status)) {
4 POOL_invalidate (POOL_makePoolId(processorId, SAMPLE_POOL_ID),
5 currentElement,
6 sizeof (MP_LIST_ListData)) ;
7 status =
MP_LIST_VerifyData (i, j, currentElement) ;
8 if (DSP_FAILED (status)) {
9 MP_LIST_1Print (
"Data verification failed."
10 " Status = [0x%x]
",
11 status) ;
12 }
13 }
14 else {
15 MP_LIST_1Print (
"MPLIST_getHead failed."
16 " Status = [0x%x]
",
17 status) ;
18 }
19
MP_LIST_Delete (numElem, processorId) ;
-------- tmpStatus = PROC_stop (processorId) ;
--------
tmpStatus = NOTIFY_unregister (processorId,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(FnNotifyCbck) MP_LIST_Notify,MP_LIST_SemPtr) ;
--------tmpStatus = MP_LIST_DeleteSem (MP_LIST_SemPtr) ;
--------
tmpStatus = POOL_free (POOL_makePoolId(processorId, SAMPLE_POOL_ID),(Pvoid ) MP_LIST_Data [i],listElemSize) ;
--------tmpStatus = MPLIST_close (MP_LIST_MplistHandle) ;
--------tmpStatus = MPLIST_delete (processorId, SampleGppMpListName) ;
-------- tmpStatus = POOL_close (POOL_makePoolId(processorId, SAMPLE_POOL_ID)) ;
--------tmpStatus = PROC_detach (processorId) ;
--------tmpStatus = PROC_destroy () ;
---------------------------------------------DSP端--------------------------------------------------------
DSPLINK_init () ;
tskMpListTask = TSK_create (tskMpList, NULL, 0) ;
-status = TSKMPLIST_create (&info) ;
--------status = POOL_open (0, &poolObj) ;
--------
*infoPtr = MEM_calloc (DSPLINK_SEGID,sizeof (TSKMPLIST_TransferInfo),DSPLINK_BUF_ALIGN) ;
--------
status = NOTIFY_register (ID_GPP,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(FnNotifyCbck) TSKMPLIST_notify,info) ;
--------
status = MPLIST_open(ID_GPP,SAMPLE_MP_LIST_GPP_NAME,&(info->gppMpListHandle)) ;
--------SEM_new (&(info->notifySemObj), 0) ;
--------
status = NOTIFY_notify (ID_GPP,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(Uint32) 0) ; //向GPP发送通知,它已准备好进一步的执行动作
- status = TSKMPLIST_execute (info) ;
--------semStatus = SEM_pend (&(info->notifySemObj), SYS_FOREVER) ;//等待GPP发来通知它已经把数据加到链表中了
--------如果收到通知,则获取链表表头,获取链表元素内容,更新内容,在链表尾加入一个元素
1 for (j =
0 ;
2 ((j < info->numElem)) && ((status ==
SYS_OK)) ;
3 j++
) {
4 /* Get list head */
5 status =
MPLIST_getHead(mplistHandle,
6 (MPLIST_Elem *) &
currentElement) ;
7 if (status ==
SYS_OK) {
8 /* Get list element contents */
9 HAL_cacheInv((Ptr)currentElement, listElemSize) ;
10
11 /* Update list element contents */
12 currentElement->value = currentElement->
iter
13 * currentElement->
pos ;
14 HAL_cacheWbInv((Ptr)currentElement, listElemSize) ;
15 /* Add element to end of list */
16 status =
MPLIST_putTail (mplistHandle,
17 (MPLIST_Elem ) currentElement) ;
18 if (status !=
SYS_OK) {
19 SET_FAILURE_REASON (status) ;
20 }
21 }
22 else {
23 SET_FAILURE_REASON (status) ;
24 }
--------
tmpStatus = NOTIFY_notify (ID_GPP,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(Uint32 ) 0) ;
- status = TSKMPLIST_delete (info) ;
--------status = MPLIST_close(mplistHandle) ;
--------
status = NOTIFY_unregister (ID_GPP,MP_LIST_IPS_ID,MP_LIST_IPS_EVENTNO,(FnNotifyCbck) TSKMPLIST_notify,info) ;
--------freeStatus = MEM_free ()、