lib/sw_services/xilplmi/src/xplmi_generic.c
static int XPlmi_DmaXfer(XPlmi_Cmd *Cmd)
{
	int Status = XST_FAILURE;
	u64 DestAddr;
	u64 SrcAddr;
	u32 Len;
	u32 Flags;

	XPlmi_Printf(DEBUG_DETAILED, "%s \n\r", __func__);

	if (Cmd->ProcessedLen == 0U) {
		/* Store the command fields in resume data */
		Cmd->ResumeData[0U] = Cmd->Payload[0U];
		Cmd->ResumeData[1U] = Cmd->Payload[1U];
		Cmd->ResumeData[2U] = Cmd->Payload[2U];
		Cmd->ResumeData[3U] = Cmd->Payload[3U];
		Cmd->ResumeData[4U] = Cmd->Payload[4U];
		Cmd->ResumeData[5U] = Cmd->Payload[5U];
	}

	SrcAddr = (u64)Cmd->ResumeData[0U];
	SrcAddr = ((u64)Cmd->ResumeData[1U] | (SrcAddr << 32U));
	DestAddr = (u64)Cmd->ResumeData[2U];
	DestAddr = ((u64)Cmd->ResumeData[3U] | (DestAddr << 32U));
	DestAddr += ((u64)Cmd->ProcessedLen * XPLMI_WORD_LEN);
	Len = Cmd->ResumeData[4U];

	/* Set DMA flags to DMA0 */
	Flags = Cmd->ResumeData[5U] | XPLMI_PMCDMA_0;

	if (DestAddr == XPLMI_SBI_DEST_ADDR) {
		XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
			SLAVE_BOOT_SBI_MODE_SELECT_MASK,
			SLAVE_BOOT_SBI_MODE_SELECT_MASK);
		if ((Flags & XPLMI_DMA_SRC_NPI) == XPLMI_DMA_SRC_NPI) {
			Status = XPlmi_NpiRead(SrcAddr, DestAddr, Len);
		} else {
			Status = XPlmi_DmaSbiXfer(SrcAddr, Len,
					Cmd->ResumeData[5U] | XPLMI_PMCDMA_1);
		}
		if (Status != XST_SUCCESS) {
			XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
				SLAVE_BOOT_SBI_MODE_SELECT_MASK, 0U);
			goto END;
		}

		Status = XPlmi_UtilPoll(SLAVE_BOOT_SBI_STATUS,
				SLAVE_BOOT_SBI_STATUS_CMN_BUF_SPACE_MASK,
				SLAVE_BOOT_SBI_STATUS_CMN_BUF_SPACE_VAL,
				XPLMI_TIME_OUT_DEFAULT);
		if (Status != XST_SUCCESS) {
			XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
				SLAVE_BOOT_SBI_MODE_SELECT_MASK, 0U);
			goto END;
		}

		Status = XPlmi_UtilPoll(SLAVE_BOOT_SBI_STATUS,
				SLAVE_BOOT_SBI_STATUS_JTAG_DOUT_FIFO_SPACE_MASK,
				SLAVE_BOOT_SBI_STATUS_JTAG_DOUT_FIFO_SPACE_VAL,
				XPLMI_TIME_OUT_DEFAULT);
		XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
				SLAVE_BOOT_SBI_MODE_SELECT_MASK, 0U);
	} else {
		if ((Flags & XPLMI_DMA_SRC_NPI) == XPLMI_DMA_SRC_NPI) {
			Status = XPlmi_NpiRead(SrcAddr, DestAddr, Len);
		} else {
			Status = XPlmi_DmaXfr(SrcAddr, DestAddr, Len, Flags);
		}
	}
	if (Status != XST_SUCCESS) {
		XPlmi_Printf(DEBUG_GENERAL, "DMA XFER Failed\n\r");
	}

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function provides DMA Xfer command execution.
 *  		Command payload parameters are
 *		- High Src Addr
 *		- Low Src Addr
 *		- High Dest Addr
 *		- Low Dest Addr
 *		- Params - AXI burst type (Fixed/INCR)
 *
 * @param	Cmd is pointer to the command structure
 *
 * @return	XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function provides DMA Xfer command execution.

@param       Cmd is pointer to the command structure

@return      XST_SUCCESS on success and error code on failure
@brief This function provides DMA Xfer command execution . @param Cmd is pointer to the command structure @return XST_SUCCESS on success and error code on failure
static int XPlmi_DmaXfer(XPlmi_Cmd *Cmd)
{
	int Status = XST_FAILURE;
	u64 DestAddr;
	u64 SrcAddr;
	u32 Len;
	u32 Flags;
	XPlmi_Printf(DEBUG_DETAILED, "%s \n\r", __func__);
	if (Cmd->ProcessedLen == 0U) {
		Cmd->ResumeData[0U] = Cmd->Payload[0U];
		Cmd->ResumeData[1U] = Cmd->Payload[1U];
		Cmd->ResumeData[2U] = Cmd->Payload[2U];
		Cmd->ResumeData[3U] = Cmd->Payload[3U];
		Cmd->ResumeData[4U] = Cmd->Payload[4U];
		Cmd->ResumeData[5U] = Cmd->Payload[5U];
	}
	SrcAddr = (u64)Cmd->ResumeData[0U];
	SrcAddr = ((u64)Cmd->ResumeData[1U] | (SrcAddr << 32U));
	DestAddr = (u64)Cmd->ResumeData[2U];
	DestAddr = ((u64)Cmd->ResumeData[3U] | (DestAddr << 32U));
	DestAddr += ((u64)Cmd->ProcessedLen * XPLMI_WORD_LEN);
	Len = Cmd->ResumeData[4U];
	Flags = Cmd->ResumeData[5U] | XPLMI_PMCDMA_0;
	if (DestAddr == XPLMI_SBI_DEST_ADDR) {
		XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
			SLAVE_BOOT_SBI_MODE_SELECT_MASK,
			SLAVE_BOOT_SBI_MODE_SELECT_MASK);
		if ((Flags & XPLMI_DMA_SRC_NPI) == XPLMI_DMA_SRC_NPI) {
			Status = XPlmi_NpiRead(SrcAddr, DestAddr, Len);
		} else {
			Status = XPlmi_DmaSbiXfer(SrcAddr, Len,
					Cmd->ResumeData[5U] | XPLMI_PMCDMA_1);
		}
		if (Status != XST_SUCCESS) {
			XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
				SLAVE_BOOT_SBI_MODE_SELECT_MASK, 0U);
			goto END;
		}
		Status = XPlmi_UtilPoll(SLAVE_BOOT_SBI_STATUS,
				SLAVE_BOOT_SBI_STATUS_CMN_BUF_SPACE_MASK,
				SLAVE_BOOT_SBI_STATUS_CMN_BUF_SPACE_VAL,
				XPLMI_TIME_OUT_DEFAULT);
		if (Status != XST_SUCCESS) {
			XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
				SLAVE_BOOT_SBI_MODE_SELECT_MASK, 0U);
			goto END;
		}
		Status = XPlmi_UtilPoll(SLAVE_BOOT_SBI_STATUS,
				SLAVE_BOOT_SBI_STATUS_JTAG_DOUT_FIFO_SPACE_MASK,
				SLAVE_BOOT_SBI_STATUS_JTAG_DOUT_FIFO_SPACE_VAL,
				XPLMI_TIME_OUT_DEFAULT);
		XPlmi_UtilRMW(SLAVE_BOOT_SBI_MODE,
				SLAVE_BOOT_SBI_MODE_SELECT_MASK, 0U);
	} else {
		if ((Flags & XPLMI_DMA_SRC_NPI) == XPLMI_DMA_SRC_NPI) {
			Status = XPlmi_NpiRead(SrcAddr, DestAddr, Len);
		} else {
			Status = XPlmi_DmaXfr(SrcAddr, DestAddr, Len, Flags);
		}
	}
	if (Status != XST_SUCCESS) {
		XPlmi_Printf(DEBUG_GENERAL, "DMA XFER Failed\n\r");
	}
END:
	return Status;
}
static int XPlmi_DmaXfer ( XPlmi_Cmd * Cmd ) { int Status = XST_FAILURE ; u64 DestAddr ; u64 SrcAddr ; u32 Len ; u32 Flags ; XPlmi_Printf ( DEBUG_DETAILED , " \n \r " , __func__ ) ; if ( Cmd -> ProcessedLen == 0U ) { Cmd -> ResumeData [ 0U ] = Cmd -> Payload [ 0U ] ; Cmd -> ResumeData [ 1U ] = Cmd -> Payload [ 1U ] ; Cmd -> ResumeData [ 2U ] = Cmd -> Payload [ 2U ] ; Cmd -> ResumeData [ 3U ] = Cmd -> Payload [ 3U ] ; Cmd -> ResumeData [ 4U ] = Cmd -> Payload [ 4U ] ; Cmd -> ResumeData [ 5U ] = Cmd -> Payload [ 5U ] ; } SrcAddr = ( u64 ) Cmd -> ResumeData [ 0U ] ; SrcAddr = ( ( u64 ) Cmd -> ResumeData [ 1U ] | ( SrcAddr << 32U ) ) ; DestAddr = ( u64 ) Cmd -> ResumeData [ 2U ] ; DestAddr = ( ( u64 ) Cmd -> ResumeData [ 3U ] | ( DestAddr << 32U ) ) ; DestAddr += ( ( u64 ) Cmd -> ProcessedLen * XPLMI_WORD_LEN ) ; Len = Cmd -> ResumeData [ 4U ] ; Flags = Cmd -> ResumeData [ 5U ] | XPLMI_PMCDMA_0 ; if ( DestAddr == XPLMI_SBI_DEST_ADDR ) { XPlmi_UtilRMW ( SLAVE_BOOT_SBI_MODE , SLAVE_BOOT_SBI_MODE_SELECT_MASK , SLAVE_BOOT_SBI_MODE_SELECT_MASK ) ; if ( ( Flags & XPLMI_DMA_SRC_NPI ) == XPLMI_DMA_SRC_NPI ) { Status = XPlmi_NpiRead ( SrcAddr , DestAddr , Len ) ; } else { Status = XPlmi_DmaSbiXfer ( SrcAddr , Len , Cmd -> ResumeData [ 5U ] | XPLMI_PMCDMA_1 ) ; } if ( Status != XST_SUCCESS ) { XPlmi_UtilRMW ( SLAVE_BOOT_SBI_MODE , SLAVE_BOOT_SBI_MODE_SELECT_MASK , 0U ) ; goto END ; } Status = XPlmi_UtilPoll ( SLAVE_BOOT_SBI_STATUS , SLAVE_BOOT_SBI_STATUS_CMN_BUF_SPACE_MASK , SLAVE_BOOT_SBI_STATUS_CMN_BUF_SPACE_VAL , XPLMI_TIME_OUT_DEFAULT ) ; if ( Status != XST_SUCCESS ) { XPlmi_UtilRMW ( SLAVE_BOOT_SBI_MODE , SLAVE_BOOT_SBI_MODE_SELECT_MASK , 0U ) ; goto END ; } Status = XPlmi_UtilPoll ( SLAVE_BOOT_SBI_STATUS , SLAVE_BOOT_SBI_STATUS_JTAG_DOUT_FIFO_SPACE_MASK , SLAVE_BOOT_SBI_STATUS_JTAG_DOUT_FIFO_SPACE_VAL , XPLMI_TIME_OUT_DEFAULT ) ; XPlmi_UtilRMW ( SLAVE_BOOT_SBI_MODE , SLAVE_BOOT_SBI_MODE_SELECT_MASK , 0U ) ; } else { if ( ( Flags & XPLMI_DMA_SRC_NPI ) == XPLMI_DMA_SRC_NPI ) { Status = XPlmi_NpiRead ( SrcAddr , DestAddr , Len ) ; } else { Status = XPlmi_DmaXfr ( SrcAddr , DestAddr , Len , Flags ) ; } } if ( Status != XST_SUCCESS ) { XPlmi_Printf ( DEBUG_GENERAL , " \n \r " ) ; } END : return Status ; }
@brief       This function provides DMA Xfer command execution.
@brief This function provides DMA Xfer command execution .
/* Store the command fields in resume data */ /* Set DMA flags to DMA0 */