lib/sw_services/xilplmi/src/xplmi_dma.c
static int XPlmi_DmaChXfer(u64 Addr, u32 Len, XPmcDma_Channel Channel, u32 Flags)
{
	int Status = XST_FAILURE;
	XPmcDma *DmaPtr;

	/* Select DMA pointer */
	if ((Flags & XPLMI_PMCDMA_0) == XPLMI_PMCDMA_0) {
		XPlmi_Printf(DEBUG_INFO, "PMCDMA0\n\r");
		DmaPtr = &PmcDma0;
	} else {
		XPlmi_Printf(DEBUG_INFO, "PMCDMA1\n\r");
		DmaPtr = &PmcDma1;
	}

	/* Setting PMC_DMA in AXI FIXED mode */
	if (((Channel == XPMCDMA_DST_CHANNEL) &&
		((Flags & XPLMI_DST_CH_AXI_FIXED) == XPLMI_DST_CH_AXI_FIXED)) ||
		((Channel == XPMCDMA_SRC_CHANNEL) &&
		((Flags & XPLMI_SRC_CH_AXI_FIXED) == XPLMI_SRC_CH_AXI_FIXED))) {
		DmaCtrl.AxiBurstType = 1U;
		XPmcDma_SetConfig(DmaPtr, Channel, &DmaCtrl);
	}

	XPmcDma_64BitTransfer(DmaPtr, Channel , (u32)(Addr),
		(u32)(Addr >> 32U), Len, 0U);

	if (((Flags & XPLMI_DMA_SRC_NONBLK) != 0U) ||
		((Flags & XPLMI_DMA_DST_NONBLK) != 0U)) {
		Status = XST_SUCCESS;
		goto END;
	}

	/* Polling for transfer to be done */
	if ((Addr >= XPLMI_PMC_ALIAS1_BASEADDR) &&
		(Addr < XPLMI_PMC_ALIAS_MAX_ADDR)) {
		/*
		 * Call XPlmi_SsitWaitForDmaDone() if DMA transfer is to
		 * SSIT Slave SLRs
		 */
		Status = XPlmi_SsitWaitForDmaDone(DmaPtr, Channel);
	} else {
		Status = XPmcDma_WaitForDone(DmaPtr, Channel);
	}
	if (Status != XST_SUCCESS) {
		Status = XPlmi_UpdateStatus(XPLMI_ERR_DMA_XFER_WAIT, 0);
		goto END;
	}

	/* To acknowledge the transfer has completed */
	XPmcDma_IntrClear(DmaPtr, Channel, XPMCDMA_IXR_DONE_MASK);

	/* Revert the setting of PMC_DMA in AXI FIXED mode */
	if (((Channel == XPMCDMA_DST_CHANNEL) &&
		((Flags & XPLMI_DST_CH_AXI_FIXED) == XPLMI_DST_CH_AXI_FIXED)) ||
		((Channel == XPMCDMA_SRC_CHANNEL) &&
		((Flags & XPLMI_SRC_CH_AXI_FIXED) == XPLMI_SRC_CH_AXI_FIXED))) {
		DmaCtrl.AxiBurstType = 0U;
		XPmcDma_SetConfig(DmaPtr, Channel, &DmaCtrl);
	}

	Status = XST_SUCCESS;
END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function is used transfer the data on SRC or DST channel.
 *
 * @param 	Addr is address to which data has to be stored
 * @param	Len is length of the data in bytes
 * @param	Channel is SRC/DST channel selection
 * @param	Flags to select PMC DMA and DMA Burst type
 *
 * @return	XST_SUCCESS on success and error codes on failure
 *
 *****************************************************************************/
@brief       This function is used transfer the data on SRC or DST channel.
@param       Addr is address to which data has to be stored
@param       Len is length of the data in bytes
@param       Channel is SRC/DST channel selection
@param       Flags to select PMC DMA and DMA Burst type

@return      XST_SUCCESS on success and error codes on failure
@brief This function is used transfer the data on SRC or DST channel . @param Addr is address to which data has to be stored @param Len is length of the data in bytes @param Channel is SRC / DST channel selection @param Flags to select PMC DMA and DMA Burst type @return XST_SUCCESS on success and error codes on failure
static int XPlmi_DmaChXfer(u64 Addr, u32 Len, XPmcDma_Channel Channel, u32 Flags)
{
	int Status = XST_FAILURE;
	XPmcDma *DmaPtr;
	if ((Flags & XPLMI_PMCDMA_0) == XPLMI_PMCDMA_0) {
		XPlmi_Printf(DEBUG_INFO, "PMCDMA0\n\r");
		DmaPtr = &PmcDma0;
	} else {
		XPlmi_Printf(DEBUG_INFO, "PMCDMA1\n\r");
		DmaPtr = &PmcDma1;
	}
	if (((Channel == XPMCDMA_DST_CHANNEL) &&
		((Flags & XPLMI_DST_CH_AXI_FIXED) == XPLMI_DST_CH_AXI_FIXED)) ||
		((Channel == XPMCDMA_SRC_CHANNEL) &&
		((Flags & XPLMI_SRC_CH_AXI_FIXED) == XPLMI_SRC_CH_AXI_FIXED))) {
		DmaCtrl.AxiBurstType = 1U;
		XPmcDma_SetConfig(DmaPtr, Channel, &DmaCtrl);
	}
	XPmcDma_64BitTransfer(DmaPtr, Channel , (u32)(Addr),
		(u32)(Addr >> 32U), Len, 0U);
	if (((Flags & XPLMI_DMA_SRC_NONBLK) != 0U) ||
		((Flags & XPLMI_DMA_DST_NONBLK) != 0U)) {
		Status = XST_SUCCESS;
		goto END;
	}
	if ((Addr >= XPLMI_PMC_ALIAS1_BASEADDR) &&
		(Addr < XPLMI_PMC_ALIAS_MAX_ADDR)) {
		Status = XPlmi_SsitWaitForDmaDone(DmaPtr, Channel);
	} else {
		Status = XPmcDma_WaitForDone(DmaPtr, Channel);
	}
	if (Status != XST_SUCCESS) {
		Status = XPlmi_UpdateStatus(XPLMI_ERR_DMA_XFER_WAIT, 0);
		goto END;
	}
	XPmcDma_IntrClear(DmaPtr, Channel, XPMCDMA_IXR_DONE_MASK);
	if (((Channel == XPMCDMA_DST_CHANNEL) &&
		((Flags & XPLMI_DST_CH_AXI_FIXED) == XPLMI_DST_CH_AXI_FIXED)) ||
		((Channel == XPMCDMA_SRC_CHANNEL) &&
		((Flags & XPLMI_SRC_CH_AXI_FIXED) == XPLMI_SRC_CH_AXI_FIXED))) {
		DmaCtrl.AxiBurstType = 0U;
		XPmcDma_SetConfig(DmaPtr, Channel, &DmaCtrl);
	}
	Status = XST_SUCCESS;
END:
	return Status;
}
static int XPlmi_DmaChXfer ( u64 Addr , u32 Len , XPmcDma_Channel Channel , u32 Flags ) { int Status = XST_FAILURE ; XPmcDma * DmaPtr ; if ( ( Flags & XPLMI_PMCDMA_0 ) == XPLMI_PMCDMA_0 ) { XPlmi_Printf ( DEBUG_INFO , " \n \r " ) ; DmaPtr = & PmcDma0 ; } else { XPlmi_Printf ( DEBUG_INFO , " \n \r " ) ; DmaPtr = & PmcDma1 ; } if ( ( ( Channel == XPMCDMA_DST_CHANNEL ) && ( ( Flags & XPLMI_DST_CH_AXI_FIXED ) == XPLMI_DST_CH_AXI_FIXED ) ) || ( ( Channel == XPMCDMA_SRC_CHANNEL ) && ( ( Flags & XPLMI_SRC_CH_AXI_FIXED ) == XPLMI_SRC_CH_AXI_FIXED ) ) ) { DmaCtrl . AxiBurstType = 1U ; XPmcDma_SetConfig ( DmaPtr , Channel , & DmaCtrl ) ; } XPmcDma_64BitTransfer ( DmaPtr , Channel , ( u32 ) ( Addr ) , ( u32 ) ( Addr >> 32U ) , Len , 0U ) ; if ( ( ( Flags & XPLMI_DMA_SRC_NONBLK ) != 0U ) || ( ( Flags & XPLMI_DMA_DST_NONBLK ) != 0U ) ) { Status = XST_SUCCESS ; goto END ; } if ( ( Addr >= XPLMI_PMC_ALIAS1_BASEADDR ) && ( Addr < XPLMI_PMC_ALIAS_MAX_ADDR ) ) { Status = XPlmi_SsitWaitForDmaDone ( DmaPtr , Channel ) ; } else { Status = XPmcDma_WaitForDone ( DmaPtr , Channel ) ; } if ( Status != XST_SUCCESS ) { Status = XPlmi_UpdateStatus ( XPLMI_ERR_DMA_XFER_WAIT , 0 ) ; goto END ; } XPmcDma_IntrClear ( DmaPtr , Channel , XPMCDMA_IXR_DONE_MASK ) ; if ( ( ( Channel == XPMCDMA_DST_CHANNEL ) && ( ( Flags & XPLMI_DST_CH_AXI_FIXED ) == XPLMI_DST_CH_AXI_FIXED ) ) || ( ( Channel == XPMCDMA_SRC_CHANNEL ) && ( ( Flags & XPLMI_SRC_CH_AXI_FIXED ) == XPLMI_SRC_CH_AXI_FIXED ) ) ) { DmaCtrl . AxiBurstType = 0U ; XPmcDma_SetConfig ( DmaPtr , Channel , & DmaCtrl ) ; } Status = XST_SUCCESS ; END : return Status ; }
@brief       This function is used transfer the data on SRC or DST channel.
@brief This function is used transfer the data on SRC or DST channel .
/* Select DMA pointer */ /* Setting PMC_DMA in AXI FIXED mode */ /* Polling for transfer to be done */ /*
		 * Call XPlmi_SsitWaitForDmaDone() if DMA transfer is to
		 * SSIT Slave SLRs
		 */ /* To acknowledge the transfer has completed */ /* Revert the setting of PMC_DMA in AXI FIXED mode */