lib/sw_services/xilflash/src/xilflash_amd.c
int XFlashAmd_Write(XFlash * InstancePtr, u32 Offset, u32 Bytes, void *SrcPtr)
{
	int Status = (int)XST_FAILURE;
	u32 StartOffset;
	u32 EndOffset;
	XFlashVendorData_Amd *DevDataPtr;

	/* Verify inputs are valid. */
	if(InstancePtr == NULL) {
		return (XST_FAILURE);
	}

	if(SrcPtr == NULL) {
		return (XST_FAILURE);
	}

	/* Nothing specified to be programmed. */
	if (Bytes == 0) {
		return (XST_SUCCESS);
	}

	if (InstancePtr->Geometry.MemoryLayout == XFL_LAYOUT_X16_X16_X1){
		StartOffset = Offset >> 1;
		EndOffset = Offset + Bytes -1;
		EndOffset = EndOffset >> 1;
	}
	else {
		StartOffset = Offset ;
		EndOffset = Offset + Bytes -1;
	}

	/* Verify the address range is within the part. */
	if (!XFL_GEOMETRY_IS_ABSOLUTE_VALID(&InstancePtr->Geometry, StartOffset)
		 || !XFL_GEOMETRY_IS_ABSOLUTE_VALID(&InstancePtr->Geometry,
			EndOffset)) {
		return (XFLASH_ADDRESS_ERROR);
	}

	/* Call the proper write buffer function. */
	DevDataPtr = GET_PARTDATA(InstancePtr);
	Status = DevDataPtr->WriteBuffer(InstancePtr, (void *)StartOffset, SrcPtr,
					(Bytes));

	/* Reset the bank(s) so that it returns to the read mode. */
	(void) XFlashAmd_ResetBank(InstancePtr, StartOffset, Bytes);

	return (Status);
}
/*****************************************************************************/
/**
*
* Programs the AMD flash device with data stored in the user buffer.
*
* @param	InstancePtr is the pointer to the XFlash instance.
* @param	Offset is the offset into the device(s) address space from which
*		to begin programming. Must be aligned to the width of the
*		flash's data bus.
* @param	Bytes is the number of bytes to program.
* @param	SrcPtr is the source address containing data to be programmed.
*		Must be aligned to the width of the flash's data bus.
*
* @return
*		- XST_SUCCESS if successful.
*		- XFLASH_ADDRESS_ERROR if the destination address range is
*		  not completely within the addressable areas of the device(s).
*		- XST_FAILURE if failed.
*
* @note		None.
*
******************************************************************************/
Programs the AMD flash device with data stored in the user buffer.
Programs the AMD flash device with data stored in the user buffer .
int XFlashAmd_Write(XFlash * InstancePtr, u32 Offset, u32 Bytes, void *SrcPtr)
{
	int Status = (int)XST_FAILURE;
	u32 StartOffset;
	u32 EndOffset;
	XFlashVendorData_Amd *DevDataPtr;
	if(InstancePtr == NULL) {
		return (XST_FAILURE);
	}
	if(SrcPtr == NULL) {
		return (XST_FAILURE);
	}
	if (Bytes == 0) {
		return (XST_SUCCESS);
	}
	if (InstancePtr->Geometry.MemoryLayout == XFL_LAYOUT_X16_X16_X1){
		StartOffset = Offset >> 1;
		EndOffset = Offset + Bytes -1;
		EndOffset = EndOffset >> 1;
	}
	else {
		StartOffset = Offset ;
		EndOffset = Offset + Bytes -1;
	}
	if (!XFL_GEOMETRY_IS_ABSOLUTE_VALID(&InstancePtr->Geometry, StartOffset)
		 || !XFL_GEOMETRY_IS_ABSOLUTE_VALID(&InstancePtr->Geometry,
			EndOffset)) {
		return (XFLASH_ADDRESS_ERROR);
	}
	DevDataPtr = GET_PARTDATA(InstancePtr);
	Status = DevDataPtr->WriteBuffer(InstancePtr, (void *)StartOffset, SrcPtr,
					(Bytes));
	(void) XFlashAmd_ResetBank(InstancePtr, StartOffset, Bytes);
	return (Status);
}
int XFlashAmd_Write ( XFlash * InstancePtr , u32 Offset , u32 Bytes , void * SrcPtr ) { int Status = ( int ) XST_FAILURE ; u32 StartOffset ; u32 EndOffset ; XFlashVendorData_Amd * DevDataPtr ; if ( InstancePtr == NULL ) { return ( XST_FAILURE ) ; } if ( SrcPtr == NULL ) { return ( XST_FAILURE ) ; } if ( Bytes == 0 ) { return ( XST_SUCCESS ) ; } if ( InstancePtr -> Geometry . MemoryLayout == XFL_LAYOUT_X16_X16_X1 ) { StartOffset = Offset >> 1 ; EndOffset = Offset + Bytes - 1 ; EndOffset = EndOffset >> 1 ; } else { StartOffset = Offset ; EndOffset = Offset + Bytes - 1 ; } if ( ! XFL_GEOMETRY_IS_ABSOLUTE_VALID ( & InstancePtr -> Geometry , StartOffset ) || ! XFL_GEOMETRY_IS_ABSOLUTE_VALID ( & InstancePtr -> Geometry , EndOffset ) ) { return ( XFLASH_ADDRESS_ERROR ) ; } DevDataPtr = GET_PARTDATA ( InstancePtr ) ; Status = DevDataPtr -> WriteBuffer ( InstancePtr , ( void * ) StartOffset , SrcPtr , ( Bytes ) ) ; ( void ) XFlashAmd_ResetBank ( InstancePtr , StartOffset , Bytes ) ; return ( Status ) ; }
Programs the AMD flash device with data stored in the user buffer.
Programs the AMD flash device with data stored in the user buffer .
/* Verify inputs are valid. */ /* Nothing specified to be programmed. */ /* Verify the address range is within the part. */ /* Call the proper write buffer function. */ /* Reset the bank(s) so that it returns to the read mode. */