Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / nvs.h
1 #ifndef _IPXE_NVS_H
2 #define _IPXE_NVS_H
3
4 /** @file
5  *
6  * Non-volatile storage
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <stdint.h>
13
14 /** A non-volatile storage device */
15 struct nvs_device {
16         /** Word length
17          *
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.
21          */
22         unsigned int word_len_log2;
23         /** Device size (in words) */
24         unsigned int size;
25         /** Data block size (in words)
26          *
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.
30          *
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.
35          */
36         unsigned int block_size;
37         /** Read data from device
38          *
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
44          *
45          * Reads may not cross a block boundary.
46          */
47         int ( * read ) ( struct nvs_device *nvs, unsigned int address,
48                          void *data, size_t len );
49         /** Write data to device
50          *
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
56          *
57          * Writes may not cross a block boundary.
58          */
59         int ( * write ) ( struct nvs_device *nvs, unsigned int address,
60                           const void *data, size_t len );
61 };
62
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 );
67
68 #endif /* _IPXE_NVS_H */