iPXE
nvs.h
Go to the documentation of this file.
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_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stdint.h>
14 
15 /** A non-volatile storage device */
16 struct nvs_device {
17  /** Word length
18  *
19  * This is expressed as the base-2 logarithm of the word
20  * length in bytes. A value of 0 therefore translates as
21  * 8-bit words, and a value of 1 translates as 16-bit words.
22  */
23  unsigned int word_len_log2;
24  /** Device size (in words) */
25  unsigned int size;
26  /** Data block size (in words)
27  *
28  * This is the block size used by the device. It must be a
29  * power of two. Data reads and writes must not cross a block
30  * boundary.
31  *
32  * Many devices allow reads to cross a block boundary, and
33  * restrict only writes. For the sake of simplicity, we
34  * assume that the same restriction applies to both reads and
35  * writes.
36  */
37  unsigned int block_size;
38  /** Read data from device
39  *
40  * @v nvs NVS device
41  * @v address Address from which to read
42  * @v data Data buffer
43  * @v len Length of data buffer
44  * @ret rc Return status code
45  *
46  * Reads may not cross a block boundary.
47  */
48  int ( * read ) ( struct nvs_device *nvs, unsigned int address,
49  void *data, size_t len );
50  /** Write data to device
51  *
52  * @v nvs NVS device
53  * @v address Address to which to write
54  * @v data Data buffer
55  * @v len Length of data buffer
56  * @ret rc Return status code
57  *
58  * Writes may not cross a block boundary.
59  */
60  int ( * write ) ( struct nvs_device *nvs, unsigned int address,
61  const void *data, size_t len );
62 };
63 
64 extern int nvs_read ( struct nvs_device *nvs, unsigned int address,
65  void *data, size_t len );
66 extern int nvs_write ( struct nvs_device *nvs, unsigned int address,
67  const void *data, size_t len );
68 
69 #endif /* _IPXE_NVS_H */
int(* write)(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write data to device.
Definition: nvs.h:60
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
Definition: nvs.c:76
unsigned int word_len_log2
Word length.
Definition: nvs.h:23
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A non-volatile storage device.
Definition: nvs.h:16
uint64_t address
Base address.
Definition: ena.h:24
int nvs_write(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write to non-volatile storage device.
Definition: nvs.c:141
FILE_SECBOOT(PERMITTED)
unsigned int block_size
Data block size (in words)
Definition: nvs.h:37
ring len
Length.
Definition: dwmac.h:231
int(* read)(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from device.
Definition: nvs.h:48
uint8_t data[48]
Additional event data.
Definition: ena.h:22
unsigned int size
Device size (in words)
Definition: nvs.h:25