lib/sw_services/xilplmi/src/xplmi_generic.c
static int XPlmi_KeyHoleXfr(XPlmi_KeyHoleXfrParams* KeyHoleXfrParams)
{
	int Status = XST_FAILURE;
	u32 LenTemp = (u32)(((u64)KeyHoleXfrParams->Keyholesize + KeyHoleXfrParams->BaseAddr)
		- KeyHoleXfrParams->DestAddr);

	if (LenTemp > KeyHoleXfrParams->Len) {
		LenTemp = KeyHoleXfrParams->Len;
	}

	if (LenTemp == 0U) {
		Status = XST_SUCCESS;
		goto END;
	}

	if (KeyHoleXfrParams->Func == NULL) {
		Status = XPlmi_DmaXfr(KeyHoleXfrParams->SrcAddr,
			KeyHoleXfrParams->DestAddr, LenTemp / XPLMI_WORD_LEN,
			KeyHoleXfrParams->Flags);
	}
	else {
		Status = KeyHoleXfrParams->Func(KeyHoleXfrParams->SrcAddr,
			KeyHoleXfrParams->DestAddr, LenTemp, KeyHoleXfrParams->Flags);
	}
	if (Status != XST_SUCCESS) {
		goto END;
	}
	KeyHoleXfrParams->SrcAddr += LenTemp;
	KeyHoleXfrParams->Len -= LenTemp;
	if (KeyHoleXfrParams->Len == 0U) {
		KeyHoleXfrParams->DestAddr += LenTemp;
		goto END;
	}

	KeyHoleXfrParams->DestAddr = KeyHoleXfrParams->BaseAddr;

	while (KeyHoleXfrParams->Len > 0U) {
		LenTemp = KeyHoleXfrParams->Keyholesize;
		if (LenTemp > KeyHoleXfrParams->Len) {
			LenTemp = KeyHoleXfrParams->Len;
		}

		if (KeyHoleXfrParams->Func == NULL) {
			Status = XPlmi_DmaXfr(KeyHoleXfrParams->SrcAddr,
				KeyHoleXfrParams->BaseAddr,
				LenTemp / XPLMI_WORD_LEN, KeyHoleXfrParams->Flags);
		}
		else {
			Status = KeyHoleXfrParams->Func(KeyHoleXfrParams->SrcAddr,
				KeyHoleXfrParams->BaseAddr, LenTemp, KeyHoleXfrParams->Flags);
		}
		if (Status != XST_SUCCESS) {
			goto END;
		}
		KeyHoleXfrParams->Len -= LenTemp;
		KeyHoleXfrParams->SrcAddr +=LenTemp;
	}
	if (LenTemp < KeyHoleXfrParams->Keyholesize) {
		KeyHoleXfrParams->DestAddr += LenTemp;
	}

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function provides DMA transfer to CFI in chunks of
 * Keyholesize.
 *
 * @param	KeyHoleXfrParams is a pointer to instance of CfiParams structure
 *
 * @return	XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function provides DMA transfer to CFI in chunks of
Keyholesize.

@param       KeyHoleXfrParams is a pointer to instance of CfiParams structure

@return      XST_SUCCESS on success and error code on failure
@brief This function provides DMA transfer to CFI in chunks of Keyholesize . @param KeyHoleXfrParams is a pointer to instance of CfiParams structure @return XST_SUCCESS on success and error code on failure
static int XPlmi_KeyHoleXfr(XPlmi_KeyHoleXfrParams* KeyHoleXfrParams)
{
	int Status = XST_FAILURE;
	u32 LenTemp = (u32)(((u64)KeyHoleXfrParams->Keyholesize + KeyHoleXfrParams->BaseAddr)
		- KeyHoleXfrParams->DestAddr);
	if (LenTemp > KeyHoleXfrParams->Len) {
		LenTemp = KeyHoleXfrParams->Len;
	}
	if (LenTemp == 0U) {
		Status = XST_SUCCESS;
		goto END;
	}
	if (KeyHoleXfrParams->Func == NULL) {
		Status = XPlmi_DmaXfr(KeyHoleXfrParams->SrcAddr,
			KeyHoleXfrParams->DestAddr, LenTemp / XPLMI_WORD_LEN,
			KeyHoleXfrParams->Flags);
	}
	else {
		Status = KeyHoleXfrParams->Func(KeyHoleXfrParams->SrcAddr,
			KeyHoleXfrParams->DestAddr, LenTemp, KeyHoleXfrParams->Flags);
	}
	if (Status != XST_SUCCESS) {
		goto END;
	}
	KeyHoleXfrParams->SrcAddr += LenTemp;
	KeyHoleXfrParams->Len -= LenTemp;
	if (KeyHoleXfrParams->Len == 0U) {
		KeyHoleXfrParams->DestAddr += LenTemp;
		goto END;
	}
	KeyHoleXfrParams->DestAddr = KeyHoleXfrParams->BaseAddr;
	while (KeyHoleXfrParams->Len > 0U) {
		LenTemp = KeyHoleXfrParams->Keyholesize;
		if (LenTemp > KeyHoleXfrParams->Len) {
			LenTemp = KeyHoleXfrParams->Len;
		}
		if (KeyHoleXfrParams->Func == NULL) {
			Status = XPlmi_DmaXfr(KeyHoleXfrParams->SrcAddr,
				KeyHoleXfrParams->BaseAddr,
				LenTemp / XPLMI_WORD_LEN, KeyHoleXfrParams->Flags);
		}
		else {
			Status = KeyHoleXfrParams->Func(KeyHoleXfrParams->SrcAddr,
				KeyHoleXfrParams->BaseAddr, LenTemp, KeyHoleXfrParams->Flags);
		}
		if (Status != XST_SUCCESS) {
			goto END;
		}
		KeyHoleXfrParams->Len -= LenTemp;
		KeyHoleXfrParams->SrcAddr +=LenTemp;
	}
	if (LenTemp < KeyHoleXfrParams->Keyholesize) {
		KeyHoleXfrParams->DestAddr += LenTemp;
	}
END:
	return Status;
}
static int XPlmi_KeyHoleXfr ( XPlmi_KeyHoleXfrParams * KeyHoleXfrParams ) { int Status = XST_FAILURE ; u32 LenTemp = ( u32 ) ( ( ( u64 ) KeyHoleXfrParams -> Keyholesize + KeyHoleXfrParams -> BaseAddr ) - KeyHoleXfrParams -> DestAddr ) ; if ( LenTemp > KeyHoleXfrParams -> Len ) { LenTemp = KeyHoleXfrParams -> Len ; } if ( LenTemp == 0U ) { Status = XST_SUCCESS ; goto END ; } if ( KeyHoleXfrParams -> Func == NULL ) { Status = XPlmi_DmaXfr ( KeyHoleXfrParams -> SrcAddr , KeyHoleXfrParams -> DestAddr , LenTemp / XPLMI_WORD_LEN , KeyHoleXfrParams -> Flags ) ; } else { Status = KeyHoleXfrParams -> Func ( KeyHoleXfrParams -> SrcAddr , KeyHoleXfrParams -> DestAddr , LenTemp , KeyHoleXfrParams -> Flags ) ; } if ( Status != XST_SUCCESS ) { goto END ; } KeyHoleXfrParams -> SrcAddr += LenTemp ; KeyHoleXfrParams -> Len -= LenTemp ; if ( KeyHoleXfrParams -> Len == 0U ) { KeyHoleXfrParams -> DestAddr += LenTemp ; goto END ; } KeyHoleXfrParams -> DestAddr = KeyHoleXfrParams -> BaseAddr ; while ( KeyHoleXfrParams -> Len > 0U ) { LenTemp = KeyHoleXfrParams -> Keyholesize ; if ( LenTemp > KeyHoleXfrParams -> Len ) { LenTemp = KeyHoleXfrParams -> Len ; } if ( KeyHoleXfrParams -> Func == NULL ) { Status = XPlmi_DmaXfr ( KeyHoleXfrParams -> SrcAddr , KeyHoleXfrParams -> BaseAddr , LenTemp / XPLMI_WORD_LEN , KeyHoleXfrParams -> Flags ) ; } else { Status = KeyHoleXfrParams -> Func ( KeyHoleXfrParams -> SrcAddr , KeyHoleXfrParams -> BaseAddr , LenTemp , KeyHoleXfrParams -> Flags ) ; } if ( Status != XST_SUCCESS ) { goto END ; } KeyHoleXfrParams -> Len -= LenTemp ; KeyHoleXfrParams -> SrcAddr += LenTemp ; } if ( LenTemp < KeyHoleXfrParams -> Keyholesize ) { KeyHoleXfrParams -> DestAddr += LenTemp ; } END : return Status ; }
@brief       This function provides DMA transfer to CFI in chunks of
 Keyholesize.
@brief This function provides DMA transfer to CFI in chunks of Keyholesize .