forked from data-respons-solutions/nvram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvram_interface.h
85 lines (76 loc) · 1.75 KB
/
nvram_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _NVRAM_INTERFACE_H_
#define _NVRAM_INTERFACE_H_
#include <stdint.h>
#include <stddef.h>
/* Should be defined and allocate by nvram_interface_init.
* nvram framework will call nvram_interface_destroy
*/
struct nvram_device;
/*
* Initialize nvram interface
*
* @params
* dev: device
* section: String (i.e. path) for section A. The pointer must remain valid until
* nvram_interface_destroy is called.
*
* @returns
* 0 for success
* negative errno for error
*/
int nvram_interface_init(struct nvram_device** dev, const char* section);
/*
* Free allocated resources
*/
void nvram_interface_destroy(struct nvram_device** dev);
/*
* Get size needed to be read
*
* @params
* dev: device
* size: size returned
*
* @returns
* 0 for success
* negative errno for error
*/
int nvram_interface_size(struct nvram_device* dev, size_t* size);
/*
* Read from nvram device into buffer
*
* @params
* dev: device
* buf: Read buffer
* size: Size of read buffer
*
* @returns
* 0 for success (All "size" bytes read)
* negative errno for error
*/
int nvram_interface_read(struct nvram_device* dev, uint8_t* buf, size_t size);
/*
* Write from buffer into nvram device
*
* @params
* priv: private data
* section: Section to operate on
* buf: write buffer
* size: Size of write buffer
*
* @returns
* 0 for success (All "size" bytes written)
* negative errno for error
*/
int nvram_interface_write(struct nvram_device* dev, const uint8_t* buf, size_t size);
/*
* Get section string from interface
*
* @params
* priv: private data
*
* @returns
* pointer to path string
* NULL if unavailable
*/
const char* nvram_interface_section(const struct nvram_device* dev);
#endif // _NVRAM_INTERFACE_H_