[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / gpxe / nvs.h
blob5c90c65560183edbaf0a27c3120c86bacd465b4f
1 #ifndef _GPXE_NVS_H
2 #define _GPXE_NVS_H
4 /** @file
6 * Non-volatile storage
8 */
10 FILE_LICENCE ( GPL2_OR_LATER );
12 #include <stdint.h>
14 /** A non-volatile storage device */
15 struct nvs_device {
16 /** Word length
18 * This is expressed as the base-2 logarithm of the word
19 * length in bytes. A value of 0 therefore translates as
20 * 8-bit words, and a value of 1 translates as 16-bit words.
22 unsigned int word_len_log2;
23 /** Device size (in words) */
24 unsigned int size;
25 /** Data block size (in words)
27 * This is the block size used by the device. It must be a
28 * power of two. Data reads and writes must not cross a block
29 * boundary.
31 * Many devices allow reads to cross a block boundary, and
32 * restrict only writes. For the sake of simplicity, we
33 * assume that the same restriction applies to both reads and
34 * writes.
36 unsigned int block_size;
37 /** Read data from device
39 * @v nvs NVS device
40 * @v address Address from which to read
41 * @v data Data buffer
42 * @v len Length of data buffer
43 * @ret rc Return status code
45 * Reads may not cross a block boundary.
47 int ( * read ) ( struct nvs_device *nvs, unsigned int address,
48 void *data, size_t len );
49 /** Write data to device
51 * @v nvs NVS device
52 * @v address Address to which to write
53 * @v data Data buffer
54 * @v len Length of data buffer
55 * @ret rc Return status code
57 * Writes may not cross a block boundary.
59 int ( * write ) ( struct nvs_device *nvs, unsigned int address,
60 const void *data, size_t len );
63 extern int nvs_read ( struct nvs_device *nvs, unsigned int address,
64 void *data, size_t len );
65 extern int nvs_write ( struct nvs_device *nvs, unsigned int address,
66 const void *data, size_t len );
68 #endif /* _GPXE_NVS_H */