Typedefs | ||
| struct { | ||
| } | sflash_handle_t | |
Functions | |
| int | deinit_sflash (sflash_handle_t *const handle) |
| int | init_sflash (sflash_handle_t *const handle, void *peripheral_id, sflash_write_allowed_t write_allowed_in) |
| int | sflash_chip_erase (const sflash_handle_t *const handle) |
| int | sflash_dct_read_secure (const sflash_handle_t *const sflash_handle, unsigned long device_address, void *data_addr, unsigned int size) |
| int | sflash_dct_write_secure (const sflash_handle_t *const sflash_handle, unsigned long device_address, const void *const data_addr, unsigned int size) |
| int | sflash_get_size (const sflash_handle_t *const handle, unsigned long *size) |
| int | sflash_read (const sflash_handle_t *const handle, unsigned long device_address, void *data_addr, unsigned int size) |
| int | sflash_read_secure (const sflash_handle_t *const handle, unsigned long device_address, void *data_addr, unsigned int size) |
| int | sflash_sector_erase (const sflash_handle_t *const handle, unsigned long device_address) |
| int | sflash_write (const sflash_handle_t *const handle, unsigned long device_address, const void *const data_addr, unsigned int size) |
| int | sflash_write_secure (const sflash_handle_t *const handle, unsigned long device_address, const void *const data_addr, unsigned int size) |
API for accessing SPI flash chips.
| typedef struct { ... } sflash_handle_t |
Handle for a sflash access instance Users should not access these values - they are provided here only to provide the compiler with datatype size information allowing static declarations
| int deinit_sflash | ( | sflash_handle_t *const | handle | ) |
De-initializes a SPI Flash chip
| [in] | handle | Handle structure that will be used for this sflash instance - allocated by caller. |
| int init_sflash | ( | sflash_handle_t *const | handle, |
| void * | peripheral_id, | ||
| sflash_write_allowed_t | write_allowed_in ) |
Initializes a SPI Flash chip
Internally this initializes the associated SPI port, then reads the chip ID from the SPI flash to determine what type it is.
| [in] | handle | Handle structure that will be used for this sflash instance - allocated by caller. |
| [in] | peripheral_id | An ID value which is passed to the underlying sflash_platform_init function |
| [in] | write_allowed_in | Determines whether writing will be allowed to this sflash handle |
| int sflash_chip_erase | ( | const sflash_handle_t *const | handle | ) |
Erase the contents of a SPI Flash chip
| [in] | handle | Handle structure that was initialized with init_sflash |
| int sflash_dct_read_secure | ( | const sflash_handle_t *const | sflash_handle, |
| unsigned long | device_address, | ||
| void * | data_addr, | ||
| unsigned int | size ) |
Reads data from DCT, Decrypts/Authenticates the data read, returns error if Authentication fails
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the SPI flash where reading will start |
| [out] | data_addr | Destination buffer in memory that will receive the data |
| [in] | size | Number of bytes to read from the chip |
| int sflash_dct_write_secure | ( | const sflash_handle_t *const | sflash_handle, |
| unsigned long | device_address, | ||
| const void *const | data_addr, | ||
| unsigned int | size ) |
Writes data to DCT, Encrypts and Sign the data
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the SPI flash where reading will start |
| [out] | data_addr | Destination buffer in memory that will receive the data |
| [in] | size | Number of bytes to read from the chip |
| int sflash_get_size | ( | const sflash_handle_t *const | handle, |
| unsigned long * | size ) |
Erase one sector of a SPI Flash chip
| [in] | handle | Handle structure that was initialized with init_sflash |
| [out] | size | Variable which will receive the capacity size in bytes of the sflash chip |
| int sflash_read | ( | const sflash_handle_t *const | handle, |
| unsigned long | device_address, | ||
| void * | data_addr, | ||
| unsigned int | size ) |
Reads data from a SPI Flash chip
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the SPI flash where reading will start |
| [out] | data_addr | Destination buffer in memory that will receive the data |
| [in] | size | Number of bytes to read from the chip |
| int sflash_read_secure | ( | const sflash_handle_t *const | handle, |
| unsigned long | device_address, | ||
| void * | data_addr, | ||
| unsigned int | size ) |
Reads data from a SPI Flash chip, Decrypts/Authenticates the data read, returns error if Authentication fails
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the SPI flash where reading will start |
| [out] | data_addr | Destination buffer in memory that will receive the data |
| [in] | size | Number of bytes to read from the chip |
| int sflash_sector_erase | ( | const sflash_handle_t *const | handle, |
| unsigned long | device_address ) |
Erase one sector of a SPI Flash chip
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the sflash chip of the first byte of the sector to erase |
| int sflash_write | ( | const sflash_handle_t *const | handle, |
| unsigned long | device_address, | ||
| const void *const | data_addr, | ||
| unsigned int | size ) |
Write data to a SPI Flash chip
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the SPI flash where writing will start |
| [in] | data_addr | Pointer to the buffer in memory that contains the data being written |
| [in] | size | Number of bytes to write to the chip |
| int sflash_write_secure | ( | const sflash_handle_t *const | handle, |
| unsigned long | device_address, | ||
| const void *const | data_addr, | ||
| unsigned int | size ) |
Secure-Write data to a SPI Flash chip (Encrypt and Authenticate data sector by sector before being written)
| [in] | handle | Handle structure that was initialized with init_sflash |
| [in] | device_address | The location on the SPI flash where writing will start |
| [in] | data_addr | Pointer to the buffer in memory that contains the data being written |
| [in] | size | Number of bytes to write to the chip |