Visible to Intel only — GUID: mwh1416946779451
Ixiasoft
Visible to Intel only — GUID: mwh1416946779451
Ixiasoft
6.10.1. Simple Flash Access
For more information about the use of all of these functions in one code example, refer to the code in the “Using the Simple Flash API Functions to Access a Flash Device Named /dev/ext/flash” example in the "Fine-Grained Flash Access" section.
You open a flash device by calling alt_flash_open_dev(), which returns a file handle to a flash device. This function takes a single argument that is the name of the flash device, as defined in system.h.
After you obtain a handle, you can use the alt_write_flash() function to write data to the flash device. The prototype is:
int alt_write_flash( alt_flash_fd* fd, int offset, const void* src_addr, int length )
A call to this function writes to the flash device identified by the handle fd. The driver writes the data starting at offset bytes from the base of the flash device. The data written comes from the address pointed to by src_addr, and the amount of data written is length.
There is also an alt_read_flash() function to read data from the flash device. The prototype is:
int alt_read_flash( alt_flash_fd* fd, int offset, void* dest_addr, int length )
A call to alt_read_flash() reads from the flash device with the handle fd, offset bytes from the beginning of the flash device. The function writes the data to location pointed to by dest_addr, and the amount of data read is length. For most flash devices, you can access the contents as standard memory, making it unnecessary to use alt_read_flash().
The function alt_flash_close_dev() takes a file handle and closes the device. The prototype for this function is:
void alt_flash_close_dev(alt_flash_fd* fd )