3.3.2. eeprom_soft — Software EEPROM

Source code: src/drivers/storage/eeprom_soft.h, src/drivers/storage/eeprom_soft.c

Test code: tst/drivers/hardware/storage/eeprom_soft/main.c


Functions

int eeprom_soft_module_init(void)

Initialize software EEPROM module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int eeprom_soft_init(struct eeprom_soft_driver_t *self_p, struct flash_driver_t *flash_p, const struct eeprom_soft_block_t *blocks_p, int number_of_blocks, size_t chunk_size)

Initialize given driver object.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to initialize.
  • flash_p: Flash driver.
  • blocks_p: Flash memory blocks to use.
  • number_of_blocks: Number of blocks.
  • chunk_size: Chunk size in bytes. This is the size of the EEPROM. Eight bytes of the chunk will be used to store metadata, so only chunk_size - 8 bytes are available to the user.

int eeprom_soft_mount(struct eeprom_soft_driver_t *self_p)

Mount given software EEPROM.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to mount.

int eeprom_soft_format(struct eeprom_soft_driver_t *self_p)

Format given software EEPROM.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to format.

ssize_t eeprom_soft_read(struct eeprom_soft_driver_t *self_p, void *dst_p, uintptr_t src, size_t size)

Read into given buffer from given address.

Return
Number of bytes read or negative error code.
Parameters
  • self_p: Initialized driver object.
  • dst_p: Buffer to read into.
  • src: Software EEPROM address to read from. Addressing starts at zero(0).
  • size: Number of bytes to read.

ssize_t eeprom_soft_write(struct eeprom_soft_driver_t *self_p, uintptr_t dst, const void *src_p, size_t size)

Write given buffer to given address.

Return
Number of bytes written or negative error code.
Parameters
  • self_p: Initialized driver object.
  • dst: Software EEPROM address to write to. Addressing starts at zero(0).
  • src_p: Buffer to write.
  • size: Number of bytes to write.

struct eeprom_soft_block_t
#include <eeprom_soft.h>

Public Members

uintptr_t address
size_t size
struct eeprom_soft_driver_t

Public Members

struct flash_driver_t *flash_p
const struct eeprom_soft_block_t *blocks_p
int number_of_blocks
size_t chunk_size
size_t eeprom_size
const struct eeprom_soft_block_t *block_p
uintptr_t chunk_address
uint16_t revision
struct eeprom_soft_driver_t::@40 eeprom_soft_driver_t::current