Example #1
0
/*********************************************************************************
 * FUNCTION PURPOSE: Free EdmaMgr handle
 *********************************************************************************
  DESCRIPTION:      This function frees an EDMA channel

  Parameters :      Inputs: h   : EdmaMgr handle

                    Output: EdmaMgr_SUCCESS if free is successful;
                            Error code otherwise.
 *********************************************************************************/
int32_t EdmaMgr_free(EdmaMgr_Handle h)
{
    EdmaMgr_Channel *chan = (EdmaMgr_Channel *)h;
    IRES_ResourceDescriptor resDesc;
    IRES_Status ires_status;
    int32_t scratchId = -1;
    int32_t i, ret_val = EdmaMgr_SUCCESS;

    /* Make sure all transfers have completed */
    EdmaMgr_wait(h);

    /* While loop for freeing chained channels. */
    while ( chan != NULL ) {
      EdmaMgr_Channel *chainedChan = chan->chainedChannel;

      /* Verify that this is a valid handle? */
      for (i = 0; i < EDMA_MGR_MAX_NUM_CHANNELS; i++)
          if (chan == &EdmaMgr_channels[i])
              break;

      if (i >= EDMA_MGR_MAX_NUM_CHANNELS)
          return EdmaMgr_ERROR_INVHANDLE;

      /* Prepare IRES resource descriptor */
      resDesc.resourceName = IRES_EDMA3CHAN_PROTOCOLNAME;
      resDesc.revision = &_iresEDMA3ChanRevision;
      resDesc.protocolArgs = (IRES_ProtocolArgs *)&(chan->edmaArgs);
      resDesc.handle = (IRES_Handle)chan->edmaHandle;

      ECPY_deleteHandle(chan->ecpyHandle);

      ires_status =
              RMAN_freeAllocatedResources((Int)EdmaMgr_channels, &resDesc, 1,
              scratchId);
      if (ires_status != IRES_OK) {
          ret_val = EdmaMgr_ERROR_FREE;
      }

      chan->ecpyHandle = NULL;
      chan->edmaHandle = NULL;
      chan->xferPending = FALSE;

      chan->edmaArgs.numPaRams = 0;
      chan->chainedChannel = NULL;

      if ( chan->addrTable.base ) {
          chan->addrTable.base = NULL;
          chan->addrTable.size = 0;
      }

      chan = chainedChan;
    }

    return ret_val;
}
Example #2
0
/*
 *  ======== SWOSD_TI_deInitResources ========
 */
static IRES_Status SWOSD_TI_deInitResources(IALG_Handle h,
        IRES_ResourceDescriptor *desc)
{
	SWOSD_TI_Obj  *alg = (SWOSD_TI_Obj *)h;
	UInt8 i;

	for(i = 0; i < SWOSD_DMA_CH_MAX; i++)
	{
		if (desc[i].handle == (IRES_Handle)alg->edmaHandle[i]) {
			ECPY_deleteHandle(alg->ecpyHandle[i]);
			ECPY_exit();

			alg->ecpyHandle[i] = NULL;
			alg->edmaHandle[i] = NULL;
		}
	}

	return (IRES_OK);
}