diff options
author | Michael Brown | 2006-12-04 19:23:06 +0100 |
---|---|---|
committer | Michael Brown | 2006-12-04 19:23:06 +0100 |
commit | 946967f09ce0ab9ab438a0647d393601dd0fca23 (patch) | |
tree | 0e133cb2d481d3e683ecc5be7dcfa0610eaf2f79 /src/include/gpxe/nvs.h | |
parent | Changed length parameter in SPI methods to be a byte length, rather than (diff) | |
download | ipxe-946967f09ce0ab9ab438a0647d393601dd0fca23.tar.gz ipxe-946967f09ce0ab9ab438a0647d393601dd0fca23.tar.xz ipxe-946967f09ce0ab9ab438a0647d393601dd0fca23.zip |
Abstracted out part of the concept of an SPI device to a generalised NVS
device.
Separated the mechanisms of non-volatile storage access and non-volatile
stored options.
Diffstat (limited to 'src/include/gpxe/nvs.h')
-rw-r--r-- | src/include/gpxe/nvs.h | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/src/include/gpxe/nvs.h b/src/include/gpxe/nvs.h index f8a80787..38bc9c55 100644 --- a/src/include/gpxe/nvs.h +++ b/src/include/gpxe/nvs.h @@ -9,22 +9,53 @@ #include <stdint.h> -struct nvs_operations; - +/** A non-volatile storage device */ struct nvs_device { - struct dhcp_option_block *options; - size_t len; - struct nvs_operations *op; -}; - -struct nvs_operations { - int ( * read ) ( struct nvs_device *nvs, unsigned int offset, + /** Word length, in bits */ + unsigned int word_len; + /** Device size (in words) */ + unsigned int size; + /** Data block size (in words) + * + * This is the block size used by the device. It must be a + * power of two. Data reads and writes must not cross a block + * boundary. + * + * Many devices allow reads to cross a block boundary, and + * restrict only writes. For the sake of simplicity, we + * assume that the same restriction applies to both reads and + * writes. + */ + unsigned int block_size; + /** Read data from device + * + * @v nvs NVS device + * @v address Address from which to read + * @v data Data buffer + * @v len Length of data buffer + * @ret rc Return status code + * + * Reads may not cross a block boundary. + */ + int ( * read ) ( struct nvs_device *nvs, unsigned int address, void *data, size_t len ); - int ( * write ) ( struct nvs_device *nvs, unsigned int offset, + /** Write data to device + * + * @v nvs NVS device + * @v address Address to which to write + * @v data Data buffer + * @v len Length of data buffer + * @ret rc Return status code + * + * Writes may not cross a block boundary. + */ + int ( * write ) ( struct nvs_device *nvs, unsigned int address, const void *data, size_t len ); }; -extern int nvs_register ( struct nvs_device *nvs ); -extern void nvs_unregister ( struct nvs_device *nvs ); +extern int nvs_read ( struct nvs_device *nvs, unsigned int address, + void *data, size_t len ); +extern int nvs_write ( struct nvs_device *nvs, unsigned int address, + const void *data, size_t len ); #endif /* _GPXE_NVS_H */ |