XilinxProcessorIPLib/drivers/axicdma/src/xaxicdma_bdring.c
u32 XAxiCdma_BdRingCntCalc(u32 Alignment, u32 Bytes, UINTPTR BdBuffAddr)
{

	/* The buffer alignment has to be taken account of. An unaligned buffer
	 * is invalid.
	 */
	if (BdBuffAddr & Alignment) {
		xdbg_printf(XDBG_DEBUG_ERROR, "Invalid buffer addr %x\r\n",
			(unsigned int)BdBuffAddr);
		return 0;
	}

	return ((uint32_t)(Bytes) / ((sizeof(XAxiCdma_Bd) + (Alignment - 1)) &
               ~(Alignment - 1)));
}
/*****************************************************************************/
/**
 * This function calculates how many BDs can be built using given number of
 * bytes of memory, according to alignment provided.
 *
 * @param	Alignment is the preferred alignment for the BDs
 * @param	Bytes is the number of bytes of memory to build BDs with
 * @param	BdBuffAddr is the buffer address allocated for the BDs. This
 *			is to check the alignment of the buffer to make sure the the
 *			buffer is aligned to the BD alignment. An invalid buffer
 *			address results in 0.
 *
 * @return	The number of BDs can be built. 0 means buffer address
 *			is not valid.
 *
 * @note	The application is responsible to align the buffer before pass
 *			it to this function.
 *
 *****************************************************************************/
This function calculates how many BDs can be built using given number of
bytes of memory, according to alignment provided.

@param       Alignment is the preferred alignment for the BDs
@param       Bytes is the number of bytes of memory to build BDs with
@param       BdBuffAddr is the buffer address allocated for the BDs. This
is to check the alignment of the buffer to make sure the the
buffer is aligned to the BD alignment. An invalid buffer
address results in 0.

@return      The number of BDs can be built. 0 means buffer address
is not valid.

@note        The application is responsible to align the buffer before pass
it to this function.
This function calculates how many BDs can be built using given number of bytes of memory according to alignment provided . @param Alignment is the preferred alignment for the BDs @param Bytes is the number of bytes of memory to build BDs with @param BdBuffAddr is the buffer address allocated for the BDs . This is to check the alignment of the buffer to make sure the the buffer is aligned to the BD alignment . An invalid buffer address results in 0 . @return The number of BDs can be built . 0 means buffer address is not valid . @note The application is responsible to align the buffer before pass it to this function .
u32 XAxiCdma_BdRingCntCalc(u32 Alignment, u32 Bytes, UINTPTR BdBuffAddr)
{
	if (BdBuffAddr & Alignment) {
		xdbg_printf(XDBG_DEBUG_ERROR, "Invalid buffer addr %x\r\n",
			(unsigned int)BdBuffAddr);
		return 0;
	}
	return ((uint32_t)(Bytes) / ((sizeof(XAxiCdma_Bd) + (Alignment - 1)) &
               ~(Alignment - 1)));
}
u32 XAxiCdma_BdRingCntCalc ( u32 Alignment , u32 Bytes , UINTPTR BdBuffAddr ) { if ( BdBuffAddr & Alignment ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " , ( unsigned int ) BdBuffAddr ) ; return 0 ; } return ( ( uint32_t ) ( Bytes ) / ( ( sizeof ( XAxiCdma_Bd ) + ( Alignment - 1 ) ) & ~ ( Alignment - 1 ) ) ) ; }
This function calculates how many BDs can be built using given number of
 bytes of memory, according to alignment provided.
This function calculates how many BDs can be built using given number of bytes of memory according to alignment provided .
/* The buffer alignment has to be taken account of. An unaligned buffer
	 * is invalid.
	 */