lib/sw_services/xilplmi/src/xplmi_generic.c
static int XPlmi_DmaUnalignedXfer(u64* SrcAddr, u64* DestAddr, u32* Len,
	u8 Flag)
{
	int Status = XST_FAILURE;
	u32 RegVal;
	u8 Offset;
	u8 Count;

	if (Flag == XPLMI_SRC_ALIGN_REQ) {
		Offset = (u8)(XPLMI_WORD_LEN -
			(((*SrcAddr) & XPLMI_SIXTEEN_BYTE_MASK) / XPLMI_WORD_LEN));
		Count = Offset % XPLMI_WORD_LEN;
	}
	else if (Flag == XPLMI_DEST_ALIGN_REQ) {
		Offset = (u8)(XPLMI_WORD_LEN -
			(((*DestAddr) & XPLMI_SIXTEEN_BYTE_MASK) / XPLMI_WORD_LEN));
		Count = Offset % XPLMI_WORD_LEN;
	}
	else if (Flag == XPLMI_LEN_ALIGN_REQ) {
		Count = (u8)((*Len) % XPLMI_WORD_LEN);
	}
	else {
		goto END;
	}

	if (Count > *Len) {
		Count = (u8)*Len;
	}
	*Len -= Count;
	while (Count > 0U) {
		RegVal = XPlmi_In64(*SrcAddr);
		XPlmi_Out64(*DestAddr, RegVal);
		*SrcAddr += XPLMI_WORD_LEN;
		*DestAddr += XPLMI_WORD_LEN;
		--Count;
	}
	Status = XST_SUCCESS;

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function does unaligned DMA transfers.
 *
 * @param	SrcAddr is Source Address space
 * @param   	DestAddr is the Destination Address
 * @param	Len is the number of words to transfer out of which only
 *		unaligned words(0, 1, 2 or 3) would be transferred via
 *		memory writes in this API.
 * @param	Flag is the parameter that indicates whether SrcAddr, DestAddr
 *		or Len should be made aligned with 16 bytes
 *
 * @return	XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function does unaligned DMA transfers.
@param       SrcAddr is Source Address space
@param       DestAddr is the Destination Address
@param       Len is the number of words to transfer out of which only
unaligned words(0, 1, 2 or 3) would be transferred via
memory writes in this API.
@param       Flag is the parameter that indicates whether SrcAddr, DestAddr
or Len should be made aligned with 16 bytes

@return      XST_SUCCESS on success and error code on failure
@brief This function does unaligned DMA transfers . @param SrcAddr is Source Address space @param DestAddr is the Destination Address @param Len is the number of words to transfer out of which only unaligned words ( 0 1 2 or 3 ) would be transferred via memory writes in this API . @param Flag is the parameter that indicates whether SrcAddr DestAddr or Len should be made aligned with 16 bytes @return XST_SUCCESS on success and error code on failure
static int XPlmi_DmaUnalignedXfer(u64* SrcAddr, u64* DestAddr, u32* Len,
	u8 Flag)
{
	int Status = XST_FAILURE;
	u32 RegVal;
	u8 Offset;
	u8 Count;
	if (Flag == XPLMI_SRC_ALIGN_REQ) {
		Offset = (u8)(XPLMI_WORD_LEN -
			(((*SrcAddr) & XPLMI_SIXTEEN_BYTE_MASK) / XPLMI_WORD_LEN));
		Count = Offset % XPLMI_WORD_LEN;
	}
	else if (Flag == XPLMI_DEST_ALIGN_REQ) {
		Offset = (u8)(XPLMI_WORD_LEN -
			(((*DestAddr) & XPLMI_SIXTEEN_BYTE_MASK) / XPLMI_WORD_LEN));
		Count = Offset % XPLMI_WORD_LEN;
	}
	else if (Flag == XPLMI_LEN_ALIGN_REQ) {
		Count = (u8)((*Len) % XPLMI_WORD_LEN);
	}
	else {
		goto END;
	}
	if (Count > *Len) {
		Count = (u8)*Len;
	}
	*Len -= Count;
	while (Count > 0U) {
		RegVal = XPlmi_In64(*SrcAddr);
		XPlmi_Out64(*DestAddr, RegVal);
		*SrcAddr += XPLMI_WORD_LEN;
		*DestAddr += XPLMI_WORD_LEN;
		--Count;
	}
	Status = XST_SUCCESS;
END:
	return Status;
}
static int XPlmi_DmaUnalignedXfer ( u64 * SrcAddr , u64 * DestAddr , u32 * Len , u8 Flag ) { int Status = XST_FAILURE ; u32 RegVal ; u8 Offset ; u8 Count ; if ( Flag == XPLMI_SRC_ALIGN_REQ ) { Offset = ( u8 ) ( XPLMI_WORD_LEN - ( ( ( * SrcAddr ) & XPLMI_SIXTEEN_BYTE_MASK ) / XPLMI_WORD_LEN ) ) ; Count = Offset % XPLMI_WORD_LEN ; } else if ( Flag == XPLMI_DEST_ALIGN_REQ ) { Offset = ( u8 ) ( XPLMI_WORD_LEN - ( ( ( * DestAddr ) & XPLMI_SIXTEEN_BYTE_MASK ) / XPLMI_WORD_LEN ) ) ; Count = Offset % XPLMI_WORD_LEN ; } else if ( Flag == XPLMI_LEN_ALIGN_REQ ) { Count = ( u8 ) ( ( * Len ) % XPLMI_WORD_LEN ) ; } else { goto END ; } if ( Count > * Len ) { Count = ( u8 ) * Len ; } * Len -= Count ; while ( Count > 0U ) { RegVal = XPlmi_In64 ( * SrcAddr ) ; XPlmi_Out64 ( * DestAddr , RegVal ) ; * SrcAddr += XPLMI_WORD_LEN ; * DestAddr += XPLMI_WORD_LEN ; -- Count ; } Status = XST_SUCCESS ; END : return Status ; }
@brief       This function does unaligned DMA transfers.
@brief This function does unaligned DMA transfers .