XilinxProcessorIPLib/drivers/axidma/src/xaxidma_bdring.c
int XAxiDma_BdRingClone(XAxiDma_BdRing * RingPtr, XAxiDma_Bd * SrcBdPtr)
{
	int i;
	UINTPTR CurBd;
	u32 Save;
	XAxiDma_Bd TmpBd;

	/* Can't do this function if there isn't a ring */
	if (RingPtr->AllCnt == 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 (RingPtr->RunState == AXIDMA_CHANNEL_NOT_HALTED) {

		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: bd ring started "
			"already, cannot do\r\n");

		return XST_DEVICE_IS_STARTED;
	}

	/* Can't do this function with some of the BDs in use */
	if (RingPtr->FreeCnt != RingPtr->AllCnt) {

		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: some bds already "
			"in use %d/%d\r\n",RingPtr->FreeCnt, RingPtr->AllCnt);

		return XST_DMA_SG_LIST_ERROR;
	}

	/* Make a copy of the template then modify it by clearing
	 * the complete bit in status/control field
	 */
	memcpy(&TmpBd, SrcBdPtr, sizeof(XAxiDma_Bd));

	Save = XAxiDma_BdRead(&TmpBd, XAXIDMA_BD_STS_OFFSET);
	Save &= ~XAXIDMA_BD_STS_COMPLETE_MASK;
	XAxiDma_BdWrite(&TmpBd, XAXIDMA_BD_STS_OFFSET, Save);

	for (i = 0, CurBd = RingPtr->FirstBdAddr;
	     i < RingPtr->AllCnt; i++, CurBd += RingPtr->Separation) {

		memcpy((void *)((UINTPTR)CurBd + XAXIDMA_BD_START_CLEAR),
		    (void *)((UINTPTR)(&TmpBd) + XAXIDMA_BD_START_CLEAR),
		    XAXIDMA_BD_BYTES_TO_CLEAR);

		XAXIDMA_CACHE_FLUSH(CurBd);
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
 * Clone the given BD into every BD in the ring. Only the fields offset from
 * XAXIDMA_BD_START_CLEAR are copied, for XAXIDMA_BD_BYTES_TO_CLEAR bytes.
 * This covers: BufferAddr, Control/Buffer length, status, APP words 0 - 4,
 * and software ID fields.
 *
 * This function can be called only when all BDs are in the free group such as
 * immediately after creation of the ring. This prevents modification
 * of BDs while they are in use by hardware or the application.
 *
 * @param	RingPtr is the BD ring instance to be worked on.
 * @param	SrcBdPtr is the source BD template to be cloned into the list.
 *
 * @return
 *		- XST_SUCCESS if the list was modified.
 *		- XST_DMA_SG_NO_LIST if a list has not been created.
 *		- XST_DEVICE_IS_STARTED if the DMA channel has not been stopped.
 *		- XST_DMA_SG_LIST_ERROR if some of the BDs in this channel are
 *		under hardware or application control.
 *
 * @note	This function can be used only when DMA is in SG mode
 *
 *****************************************************************************/
Clone the given BD into every BD in the ring. Only the fields offset from
XAXIDMA_BD_START_CLEAR are copied, for XAXIDMA_BD_BYTES_TO_CLEAR bytes.
This covers: BufferAddr, Control/Buffer length, status, APP words 0 - 4,
and software ID fields.

This function can be called only when all BDs are in the free group such as
immediately after creation of the ring. This prevents modification
of BDs while they are in use by hardware or the application.

@param       RingPtr is the BD ring instance to be worked on.
@param       SrcBdPtr is the source BD template to be cloned into the list.

@return
- XST_SUCCESS if the list was modified.
- XST_DMA_SG_NO_LIST if a list has not been created.
- XST_DEVICE_IS_STARTED if the DMA channel has not been stopped.
- XST_DMA_SG_LIST_ERROR if some of the BDs in this channel are
under hardware or application control.

@note        This function can be used only when DMA is in SG mode
Clone the given BD into every BD in the ring . Only the fields offset from XAXIDMA_BD_START_CLEAR are copied for XAXIDMA_BD_BYTES_TO_CLEAR bytes . This covers : BufferAddr Control / Buffer length status APP words 0 - 4 and software ID fields . This function can be called only when all BDs are in the free group such as immediately after creation of the ring . This prevents modification of BDs while they are in use by hardware or the application . @param RingPtr is the BD ring instance to be worked on . @param SrcBdPtr is the source BD template to be cloned into the list . @return - XST_SUCCESS if the list was modified . - XST_DMA_SG_NO_LIST if a list has not been created . - XST_DEVICE_IS_STARTED if the DMA channel has not been stopped . - XST_DMA_SG_LIST_ERROR if some of the BDs in this channel are under hardware or application control . @note This function can be used only when DMA is in SG mode
int XAxiDma_BdRingClone(XAxiDma_BdRing * RingPtr, XAxiDma_Bd * SrcBdPtr)
{
	int i;
	UINTPTR CurBd;
	u32 Save;
	XAxiDma_Bd TmpBd;
	if (RingPtr->AllCnt == 0) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: no bds\r\n");
		return XST_DMA_SG_NO_LIST;
	}
	if (RingPtr->RunState == AXIDMA_CHANNEL_NOT_HALTED) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: bd ring started "
			"already, cannot do\r\n");
		return XST_DEVICE_IS_STARTED;
	}
	if (RingPtr->FreeCnt != RingPtr->AllCnt) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingClone: some bds already "
			"in use %d/%d\r\n",RingPtr->FreeCnt, RingPtr->AllCnt);
		return XST_DMA_SG_LIST_ERROR;
	}
	memcpy(&TmpBd, SrcBdPtr, sizeof(XAxiDma_Bd));
	Save = XAxiDma_BdRead(&TmpBd, XAXIDMA_BD_STS_OFFSET);
	Save &= ~XAXIDMA_BD_STS_COMPLETE_MASK;
	XAxiDma_BdWrite(&TmpBd, XAXIDMA_BD_STS_OFFSET, Save);
	for (i = 0, CurBd = RingPtr->FirstBdAddr;
	     i < RingPtr->AllCnt; i++, CurBd += RingPtr->Separation) {
		memcpy((void *)((UINTPTR)CurBd + XAXIDMA_BD_START_CLEAR),
		    (void *)((UINTPTR)(&TmpBd) + XAXIDMA_BD_START_CLEAR),
		    XAXIDMA_BD_BYTES_TO_CLEAR);
		XAXIDMA_CACHE_FLUSH(CurBd);
	}
	return XST_SUCCESS;
}
int XAxiDma_BdRingClone ( XAxiDma_BdRing * RingPtr , XAxiDma_Bd * SrcBdPtr ) { int i ; UINTPTR CurBd ; u32 Save ; XAxiDma_Bd TmpBd ; if ( RingPtr -> AllCnt == 0 ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " ) ; return XST_DMA_SG_NO_LIST ; } if ( RingPtr -> RunState == AXIDMA_CHANNEL_NOT_HALTED ) { xdbg_printf ( XDBG_DEBUG_ERROR , " " " \r \n " ) ; return XST_DEVICE_IS_STARTED ; } if ( RingPtr -> FreeCnt != RingPtr -> AllCnt ) { xdbg_printf ( XDBG_DEBUG_ERROR , " " " \r \n " , RingPtr -> FreeCnt , RingPtr -> AllCnt ) ; return XST_DMA_SG_LIST_ERROR ; } memcpy ( & TmpBd , SrcBdPtr , sizeof ( XAxiDma_Bd ) ) ; Save = XAxiDma_BdRead ( & TmpBd , XAXIDMA_BD_STS_OFFSET ) ; Save &= ~ XAXIDMA_BD_STS_COMPLETE_MASK ; XAxiDma_BdWrite ( & TmpBd , XAXIDMA_BD_STS_OFFSET , Save ) ; for ( i = 0 , CurBd = RingPtr -> FirstBdAddr ; i < RingPtr -> AllCnt ; i ++ , CurBd += RingPtr -> Separation ) { memcpy ( ( void * ) ( ( UINTPTR ) CurBd + XAXIDMA_BD_START_CLEAR ) , ( void * ) ( ( UINTPTR ) ( & TmpBd ) + XAXIDMA_BD_START_CLEAR ) , XAXIDMA_BD_BYTES_TO_CLEAR ) ; XAXIDMA_CACHE_FLUSH ( CurBd ) ; } return XST_SUCCESS ; }
Clone the given BD into every BD in the ring.
Clone the given BD into every BD in the ring .
/* 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 modify it by clearing
	 * the complete bit in status/control field
	 */