/** ============================================================================ * @func DSP_Delete * * @desc This function releases resources allocated earlier by call to * DSP_Create (). * During cleanup, the allocated resources are being freed * unconditionally. Actual applications may require stricter check * against return values for robustness. * * @modif LOOP_Buffers * ============================================================================ */ NORMAL_API Void DSP_Delete (Uint8 processorId) { DSP_STATUS status = DSP_SOK ; DSP_STATUS tmpStatus = DSP_SOK ; LOOP_0Print ("Entered DSP_Delete ()\n") ; status = PROC_stop (processorId) ; tmpStatus = POOL_close (POOL_makePoolId(processorId, 0)) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("POOL_close () failed. Status = [0x%x]\n", tmpStatus) ; } tmpStatus = PROC_detach (processorId) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("PROC_detach () failed. Status = [0x%x]\n", tmpStatus) ; } tmpStatus = PROC_destroy () ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("PROC_destroy () failed. Status = [0x%x]\n", tmpStatus) ; } LOOP_0Print ("Leaving DSP_Delete ()\n") ; }
/** ============================================================================ * @func helloDSP_Delete * * @desc This function releases resources allocated earlier by call to * helloDSP_Create (). * During cleanup, the allocated resources are being freed * unconditionally. Actual applications may require stricter check * against return values for robustness. * * @modif None * ============================================================================ */ NORMAL_API Void helloDSP_Delete(Uint8 processorId) { DSP_STATUS status = DSP_SOK; DSP_STATUS tmpStatus = DSP_SOK; SYSTEM_0Print("Entered helloDSP_Delete ()\n"); /* Release the remote message queue */ status = MSGQ_release(SampleDspMsgq); if (DSP_FAILED(status)) { SYSTEM_1Print("MSGQ_release () failed. Status = [0x%x]\n", status); } /* Close the remote transport */ tmpStatus = MSGQ_transportClose(processorId); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("MSGQ_transportClose () failed. Status = [0x%x]\n", status); } /* Stop execution on DSP. */ tmpStatus = PROC_stop(processorId); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("PROC_stop () failed. Status = [0x%x]\n", status); } /* Reset the error handler before deleting the MSGQ that receives */ /* the error messages. */ tmpStatus = MSGQ_setErrorHandler(MSGQ_INVALIDMSGQ, MSGQ_INVALIDMSGQ); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("MSGQ_setErrorHandler () failed. Status = [0x%x]\n", status); } /* Close the GPP's message queue */ tmpStatus = MSGQ_close(SampleGppMsgq); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("MSGQ_close () failed. Status = [0x%x]\n", status); } /* Close the pool */ tmpStatus = POOL_close(POOL_makePoolId(processorId, SAMPLE_POOL_ID)); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("POOL_close () failed. Status = [0x%x]\n", status); } /* Detach from the processor */ tmpStatus = PROC_detach(processorId); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("PROC_detach () failed. Status = [0x%x]\n", status); } /* Destroy the PROC object. */ tmpStatus = PROC_destroy(); if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus)) { status = tmpStatus; SYSTEM_1Print("PROC_destroy () failed. Status = [0x%x]\n", status); } SYSTEM_0Print("Leaving helloDSP_Delete ()\n"); }
/** ============================================================================ * @func helloDSP_Create * * @desc This function allocates and initializes resources used by * this application. * * @modif helloDSP_InpBufs , helloDSP_OutBufs * ============================================================================ */ NORMAL_API DSP_STATUS helloDSP_Create(IN Char8* dspExecutable, IN Char8* strNumIterations, IN Uint8 processorId) { DSP_STATUS status = DSP_SOK; Uint32 numArgs = NUM_ARGS; MSGQ_LocateAttrs syncLocateAttrs; Char8* args[NUM_ARGS]; SYSTEM_0Print("Entered helloDSP_Create ()\n"); /* Create and initialize the proc object. */ status = PROC_setup(NULL); /* Attach the Dsp with which the transfers have to be done. */ if (DSP_SUCCEEDED(status)) { status = PROC_attach(processorId, NULL); if (DSP_FAILED(status)) { SYSTEM_1Print("PROC_attach () failed. Status = [0x%x]\n", status); } } /* Open the pool. */ if (DSP_SUCCEEDED(status)) { status = POOL_open(POOL_makePoolId(processorId, SAMPLE_POOL_ID), &SamplePoolAttrs); if (DSP_FAILED(status)) { SYSTEM_1Print("POOL_open () failed. Status = [0x%x]\n", status); } } else { SYSTEM_1Print("PROC_setup () failed. Status = [0x%x]\n", status); } /* Open the GPP's message queue */ if (DSP_SUCCEEDED(status)) { status = MSGQ_open(SampleGppMsgqName, &SampleGppMsgq, NULL); if (DSP_FAILED(status)) { SYSTEM_1Print("MSGQ_open () failed. Status = [0x%x]\n", status); } } /* Set the message queue that will receive any async. errors */ if (DSP_SUCCEEDED(status)) { status = MSGQ_setErrorHandler(SampleGppMsgq, POOL_makePoolId(processorId, SAMPLE_POOL_ID)); if (DSP_FAILED(status)) { SYSTEM_1Print("MSGQ_setErrorHandler () failed. Status = [0x%x]\n", status); } } /* Load the executable on the DSP. */ if (DSP_SUCCEEDED(status)) { args [0] = strNumIterations; { status = PROC_load(processorId, dspExecutable, numArgs, args); } if (DSP_FAILED(status)) { SYSTEM_1Print("PROC_load () failed. Status = [0x%x]\n", status); } } /* Start execution on DSP. */ if (DSP_SUCCEEDED(status)) { status = PROC_start(processorId); if (DSP_FAILED(status)) { SYSTEM_1Print("PROC_start () failed. Status = [0x%x]\n", status); } } /* Open the remote transport. */ if (DSP_SUCCEEDED(status)) { mqtAttrs.poolId = POOL_makePoolId(processorId, SAMPLE_POOL_ID); status = MSGQ_transportOpen(processorId, &mqtAttrs); if (DSP_FAILED(status)) { SYSTEM_1Print("MSGQ_transportOpen () failed. Status = [0x%x]\n", status); } } /* Locate the DSP's message queue */ /* At this point the DSP must open a message queue named "DSPMSGQ" */ if (DSP_SUCCEEDED(status)) { syncLocateAttrs.timeout = WAIT_FOREVER; status = DSP_ENOTFOUND; SYSTEM_2Sprint(dspMsgqName, "%s%d", (Uint32) SampleDspMsgqName, processorId); while ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY)) { status = MSGQ_locate(dspMsgqName, &SampleDspMsgq, &syncLocateAttrs); if ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY)) { SYSTEM_Sleep(100000); } else if (DSP_FAILED(status)) { SYSTEM_1Print("MSGQ_locate () failed. Status = [0x%x]\n", status); } } } SYSTEM_0Print("Leaving helloDSP_Create ()\n"); return status; }
/** ============================================================================ * @func LOOP_Delete * * @desc This function releases resources allocated earlier by call to * LOOP_Create (). * During cleanup, the allocated resources are being freed * unconditionally. Actual applications may require stricter check * against return values for robustness. * * @modif LOOP_Buffers * ============================================================================ */ NORMAL_API Void LOOP_Delete (Uint8 processorId) { DSP_STATUS status = DSP_SOK ; DSP_STATUS tmpStatus = DSP_SOK ; LOOP_0Print ("Entered LOOP_Delete ()\n") ; /* * Free the buffer(s) allocated for channel to DSP */ tmpStatus = CHNL_freeBuffer (processorId, CHNL_ID_OUTPUT, LOOP_Buffers, 1) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("CHNL_freeBuffer () failed (output). Status = [0x%x]\n", tmpStatus) ; } /* * Delete both input and output channels */ tmpStatus = CHNL_delete (processorId, CHNL_ID_INPUT) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("CHNL_delete () failed (input). Status = [0x%x]\n", tmpStatus) ; } tmpStatus = CHNL_delete (processorId, CHNL_ID_OUTPUT) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("CHNL_delete () failed (output). Status = [0x%x]\n", tmpStatus) ; } /* * Stop execution on DSP. */ status = PROC_stop (processorId) ; /* * Close the pool */ tmpStatus = POOL_close (POOL_makePoolId(processorId, POOL_ID)) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("POOL_close () failed. Status = [0x%x]\n", tmpStatus) ; } /* * Detach from the processor */ tmpStatus = PROC_detach (processorId) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("PROC_detach () failed. Status = [0x%x]\n", tmpStatus) ; } /* * Destroy the PROC object. */ tmpStatus = PROC_destroy () ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { LOOP_1Print ("PROC_destroy () failed. Status = [0x%x]\n", tmpStatus) ; } LOOP_0Print ("Leaving LOOP_Delete ()\n") ; }
/** ============================================================================ * @func LOOP_Create * * @desc This function allocates and initializes resources used by * this application. * * @modif LOOP_Buffers * ============================================================================ */ NORMAL_API DSP_STATUS LOOP_Create (IN Char8 * dspExecutable, IN Char8 * strBufferSize, IN Char8 * strNumIterations, IN Uint8 processorId) { DSP_STATUS status = DSP_SOK ; Char8 * temp = NULL ; Uint32 numArgs = 0 ; Uint32 numBufs [NUMBUFFERPOOLS] = {NUMBUFS} ; #if defined (DA8XXGEM) NOLOADER_ImageInfo imageInfo ; #endif ChannelAttrs chnlAttrInput ; ChannelAttrs chnlAttrOutput ; Uint16 i ; Char8 * args [NUM_ARGS] ; Uint32 size [NUMBUFFERPOOLS] ; #if defined (ZCPY_LINK) SMAPOOL_Attrs poolAttrs ; #endif /* if defined (ZCPY_LINK) */ LOOP_0Print ("Entered LOOP_Create ()\n") ; /* * Create and initialize the proc object. */ status = PROC_setup (NULL) ; /* * Attach the Dsp with which the transfers have to be done. */ if (DSP_SUCCEEDED (status)) { status = PROC_attach (processorId, NULL) ; if (DSP_FAILED (status)) { LOOP_1Print ("PROC_attach failed . Status = [0x%x]\n", status) ; } } else { LOOP_1Print ("PROC_setup failed. Status = [0x%x]\n", status) ; } /* * Open the pool. */ if (DSP_SUCCEEDED (status)) { size [0] = LOOP_BufferSize ; poolAttrs.bufSizes = (Uint32 *) &size ; poolAttrs.numBuffers = (Uint32 *) &numBufs ; poolAttrs.numBufPools = NUMBUFFERPOOLS ; #if defined (ZCPY_LINK) poolAttrs.exactMatchReq = TRUE ; #endif /* if defined (ZCPY_LINK) */ status = POOL_open (POOL_makePoolId(processorId, POOL_ID), &poolAttrs) ; if (DSP_FAILED (status)) { LOOP_1Print ("POOL_open () failed. Status = [0x%x]\n", status) ; } } /* * Load the executable on the DSP. */ if (DSP_SUCCEEDED (status)) { numArgs = NUM_ARGS ; args [0] = strBufferSize ; args [1] = strNumIterations ; #if defined (DA8XXGEM) if (LINKCFG_config.dspConfigs [processorId]->dspObject->doDspCtrl == DSP_BootMode_NoBoot) { imageInfo.dspRunAddr = LOOP_dspAddr ; imageInfo.shmBaseAddr = LOOP_shmAddr ; imageInfo.argsAddr = LOOP_argsAddr ; imageInfo.argsSize = 50 ; status = PROC_load (processorId, (Char8 *) &imageInfo, numArgs, args) ; } else #endif { status = PROC_load (processorId, dspExecutable, numArgs, args) ; } if (DSP_FAILED (status)) { LOOP_1Print ("PROC_load failed. Status = [0x%x]\n", status) ; } } /* * Create a channel to DSP */ if (DSP_SUCCEEDED (status)) { chnlAttrOutput.mode = ChannelMode_Output ; chnlAttrOutput.endianism = Endianism_Default ; chnlAttrOutput.size = ChannelDataSize_16bits ; status = CHNL_create (processorId, CHNL_ID_OUTPUT, &chnlAttrOutput) ; if (DSP_FAILED (status)) { LOOP_1Print ("CHNL_create failed (output). Status = [0x%x]\n", status) ; } } /* * Create a channel from DSP */ if (DSP_SUCCEEDED (status)) { chnlAttrInput.mode = ChannelMode_Input ; chnlAttrInput.endianism = Endianism_Default ; chnlAttrInput.size = ChannelDataSize_16bits ; status = CHNL_create (processorId, CHNL_ID_INPUT, &chnlAttrInput) ; if (DSP_FAILED (status)) { LOOP_1Print ("CHNL_create failed (input). Status = [0x%x]\n", status) ; } } /* * Allocate buffer(s) for data transfer to DSP. */ if (DSP_SUCCEEDED (status)) { status = CHNL_allocateBuffer (processorId, CHNL_ID_OUTPUT, LOOP_Buffers, LOOP_BufferSize , 1) ; if (DSP_FAILED (status)) { LOOP_1Print ("CHNL_allocateBuffer failed (output)." " Status = [0x%x]\n", status) ; } } /* * Initialize the buffer with valid data. */ if (DSP_SUCCEEDED (status)) { temp = LOOP_Buffers [0] ; for (i = 0 ; i < LOOP_BufferSize ; i++) { *temp++ = XFER_CHAR ; } } LOOP_0Print ("Leaving LOOP_Create ()\n") ; return status ; }
/** ============================================================================ * @func DSP_Create * * @desc This function allocates and initializes resources used by * this application. * * @modif LOOP_Buffers * ============================================================================ */ NORMAL_API DSP_STATUS DSP_Create (IN Char8 * dspExecutable, IN Char8 * strControlArray, Uint8 processorId) { DSP_STATUS status = DSP_SOK ; Uint32 numArgs = 0 ; Uint32 numBufs [1] = {4} ; Char8 * args [1] ; Uint32 size [1] ; #if defined (ZCPY_LINK) SMAPOOL_Attrs poolAttrs ; #endif /* if defined (ZCPY_LINK) */ LOOP_0Print ("Entered DSP_Create ()\n") ; LOOP_BufferSize = DSPLINK_ALIGN (LOOP_Atoi ("1024"), DSPLINK_BUF_ALIGN) ; /* * Create and initialize the proc object. */ status = PROC_setup (NULL) ; /* * Attach the Dsp with which the transfers have to be done. */ if (DSP_SUCCEEDED (status)) { status = PROC_attach (processorId, NULL) ; if (DSP_FAILED (status)) { LOOP_1Print ("PROC_attach failed . Status = [0x%x]\n", status) ; } } else { LOOP_1Print ("PROC_setup failed. Status = [0x%x]\n", status) ; } if (DSP_SUCCEEDED (status)) { size [0] = LOOP_BufferSize ; poolAttrs.bufSizes = (Uint32 *) &size ; poolAttrs.numBuffers = (Uint32 *) &numBufs ; poolAttrs.numBufPools = 1 ; status = POOL_open (POOL_makePoolId(processorId, 0), &poolAttrs) ; if (DSP_FAILED (status)) { LOOP_1Print ("POOL_open () failed. Status = [0x%x]\n", status) ; } } /* * Load the executable on the DSP. */ if (DSP_SUCCEEDED (status)) { numArgs = 1 ; args [0] = strControlArray ; status = PROC_load (processorId, dspExecutable, numArgs, args) ; if (DSP_FAILED (status)) { LOOP_1Print ("PROC_load failed. Status = [0x%x]\n", status) ; } } LOOP_0Print ("Leaving DSP_Create ()\n") ; return status ; }
/** ============================================================================ * @func pool_notify_Delete * * @desc This function releases resources allocated earlier by call to * pool_notify_Create (). * During cleanup, the allocated resources are being freed * unconditionally. Actual applications may require stricter check * against return values for robustness. * * @modif None * ============================================================================ */ NORMAL_API Void pool_notify_Delete (Uint8 processorId) { DSP_STATUS status = DSP_SOK ; DSP_STATUS tmpStatus = DSP_SOK ; #ifdef DEBUG printf ("Entered pool_notify_Delete ()\n") ; #endif /* * Stop execution on DSP. */ status = PROC_stop (processorId) ; if (DSP_FAILED (status)) { printf ("PROC_stop () failed. Status = [0x%x]\n", (int)status) ; } /* * Unregister for notification of event registered earlier. */ tmpStatus = NOTIFY_unregister (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (FnNotifyCbck) pool_notify_Notify, 0/* vladms pool_notify_SemPtr*/) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { status = tmpStatus ; printf ("NOTIFY_unregister () failed Status = [0x%x]\n", (int)status) ; } /* * Free the memory allocated for the data buffer. */ tmpStatus = POOL_free (POOL_makePoolId(processorId, SAMPLE_POOL_ID), (Void *) pool_notify_DataBuf, pool_notify_BufferSize) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { status = tmpStatus ; printf ("POOL_free () DataBuf failed. Status = [0x%x]\n", (int)status) ; } /* * Close the pool */ tmpStatus = POOL_close (POOL_makePoolId(processorId, SAMPLE_POOL_ID)) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { status = tmpStatus ; printf ("POOL_close () failed. Status = [0x%x]\n", (int)status) ; } /* * Detach from the processor */ tmpStatus = PROC_detach (processorId) ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { status = tmpStatus ; printf ("PROC_detach () failed. Status = [0x%x]\n", (int)status) ; } /* * Destroy the PROC object. */ tmpStatus = PROC_destroy () ; if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) { status = tmpStatus ; printf ("PROC_destroy () failed. Status = [0x%x]\n", (int)status) ; } #ifdef DEBUG printf ("Leaving pool_notify_Delete ()\n") ; #endif }
/** ============================================================================ * @func pool_notify_Execute * * @desc This function implements the execute phase for this application. * * @modif None * ============================================================================ */ NORMAL_API DSP_STATUS pool_notify_Execute (IN Uint32 numIterations, Uint8 processorId, IN Char8 * strFeatures, IN Char8 * strFrames) { DSP_STATUS status = DSP_SOK ; long long start; // Variables for klt unsigned char *img1, *img2; char fnamein[100], fnameout[100]; KLT_TrackingContext tc; KLT_FeatureList fl; KLT_FeatureTable ft; int ncols, nrows; int i; int nFeatures; int nFrames; #if defined(DSP) unsigned char *buf_dsp; #endif #ifdef DEBUG printf ("Entered pool_notify_Execute ()\n") ; #endif nFeatures = atoi(strFeatures); nFrames = atoi(strFrames); unit_init(); start = get_usec(); tc = KLTCreateTrackingContext(); fl = KLTCreateFeatureList(nFeatures); ft = KLTCreateFeatureTable(nFrames, nFeatures); tc->sequentialMode = TRUE; tc->writeInternalImages = FALSE; tc->affineConsistencyCheck = -1; /* set this to 2 to turn on affine consistency check */ //startTimer(&appTimer); img1 = pgmReadFile("img0.pgm", NULL, &ncols, &nrows); img2 = (unsigned char *) malloc(ncols*nrows*sizeof(unsigned char)); KLTSelectGoodFeatures(tc, img1, ncols, nrows, fl); KLTStoreFeatureList(fl, ft, 0); KLTWriteFeatureListToPPM(fl, img1, ncols, nrows, "feat0.ppm"); for (i = 1 ; i < nFrames ; i++) { sprintf(fnamein, "img%d.pgm", i); pgmReadFile(fnamein, img2, &ncols, &nrows); KLTTrackFeatures(tc, img1, img2, ncols, nrows, fl); #ifdef REPLACE KLTReplaceLostFeatures(tc, img2, ncols, nrows, fl); #endif KLTStoreFeatureList(fl, ft, i); sprintf(fnameout, "feat%d.ppm", i); KLTWriteFeatureListToPPM(fl, img2, ncols, nrows, fnameout); } //stopTimer(&appTimer); //printTime(appTimer); //printf("Frames per second = %4.2f\n", nFrames / getTime(appTimer) *1000 ); KLTWriteFeatureTable(ft, "features.txt", "%5.1f"); KLTWriteFeatureTable(ft, "features.ft", NULL); KLTFreeFeatureTable(ft); KLTFreeFeatureList(fl); KLTFreeTrackingContext(tc); free(img1); free(img2); #if !defined(DSP) printf(" Result is %d \n", sum_dsp(pool_notify_DataBuf,pool_notify_BufferSize)); #endif #if defined(DSP) POOL_writeback (POOL_makePoolId(processorId, SAMPLE_POOL_ID), pool_notify_DataBuf, pool_notify_BufferSize); POOL_translateAddr ( POOL_makePoolId(processorId, SAMPLE_POOL_ID), (void*)&buf_dsp, AddrType_Dsp, (Void *) pool_notify_DataBuf, AddrType_Usr) ; NOTIFY_notify (processorId,pool_notify_IPS_ID,pool_notify_IPS_EVENTNO,1); sem_wait(&sem); #endif printf("Sum execution time %lld us.\n", get_usec()-start); return status ; }
/** ============================================================================ * @func pool_notify_Create * * @desc This function allocates and initializes resources used by * this application. * * @modif None * ============================================================================ */ NORMAL_API DSP_STATUS pool_notify_Create (IN Char8 * dspExecutable, IN Char8 * strBufferSize, IN Uint8 processorId) { DSP_STATUS status = DSP_SOK ; Uint32 numArgs = NUM_ARGS ; Void * dspDataBuf = NULL ; Uint32 numBufs [NUM_BUF_SIZES] = {NUM_BUF_POOL0, } ; Uint32 size [NUM_BUF_SIZES] ; SMAPOOL_Attrs poolAttrs ; Char8 * args [NUM_ARGS] ; #ifdef DEBUG printf ("Entered pool_notify_Create ()\n") ; #endif sem_init(&sem,0,0); /* * Create and initialize the proc object. */ status = PROC_setup (NULL) ; /* * Attach the Dsp with which the transfers have to be done. */ if (DSP_SUCCEEDED (status)) { status = PROC_attach (processorId, NULL) ; if (DSP_FAILED (status)) { printf ("PROC_attach () failed. Status = [0x%x]\n", (int)status) ; } } else { printf ("PROC_setup () failed. Status = [0x%x]\n", (int)status) ; } /* * Open the pool. */ if (DSP_SUCCEEDED (status)) { size [0] = pool_notify_BufferSize ; poolAttrs.bufSizes = (Uint32 *) &size ; poolAttrs.numBuffers = (Uint32 *) &numBufs ; poolAttrs.numBufPools = NUM_BUF_SIZES ; poolAttrs.exactMatchReq = TRUE ; status = POOL_open (POOL_makePoolId(processorId, SAMPLE_POOL_ID), &poolAttrs) ; if (DSP_FAILED (status)) { printf ("POOL_open () failed. Status = [0x%x]\n", (int)status) ; } } /* * Allocate the data buffer to be used for the application. */ if (DSP_SUCCEEDED (status)) { status = POOL_alloc (POOL_makePoolId(processorId, SAMPLE_POOL_ID), (Void **) &pool_notify_DataBuf, pool_notify_BufferSize) ; /* Get the translated DSP address to be sent to the DSP. */ if (DSP_SUCCEEDED (status)) { status = POOL_translateAddr ( POOL_makePoolId(processorId, SAMPLE_POOL_ID), &dspDataBuf, AddrType_Dsp, (Void *) pool_notify_DataBuf, AddrType_Usr) ; if (DSP_FAILED (status)) { printf ("POOL_translateAddr () DataBuf failed." " Status = [0x%x]\n", (int)status) ; } } else { printf ("POOL_alloc () DataBuf failed. Status = [0x%x]\n", (int)status) ; } } /* * Register for notification that the DSP-side application setup is * complete. */ if (DSP_SUCCEEDED (status)) { status = NOTIFY_register (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (FnNotifyCbck) pool_notify_Notify, 0/* vladms XFER_SemPtr*/) ; if (DSP_FAILED (status)) { printf ("NOTIFY_register () failed Status = [0x%x]\n", (int)status) ; } } /* * Load the executable on the DSP. */ if (DSP_SUCCEEDED (status)) { args [0] = strBufferSize ; { status = PROC_load (processorId, dspExecutable, numArgs, args) ; } if (DSP_FAILED (status)) { printf ("PROC_load () failed. Status = [0x%x]\n", (int)status) ; } } /* * Start execution on DSP. */ if (DSP_SUCCEEDED (status)) { status = PROC_start (processorId) ; if (DSP_FAILED (status)) { printf ("PROC_start () failed. Status = [0x%x]\n", (int)status) ; } } /* * Wait for the DSP-side application to indicate that it has completed its * setup. The DSP-side application sends notification of the IPS event * when it is ready to proceed with further execution of the application. */ if (DSP_SUCCEEDED (status)) { // wait for initialization sem_wait(&sem); } /* * Send notifications to the DSP with information about the address of the * control structure and data buffer to be used by the application. * */ status = NOTIFY_notify (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (Uint32) dspDataBuf); if (DSP_FAILED (status)) { printf ("NOTIFY_notify () DataBuf failed." " Status = [0x%x]\n", (int)status) ; } status = NOTIFY_notify (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (Uint32) pool_notify_BufferSize); if (DSP_FAILED (status)) { printf ("NOTIFY_notify () DataBuf failed." " Status = [0x%x]\n", (int)status) ; } #ifdef DEBUG printf ("Leaving pool_notify_Create ()\n") ; #endif return status ; }