XilinxProcessorIPLib/drivers/axicdma/src/xaxicdma_bdring.c
LONG XAxiCdma_BdRingClone(XAxiCdma *InstancePtr, XAxiCdma_Bd * TemplateBdPtr)
{
	int Index;
	UINTPTR CurBd;
	XAxiCdma_Bd TmpBd;

	/* Can't do this function if there isn't a ring */
	if (InstancePtr->AllBdCnt == 0) {

		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: no bds\r\n");

		return XST_DMA_SG_NO_LIST;
	}

	/* Can't do this function with the channel running */
	if (XAxiCdma_IsBusy(InstancePtr)) {

		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: engine is running, "
			"cannot do\r\n");

		return XST_DEVICE_IS_STARTED;
	}

	/* Can't do this function with some of the BDs in use */
	if (InstancePtr->FreeBdCnt != InstancePtr->AllBdCnt) {

		xdbg_printf(XDBG_DEBUG_ERROR,
		    "BdRingClone: some bds already in use %d/%d\r\n",
		    InstancePtr->FreeBdCnt, InstancePtr->AllBdCnt);

		return XST_DMA_SG_LIST_ERROR;
	}

	/* Make a copy of the template then clear the status bits
	 */
	memcpy(&TmpBd, TemplateBdPtr, sizeof(XAxiCdma_Bd));

	XAxiCdma_BdClearSts(&TmpBd);

	/* Starting from the top of the ring, save BD.Next, BD.PhysAddr
	 * overwrite the entire BD with the template, then restore BD.Next
	 * and BD.PhysAddr
	 */
	for (Index = 0, CurBd = InstancePtr->FirstBdAddr;
		Index < InstancePtr->AllBdCnt;
		Index++, CurBd += InstancePtr->BdSeparation) {

		XAxiCdma_BdClone((XAxiCdma_Bd *)CurBd, &TmpBd);
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
 * This function clones all BDs in the BD ring to be the same as the given
 * BD.
 *
 * @param	InstancePtr is the driver instance we are working on
 * @param	TemplateBdPtr is the BD to be copied from
 *
 * @return
 *			- XST_SUCCESS for success
 *			- XST_DMA_SG_NO_LIST if there is no BD ring
 *			- XST_DEVICE_IS_STARTED if the hardware is running
 *			- XST_DMA_SG_LIST_ERROR is the BD ring is still in use
 *
 * @note	None.
 *
 *****************************************************************************/
This function clones all BDs in the BD ring to be the same as the given
BD.

@param       InstancePtr is the driver instance we are working on
@param       TemplateBdPtr is the BD to be copied from

@return
- XST_SUCCESS for success
- XST_DMA_SG_NO_LIST if there is no BD ring
- XST_DEVICE_IS_STARTED if the hardware is running
- XST_DMA_SG_LIST_ERROR is the BD ring is still in use

@note        None.
This function clones all BDs in the BD ring to be the same as the given BD . @param InstancePtr is the driver instance we are working on @param TemplateBdPtr is the BD to be copied from @return - XST_SUCCESS for success - XST_DMA_SG_NO_LIST if there is no BD ring - XST_DEVICE_IS_STARTED if the hardware is running - XST_DMA_SG_LIST_ERROR is the BD ring is still in use @note None .
LONG XAxiCdma_BdRingClone(XAxiCdma *InstancePtr, XAxiCdma_Bd * TemplateBdPtr)
{
	int Index;
	UINTPTR CurBd;
	XAxiCdma_Bd TmpBd;
	if (InstancePtr->AllBdCnt == 0) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: no bds\r\n");
		return XST_DMA_SG_NO_LIST;
	}
	if (XAxiCdma_IsBusy(InstancePtr)) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: engine is running, "
			"cannot do\r\n");
		return XST_DEVICE_IS_STARTED;
	}
	if (InstancePtr->FreeBdCnt != InstancePtr->AllBdCnt) {
		xdbg_printf(XDBG_DEBUG_ERROR,
		    "BdRingClone: some bds already in use %d/%d\r\n",
		    InstancePtr->FreeBdCnt, InstancePtr->AllBdCnt);
		return XST_DMA_SG_LIST_ERROR;
	}
	memcpy(&TmpBd, TemplateBdPtr, sizeof(XAxiCdma_Bd));
	XAxiCdma_BdClearSts(&TmpBd);
	for (Index = 0, CurBd = InstancePtr->FirstBdAddr;
		Index < InstancePtr->AllBdCnt;
		Index++, CurBd += InstancePtr->BdSeparation) {
		XAxiCdma_BdClone((XAxiCdma_Bd *)CurBd, &TmpBd);
	}
	return XST_SUCCESS;
}
LONG XAxiCdma_BdRingClone ( XAxiCdma * InstancePtr , XAxiCdma_Bd * TemplateBdPtr ) { int Index ; UINTPTR CurBd ; XAxiCdma_Bd TmpBd ; if ( InstancePtr -> AllBdCnt == 0 ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " ) ; return XST_DMA_SG_NO_LIST ; } if ( XAxiCdma_IsBusy ( InstancePtr ) ) { xdbg_printf ( XDBG_DEBUG_ERROR , " " " \r \n " ) ; return XST_DEVICE_IS_STARTED ; } if ( InstancePtr -> FreeBdCnt != InstancePtr -> AllBdCnt ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " , InstancePtr -> FreeBdCnt , InstancePtr -> AllBdCnt ) ; return XST_DMA_SG_LIST_ERROR ; } memcpy ( & TmpBd , TemplateBdPtr , sizeof ( XAxiCdma_Bd ) ) ; XAxiCdma_BdClearSts ( & TmpBd ) ; for ( Index = 0 , CurBd = InstancePtr -> FirstBdAddr ; Index < InstancePtr -> AllBdCnt ; Index ++ , CurBd += InstancePtr -> BdSeparation ) { XAxiCdma_BdClone ( ( XAxiCdma_Bd * ) CurBd , & TmpBd ) ; } return XST_SUCCESS ; }
This function clones all BDs in the BD ring to be the same as the given
 BD.
This function clones all BDs in the BD ring to be the same as the given BD .
/* Can't do this function if there isn't a ring */ /* Can't do this function with the channel running */ /* Can't do this function with some of the BDs in use */ /* Make a copy of the template then clear the status bits
	 */ /* Starting from the top of the ring, save BD.Next, BD.PhysAddr
	 * overwrite the entire BD with the template, then restore BD.Next
	 * and BD.PhysAddr
	 */