/** ============================================================================ * @func LOOP_Main * * @desc Entry point for the application * * @modif None * ============================================================================ */ NORMAL_API Void LOOP_Main (IN Char8 * dspExecutable, IN Char8 * strBufferSize, IN Char8 * strNumIterations, IN Char8 * strProcessorId) { DSP_STATUS status = DSP_SOK ; Uint8 processorId = 0 ; LOOP_0Print ("=============== Sample Application : LOOP ==========\n") ; memset (&source_data[0], 0, sizeof(source_data)); memset (&result_data[0], 0, sizeof(result_data)); memset (&expect_data[0], 0, sizeof(expect_data)); if ( (dspExecutable != NULL) && (strBufferSize != NULL) && (strNumIterations != NULL)) { /* * Validate the buffer size and number of iterations specified. */ LOOP_BufferSize = DSPLINK_ALIGN (MAX_XFER_SIZE, DSPLINK_BUF_ALIGN) ; if (LOOP_BufferSize == 0) { status = DSP_ESIZE ; } LOOP_NumIterations = LOOP_Atoi (strNumIterations) ; /* execute only once */ LOOP_NumIterations = 1 ; /* Find out the processor id to work with */ processorId = LOOP_Atoi (strProcessorId) ; if (processorId >= MAX_DSPS) { LOOP_1Print ("==Error: Invalid processor id specified %d ==\n", processorId) ; status = DSP_EFAIL ; } /* * Specify the dsp executable file name and the buffer size for * loop creation phase. */ if (DSP_SUCCEEDED (status)) { LOOP_1Print ("==== Executing sample for DSP processor Id %d ====\n", processorId) ; status = LOOP_Create (dspExecutable, strBufferSize, strNumIterations, processorId) ; /* * Execute the data transfer loop. */ if (DSP_SUCCEEDED (status)) { status = LOOP_Execute (LOOP_NumIterations, processorId) ; } /* * Perform cleanup operation. */ LOOP_Delete (processorId) ; } } else { status = DSP_EINVALIDARG ; LOOP_0Print ("ERROR! Invalid arguments specified for while executing " "loop application\n") ; } LOOP_0Print ("====================================================\n") ; }
/** ============================================================================ * @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 ; }