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 
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 */
int(* write)(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write data to device.
Definition: nvs.h:59
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
Definition: nvs.c:75
unsigned int word_len_log2
Word length.
Definition: nvs.h:22
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A non-volatile storage device.
Definition: nvs.h:15
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:140
unsigned int block_size
Data block size (in words)
Definition: nvs.h:36
int(* read)(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from device.
Definition: nvs.h:47
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
unsigned int size
Device size (in words)
Definition: nvs.h:24