lib/sw_apps/img_rcvry/src/xbir_sd.c
int Xbir_SdWrite(u8 *WrBuffer, u64 Length)
{
	int Status = XST_FAILURE;
	u64 NumBlocks = Length / XBIR_SDPS_BLOCK_SIZE;
	u64 BlockIndex;

	for (BlockIndex = 0UL; BlockIndex < NumBlocks;
		BlockIndex += XBIR_SD_RAW_NUM_SECTORS) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex,
			XBIR_SD_RAW_NUM_SECTORS, WrBuffer);
		if (Status != XST_SUCCESS) {
			Status = XBIR_ERROR_SD_WRITE;
			goto END;
		}
		WrBuffer += XBIR_SDPS_WRITE_CHUNK_SIZE;

	}
	if ((Length % XBIR_SDPS_BLOCK_SIZE) != 0L) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex, 1U,
			WrBuffer);
		if (Status != XST_SUCCESS) {
			Status = XBIR_ERROR_SD_WRITE;
		}
	}

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief
 * This function writes data in Write Buffer to SD card.
 *
 * @param	WrBuffer Pointer to data to be written
 * @param	Length  Number of bytes to write
 *
 * @return	XST_SUCCESS on successful write
 * 		Error code on failure
 *
 ******************************************************************************/
@brief
This function writes data in Write Buffer to SD card.

@param       WrBuffer Pointer to data to be written
@param       Length  Number of bytes to write

@return      XST_SUCCESS on successful write
Error code on failure
@brief This function writes data in Write Buffer to SD card . @param WrBuffer Pointer to data to be written @param Length Number of bytes to write @return XST_SUCCESS on successful write Error code on failure
int Xbir_SdWrite(u8 *WrBuffer, u64 Length)
{
	int Status = XST_FAILURE;
	u64 NumBlocks = Length / XBIR_SDPS_BLOCK_SIZE;
	u64 BlockIndex;
	for (BlockIndex = 0UL; BlockIndex < NumBlocks;
		BlockIndex += XBIR_SD_RAW_NUM_SECTORS) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex,
			XBIR_SD_RAW_NUM_SECTORS, WrBuffer);
		if (Status != XST_SUCCESS) {
			Status = XBIR_ERROR_SD_WRITE;
			goto END;
		}
		WrBuffer += XBIR_SDPS_WRITE_CHUNK_SIZE;
	}
	if ((Length % XBIR_SDPS_BLOCK_SIZE) != 0L) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex, 1U,
			WrBuffer);
		if (Status != XST_SUCCESS) {
			Status = XBIR_ERROR_SD_WRITE;
		}
	}
END:
	return Status;
}
int Xbir_SdWrite ( u8 * WrBuffer , u64 Length ) { int Status = XST_FAILURE ; u64 NumBlocks = Length / XBIR_SDPS_BLOCK_SIZE ; u64 BlockIndex ; for ( BlockIndex = 0UL ; BlockIndex < NumBlocks ; BlockIndex += XBIR_SD_RAW_NUM_SECTORS ) { Status = XSdPs_WritePolled ( & SdInstance , BlockIndex , XBIR_SD_RAW_NUM_SECTORS , WrBuffer ) ; if ( Status != XST_SUCCESS ) { Status = XBIR_ERROR_SD_WRITE ; goto END ; } WrBuffer += XBIR_SDPS_WRITE_CHUNK_SIZE ; } if ( ( Length % XBIR_SDPS_BLOCK_SIZE ) != 0L ) { Status = XSdPs_WritePolled ( & SdInstance , BlockIndex , 1U , WrBuffer ) ; if ( Status != XST_SUCCESS ) { Status = XBIR_ERROR_SD_WRITE ; } } END : return Status ; }
@brief
 This function writes data in Write Buffer to SD card.
@brief This function writes data in Write Buffer to SD card .