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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
*/
;
typedef enum vpd_err vpd_err_t;
;
;
/* Callback for decodeVpdString to invoke. */
typedef vpd_decode_callback VpdDecodeCallback;
/* Container data types */
;
;
/***********************************************************************
* Encode and decode VPD entries
***********************************************************************/
/* Encodes the len into multiple bytes with the following format.
*
* 7 6 ............ 0
* +----+------------------+
* |More| Length | ...
* +----+------------------+
*
* The encode_buf points to the actual position we are going to store.
* encoded_len will return the exact bytes we encoded in this function.
* Returns fail if the buffer is not long enough.
*/
vpd_err_t ;
/* Given an encoded string, this functions decodes the length field which varies
* from 1 byte to many bytes.
*
* The in points the actual byte going to be decoded. The *length returns
* the decoded length field. The number of consumed bytes will be stroed in
* decoded_len.
*
* Returns VPD_FAIL if more bit is 1, but actually reaches the end of string.
*/
vpd_err_t ;
/* Encodes the terminator.
* When calling, the output_buf should point to the start of buffer while
* *generated_len should contain how many bytes exist in buffer now.
* After return, *generated_len would be plused the number of bytes generated
* in this function.
*/
vpd_err_t ;
/* Encodes the given type/key/value pair into buffer.
*
* The pad_value_len is used to control the output value length.
* When pad_value_len > 0, the value is outputted into fixed length (pad \0
* if the value is shorter). Truncated if too long.
* pad_value_len == VPD_NO_LIMIT, output the value as long as possible.
* This is useful when we want to fix the structure layout at beginning.
*
* The encoded string will be stored in output_buf. If it is longer than
* max_buffer_len, this function returns fail. If the buffer is long enough,
* the generated_len will be updated.
*
* When calling, the output_buf should point to the start of buffer while
* *generated_len should contain how many bytes exist in buffer now.
* After return, *generated_len would be plused the number of bytes generated
* in this function.
*
* The initial value of *generated_len can be non-zero, so that this value
* can be used between multiple calls to encodeVpd2Pair().
*/
vpd_err_t ;
/* Given the encoded string, this function invokes callback with extracted
* (key, value). The *consumed will be plused the number of bytes consumed in
* this function.
*
* The input_buf points to the first byte of the input buffer.
*
* The *consumed starts from 0, which is actually the next byte to be decoded.
* It can be non-zero to be used in multiple calls.
*
* If one entry is successfully decoded, sends it to callback and returns the
* result.
*/
vpd_err_t ;
/***********************************************************************
* Container helpers
***********************************************************************/
void ;
struct StringPair *;
/* If key is already existed in container, its value will be replaced.
* If not existed, creates new entry in container.
*/
void ;
/* merge all entries in src into dst. If key is duplicate, overwrite it.
*/
void ;
/* subtract src from dst.
*/
int ;
/* Given a container, encode its all entries into the buffer.
*/
vpd_err_t ;
/* Given a VPD blob, decode its entries and push into container.
*/
vpd_err_t ;
/* Set filter for exporting functions.
* If filter is NULL, resets the filter so that everything can be exported.
*/
vpd_err_t ;
/*
* Remove a key.
* Returns VPD_OK if deleted successfully. Otherwise, VPD_FAIL.
*/
vpd_err_t ;
/*
* Returns number of pairs in container.
*/
int ;
/*
* Export the value in raw format.
*
* The buf points to the first byte of buffer and *generated contains the number
* of bytes already existed in buffer.
*
* Afterward, the *generated will be plused on exact bytes this function has
* generated.
*/
vpd_err_t ;
/*
* Export the container content with human-readable text.
*
* The buf points to the first byte of buffer and *generated contains the number
* of bytes already existed in buffer.
*
* Afterward, the *generated will be plused on exact bytes this function has
* generated.
*/
vpd_err_t ;
void ;
/* __LIB_VPD__ */