write_page()
PROTOTYPE
#include <bfs.h>
int write_page(ui32 addr, void *src, void *dev);
DESCRIPTION
write_page() writes the page of NOR flash memory at address addr. Its size is set by the BFS_PAGE_SIZE definition. src points to where the data is copied from. To facilitate DMA transfers, it will be aligned according to the CACHE_LINE_SIZE definition in “bsp.h”.
dev is a driver-supplied data pointer. The value passed to TargetBFS by the bfsAddNorVol() call is passed back as the last parameter of each driver callback function. It can be used in any way that is convenient for the driver implementation.
write_page() should not return until the write is complete. It can poll a flash device’s ‘ready’ bit or, if the system supports this, block until an interrupt from the flash device signals that the operation is complete.
write_page() is used by TargetBFS both to write new pages and, infrequently, to write zeros over data that was written by a previous write_page() call. NOR flash memory supports multiple program operations as long as each update only writes new ‘1’s to ‘0’.
write_page() returns 0 for success. Any other value is interpreted as a fatal error. A fatal error causes all subsequent accesses to fail, with errno set to EIO. A fatal error should be reported if a permanent error condition exists, such as if a removable device has been extracted.