XStatus
XDmaChannel_SelfTest(XDmaChannel * InstancePtr)
{
	u32 ControlReg;

	/* assert to verify input arguments */

	XASSERT_NONVOID(InstancePtr != NULL);
	XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);

	/* reset the DMA channel such that it's in a known state before the test
	 * it resets to no interrupts enabled, the desired state for the test
	 */
	XDmaChannel_Reset(InstancePtr);

	/* this should be the first test to help prevent a lock up with the polling
	 * loop that occurs later in the test, check the reset value of the DMA
	 * control register to make sure it's correct, return with an error if not
	 */
	ControlReg = XDmaChannel_GetControl(InstancePtr);
	if (ControlReg != XDC_CONTROL_REG_RESET_MASK) {
		return XST_DMA_RESET_REGISTER_ERROR;
	}

	return XST_SUCCESS;
}
示例#2
0
/**
*
* This function initializes a DMA channel.  This function must be called
* prior to using a DMA channel.  Initialization of a channel includes setting
* up the registers base address, and resetting the channel such that it's in a
* known state.  Interrupts for the channel are disabled when the channel is
* reset.
*
* @param
*
* InstancePtr contains a pointer to the DMA channel to operate on.
*
* @param
*
* BaseAddress contains the base address of the registers for the DMA channel.
*
* @return
*
* XST_SUCCESS indicating initialization was successful.
*
* @note
*
* None.
*
******************************************************************************/
XStatus XDmaChannel_Initialize(XDmaChannel * InstancePtr, u32 BaseAddress)
{
	/* assert to verify input arguments, don't assert base address */

	XASSERT_NONVOID(InstancePtr != NULL);

	/* setup the base address of the registers for the DMA channel such
	 * that register accesses can be done
	 */
	InstancePtr->RegBaseAddress = BaseAddress;

	/* initialize the scatter gather list such that it indicates it has not
	 * been created yet and the DMA channel is ready to use (initialized)
	 */
	InstancePtr->GetPtr = NULL;
	InstancePtr->PutPtr = NULL;
	InstancePtr->CommitPtr = NULL;
	InstancePtr->LastPtr = NULL;

	InstancePtr->TotalDescriptorCount = 0;
	InstancePtr->ActiveDescriptorCount = 0;

	InstancePtr->ActivePacketCount = 0;
	InstancePtr->Committed = FALSE;

	InstancePtr->IsReady = XCOMPONENT_IS_READY;

	/* initialize the version of the component
	 */
	XVersion_FromString(&InstancePtr->Version, "1.00a");

	/* reset the DMA channel such that it's in a known state and ready
	 * and indicate the initialization occurred with no errors, note that
	 * the is ready variable must be set before this call or reset will assert
	 */
	XDmaChannel_Reset(InstancePtr);

	return XST_SUCCESS;
}