Exemplo n.º 1
0
/** ============================================================================
 *  @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") ;
}
Exemplo n.º 2
0
/** ============================================================================
 *  @func   DSP_Execute
 *
 *  @desc   This function implements the execute phase for this application.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
DSP_Execute ()
{
    DSP_STATUS status = DSP_SOK ;

    LOOP_0Print ("Entered DSP_Execute ()\n") ;

    status = PROC_start (0) ;

    if (DSP_SUCCEEDED (status)) {
        LOOP_0Print ("PROC_start succeeded!\n") ;
    }
    else {
        LOOP_1Print ("PROC_start failed. Status = [0x%x]\n", status) ;
    }

    LOOP_0Print ("Leaving DSP_Execute ()\n") ;

    return status ;
}
Exemplo n.º 3
0
Arquivo: loop.c Projeto: vh21/dsplink
/** ============================================================================
 *  @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") ;
}
Exemplo n.º 4
0
Arquivo: loop.c Projeto: vh21/dsplink
/** ============================================================================
 *  @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") ;
}
Exemplo n.º 5
0
Arquivo: loop.c Projeto: vh21/dsplink
/** ============================================================================
 *  @func   LOOP_Execute
 *
 *  @desc   This function implements the execute phase for this application.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LOOP_Execute (IN Uint32 numIterations, Uint8 processorId)
{
    DSP_STATUS status = DSP_SOK ;
    Uint32     i ;

    LOOP_0Print ("Entered LOOP_Execute ()\n") ;

    /*
     *  Start execution on DSP.
     */
    status = PROC_start (processorId) ;

    /*
     *  Fill the IO Request structure
     *  It gives Information for adding or reclaiming an input request.
     */
    if (DSP_SUCCEEDED (status)) {
        LOOP_IOReq.buffer = LOOP_Buffers [0] ;
        LOOP_IOReq.size   = LOOP_BufferSize   ;
    }
    else {
        LOOP_1Print ("PROC_start failed. Status = [0x%x]\n", status) ;
    }

    for (i = 1 ;
            (   (LOOP_NumIterations == 0) || (i <= LOOP_NumIterations))
            && (DSP_SUCCEEDED (status)) ;
            i++) {
        /*
         *  Initialize data
         */
        status = LOOP_InitData(LOOP_IOReq.buffer);
        if (DSP_FAILED (status)) {
            LOOP_0Print ("Init data failed.\n") ;
            status = DSP_EFAIL;
        }

        /*
         *  Send data to DSP.
         *  Issue 'filled' buffer to the channel.
         */
        if (DSP_SUCCEEDED (status)) {
            status = CHNL_issue (processorId, CHNL_ID_OUTPUT, &LOOP_IOReq) ;
            if (DSP_FAILED (status)) {
                LOOP_1Print ("CHNL_issue failed (output). Status = [0x%x]\n",
                             status) ;
            }
        }

        /*
         *  Reclaim 'empty' buffer from the channel
         */
        if (DSP_SUCCEEDED (status)) {
            status = CHNL_reclaim (processorId,
                                   CHNL_ID_OUTPUT,
                                   WAIT_FOREVER,
                                   &LOOP_IOReq) ;
            if (DSP_FAILED (status)) {
                LOOP_1Print ("CHNL_reclaim failed (output). Status = [0x%x]\n",
                             status) ;
            }
        }

        /*
         *  Receive data from DSP
         *  Issue 'empty' buffer to the channel.
         */
        if (DSP_SUCCEEDED (status)) {
            status = CHNL_issue (processorId, CHNL_ID_INPUT, &LOOP_IOReq) ;
            if (DSP_FAILED (status)) {
                LOOP_1Print ("CHNL_issue failed (input). Status = [0x%x]\n",
                             status) ;
            }
        }

        /*
         *  Reclaim 'filled' buffer from the channel
         */
        if (DSP_SUCCEEDED (status)) {
            status = CHNL_reclaim (processorId,
                                   CHNL_ID_INPUT,
                                   WAIT_FOREVER,
                                   &LOOP_IOReq) ;
            if (DSP_FAILED (status)) {
                LOOP_1Print ("CHNL_reclaim failed (input). Status = [0x%x]\n",
                             status) ;
            }
        }

        /*
         *  Verify correctness of data received.
         */
        if (DSP_SUCCEEDED (status)) {
            status = LOOP_HandleResultData (LOOP_IOReq.buffer) ;
            if (DSP_FAILED (status)) {
                LOOP_0Print ("Data integrity failed\n") ;
            }
        }

        if (DSP_SUCCEEDED (status) && (i % 1000) == 0) {
            LOOP_1Print ("Transferred %ld buffers\n", i) ;
        }
    }

    LOOP_0Print ("Leaving LOOP_Execute ()\n") ;

    return status ;
}
Exemplo n.º 6
0
Arquivo: loop.c Projeto: vh21/dsplink
/** ============================================================================
 *  @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 ;
}
Exemplo n.º 7
0
/** ============================================================================
 *  @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 ;
}