blob: 262f42355258ffce9aa1d5424c05608d0ca8558a [file] [log] [blame]
John Wang02700402019-10-06 16:34:29 +08001#ifndef BIOS_TABLE_H__
2#define BIOS_TABLE_H__
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "bios.h"
9#include <stdbool.h>
10#include <stddef.h>
11#include <stdint.h>
12
13/** @struct pldm_bios_table_iter
14 * structure representing bios table iterator
15 */
16struct pldm_bios_table_iter;
17
18/** @brief Create a bios table iterator
19 * @param[in] table - Pointer to table data
20 * @param[in] length - Length of table data
21 * @param[in] type - Type of pldm bios table
22 * @return Iterator to the beginning
23 */
24struct pldm_bios_table_iter *
25pldm_bios_table_iter_create(const void *table, size_t length,
26 enum pldm_bios_table_types type);
27
28/** @brief Release a bios table iterator
29 * @param[in] iter - Pointer to bios table iterator
30 */
31void pldm_bios_table_iter_free(struct pldm_bios_table_iter *iter);
32
33/** @brief Check if the iterator reaches the end of the bios table
34 * @param[in] iter - Pointer to the bios table iterator
35 * @return true if iterator reaches the end
36 * @note *end* is a position after the last entry.
37 */
38bool pldm_bios_table_iter_is_end(const struct pldm_bios_table_iter *iter);
39
40/** @brief Get iterator to next entry
41 * @param[in] iter - Pointer the bios table iterator
42 */
43void pldm_bios_table_iter_next(struct pldm_bios_table_iter *iter);
44
45/** @brief Get the bios table entry that the iterator points to
46 * @param[in] iter - Pointer to the bios table iterator
47 * @return Pointer to an entry in bios table
48 */
49const void *pldm_bios_table_iter_value(struct pldm_bios_table_iter *iter);
50
51/** @brief Get the bios attribute table entry that the iterator points to
52 * @param[in] iter - Pointer the bios attribute table iterator
53 * @return Pointer to an entry in bios attribute table
54 */
55static inline const struct pldm_bios_attr_table_entry *
56pldm_bios_table_iter_attr_entry_value(struct pldm_bios_table_iter *iter)
57{
58 return (const struct pldm_bios_attr_table_entry *)
59 pldm_bios_table_iter_value(iter);
60}
61
John Wangdd9a6282019-10-11 18:52:46 +080062/** @brief Get the bios string table entry that the iterator ponit to
63 * @param[in] iter - Pointer the bios string table iterator
64 * @return Pointer to an entry in bios string table
65 */
66static inline const struct pldm_bios_string_table_entry *
67pldm_bios_table_iter_string_entry_value(struct pldm_bios_table_iter *iter)
68{
69 return (const struct pldm_bios_string_table_entry *)
70 pldm_bios_table_iter_value(iter);
71}
72
John Wang49484a12019-12-02 14:21:53 +080073/** @brief Get the bios attribute value table entry that the iterator ponit to
74 * @param[in] iter - Pointer the bios attribute value table iterator
75 * @return Pointer to an entry in bios attribute value table
76 */
77static inline const struct pldm_bios_attr_val_table_entry *
78pldm_bios_table_iter_attr_value_entry_value(struct pldm_bios_table_iter *iter)
79{
80 return (const struct pldm_bios_attr_val_table_entry *)
81 pldm_bios_table_iter_value(iter);
82}
83
John Wangdd9a6282019-10-11 18:52:46 +080084/** @brief Get the length of an entry in the BIOS String Table
85 * @param[in] string_length - Length of string
86 * @return Length of an entry in bytes
87 */
88size_t pldm_bios_table_string_entry_encode_length(uint16_t string_length);
89
90/** @brief Create an entry of BIOS String Table
91 * @param[out] entry - Pointer to a buffer to create an entry
92 * @param[in] entry_length - Length of the buffer to create an entry
93 * @param[in] str - String itself
94 * @param[in] str_length - Length of the string
95 */
96void pldm_bios_table_string_entry_encode(void *entry, size_t entry_length,
97 const char *str, uint16_t str_length);
98
99/** @brief Create an entry of BIOS String Table and check the validity of the
100 * parameters
101 * @param[out] entry - Pointer to a buffer to create an entry
102 * @param[in] entry_length - Length of the buffer to create an entry
103 * @param[in] str - String itself
104 * @param[in] str_length - Length of the string
105 * @return pldm_completion_codes
106 */
107int pldm_bios_table_string_entry_encode_check(void *entry, size_t entry_length,
108 const char *str,
109 uint16_t str_length);
110
111/** @brief Get the string handle for the entry
112 * @param[in] entry - Pointer to a bios string table entry
113 * @return Handle to identify a string in the bios string table
114 */
115uint16_t pldm_bios_table_string_entry_decode_handle(
116 const struct pldm_bios_string_table_entry *entry);
117
118/** @brief Get the string length for the entry
119 * @param[in] entry - Pointer to a bios string table entry
120 * @return Length of string in bytes
121 */
122uint16_t pldm_bios_table_string_entry_decode_string_length(
123 const struct pldm_bios_string_table_entry *entry);
124
125/** @brief Get the string(at most one less than *size* characters) from the
126 * entry
127 * @param[in] entry - Pointer to a bios string table entry
128 * @param[out] buffer - Pointer to a buffer to store the string
129 * @param[in] size - Size of the buffer to store the string
130 * @return Length of the string decoded
131 */
132uint16_t pldm_bios_table_string_entry_decode_string(
133 const struct pldm_bios_string_table_entry *entry, char *buffer,
134 size_t size);
135
136/** @brief Get the string from the entry and check the validity of the
137 * parameters
138 * @param[in] entry - Pointer to a bios string table entry
139 * @param[out] buffer - Pointer to a buffer to store the string
140 * @param[in] size - Size of the buffer to store the string
141 * @return pldm_completion_codes
142 */
143int pldm_bios_table_string_entry_decode_string_check(
144 const struct pldm_bios_string_table_entry *entry, char *buffer,
145 size_t size);
146
147/** @brief Find an entry in bios string table by string
148 * @param[in] table - The BIOS String Table
149 * @param[in] length - Length of the BIOS String Table
150 * @param[in] str - String itself
151 * @return Pointer to an entry in the bios string table
152 */
153const struct pldm_bios_string_table_entry *
154pldm_bios_table_string_find_by_string(const void *table, size_t length,
155 const char *str);
156/** @brief Find an entry in bios string table by handle
157 * @param[in] table - The BIOS String Table
158 * @param[in] length - Length of the BIOS String Table
159 * @param[in] handle - Handle to identify a string in the bios string table
160 * @return Pointer to an entry in the bios string table
161 */
162const struct pldm_bios_string_table_entry *
163pldm_bios_table_string_find_by_handle(const void *table, size_t length,
164 uint16_t handle);
165
John Wangccc04552019-10-14 14:28:25 +0800166/** @struct pldm_bios_table_attr_entry_enum_info
167 *
168 * An auxiliary structure for passing parameters to @ref
169 * pldm_bios_table_attr_entry_enum_encode
170 *
171 */
172struct pldm_bios_table_attr_entry_enum_info {
173 uint16_t name_handle; //!< attribute name handle
174 bool read_only; //!< indicate whether the attribute is read-only
175 uint8_t pv_num; //!< number of possible values
176 const uint16_t *pv_handle; //!< handles of possible values
177 uint8_t def_num; //!< nnumber of default values
178 const uint8_t *def_index; //!< indices of default values.
179};
180
181/** @brief Get length that an attribute entry(type: enum) will take
182 * @param[in] pv_num - Number of possible values
183 * @param[in] def_num - Number of default values
184 * @return The length that an entry(type: enum) will take
185 */
186size_t pldm_bios_table_attr_entry_enum_encode_length(uint8_t pv_num,
187 uint8_t def_num);
188
189/** @brief Create an entry of BIOS Attribute Table (type: enum)
190 * @param[out] entry - Pointer to a buffer to create an entry
191 * @param[in] entry_length - Length of the buffer to create an entry
192 * @param[in] info - Pointer to an auxiliary structure @ref
193 * pldm_bios_table_attr_entry_enum_info
194 */
195void pldm_bios_table_attr_entry_enum_encode(
196 void *entry, size_t entry_length,
197 const struct pldm_bios_table_attr_entry_enum_info *info);
198
199/** @brief Create an entry of BIOS Attribute Table (type: enum) and check the
200 * validity of the parameters
201 * @param[out] entry - Pointer to a buffer to create an entry
202 * @param[in] entry_length - Length of the buffer to create an entry
203 * @param[in] info - Pointer to an auxiliary structure @ref
204 * pldm_bios_table_attr_entry_enum_info
205 * @return pldm_completion_codes
206 */
207int pldm_bios_table_attr_entry_enum_encode_check(
208 void *entry, size_t entry_length,
209 const struct pldm_bios_table_attr_entry_enum_info *info);
210
John Wang02700402019-10-06 16:34:29 +0800211/** @brief Get the total number of possible values for the entry
212 * @param[in] entry - Pointer to bios attribute table entry
213 * @return total number of possible values
214 */
215uint8_t pldm_bios_table_attr_entry_enum_decode_pv_num(
216 const struct pldm_bios_attr_table_entry *entry);
217
218/** @brief Get the total number of possible values for the entry and check the
219 * validity of the parameters
220 * @param[in] entry - Pointer to bios attribute table entry
221 * @param[out] pv_num - Pointer to total number of possible values
222 * @return pldm_completion_codes
223 */
224int pldm_bios_table_attr_entry_enum_decode_pv_num_check(
225 const struct pldm_bios_attr_table_entry *entry, uint8_t *pv_num);
226
227/** @brief Get the total number of default values for the entry
228 * @param[in] entry - Pointer to bios attribute table entry
229 * @return total number of default values
230 */
231uint8_t pldm_bios_table_attr_entry_enum_decode_def_num(
232 const struct pldm_bios_attr_table_entry *entry);
233
234/** @brief Get the total number of default values for the entry and check the
235 * validity of the parameters
236 * @param[in] entry - Pointer to bios attribute table entry
237 * @param[out] def_num - Pointer to total number of default values
238 * @return pldm_completion_codes
239 */
240int pldm_bios_table_attr_entry_enum_decode_def_num_check(
241 const struct pldm_bios_attr_table_entry *entry, uint8_t *def_num);
242
John Wang3ad21752019-10-06 16:42:21 +0800243/** @brief Get possible values string handles
244 * @param[in] entry - Pointer to bios attribute table entry
245 * @param[out] pv_hdls - Pointer to a buffer to stroe
246 * PossibleValuesStringHandles
247 * @param[in] pv_num - Number of PossibleValuesStringHandles expected
248 * @return pldm_completion_codes
249 */
250uint8_t pldm_bios_table_attr_entry_enum_decode_pv_hdls(
251 const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
252 uint8_t pv_num);
253
254/** @brief Get possible values string handles and check the validity of the
255 * parameters
256 * @param[in] entry - Pointer to bios attribute table entry
257 * @param[out] pv_hdls - Pointer to a buffer to stroe
258 * PossibleValuesStringHandles
259 * @param[in] pv_num - Number of PossibleValuesStringHandles the buffer can
260 * stroe
261 * @return Number of PossibleValuesStringHandles decoded
262 */
263int pldm_bios_table_attr_entry_enum_decode_pv_hdls_check(
264 const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
265 uint8_t pv_num);
266
John Wangccc04552019-10-14 14:28:25 +0800267/** @struct pldm_bios_table_attr_entry_string_info
268 *
269 * An auxiliary structure for passing parameters to @ref
270 * pldm_bios_table_attr_entry_string_encode
271 *
272 */
273struct pldm_bios_table_attr_entry_string_info {
274 uint16_t name_handle; //!< attribute name handle
275 bool read_only; //!< indicate whether the attribute is read-only
276 uint8_t string_type; //!< The type of the string
277 uint16_t min_length; //!< The minimum length of the string in bytes
278 uint16_t max_length; //!< The maximum length of the string in bytes
279 uint16_t def_length; //!< The length of the defaut string in bytes
280 const char *def_string; //!< The default string itself
281};
282
John Wang827c5de2019-11-07 18:27:27 +0800283/** @brief Check fields in @ref pldm_bios_table_attr_entry_string_info
284 * @param[in] info - Pointer to the pldm_bios_table_attr_entry_string_info
285 * @param[out] errmsg - Pointer to an errmsg stored in the statically allocated
286 * memory
287 * @return pldm_completion_codes
288 */
289int pldm_bios_table_attr_entry_string_info_check(
290 const struct pldm_bios_table_attr_entry_string_info *info,
291 const char **errmsg);
292
John Wangccc04552019-10-14 14:28:25 +0800293/** @brief Get length that an attribute entry(type: string) will take
294 * @param[in] def_str_len - Length of default string
295 * @return The length that an entry(type: string) will take
296 */
297size_t pldm_bios_table_attr_entry_string_encode_length(uint16_t def_str_len);
298
299/** @brief Create an entry of BIOS Attribute Table (type: string)
300 * @param[out] entry - Pointer to a buffer to create an entry
301 * @param[in] entry_length - Length of the buffer to create an entry
302 * @param[in] info - Pointer to an auxiliary structure @ref
303 * pldm_bios_table_attr_entry_string_info
304 */
305void pldm_bios_table_attr_entry_string_encode(
306 void *entry, size_t entry_length,
307 const struct pldm_bios_table_attr_entry_string_info *info);
308
309/** @brief Create an entry of BIOS Attribute Table (type: string) and check the
310 * validity of the parameters
311 * @param[out] entry - Pointer to a buffer to create an entry
312 * @param[in] entry_length - Length of the buffer to create an entry
313 * @param[in] info - Pointer to an auxiliary structure @ref
314 * pldm_bios_table_attr_entry_string_info
315 * @return pldm_completion_codes
316 */
317int pldm_bios_table_attr_entry_string_encode_check(
318 void *entry, size_t entry_length,
319 const struct pldm_bios_table_attr_entry_string_info *info);
320
John Wang02700402019-10-06 16:34:29 +0800321/** @brief Get the length of default string in bytes for the entry
322 * @param[in] entry - Pointer to bios attribute table entry
323 * @return length of default string in bytes
324 */
325uint16_t pldm_bios_table_attr_entry_string_decode_def_string_length(
326 const struct pldm_bios_attr_table_entry *entry);
327
328/** @brief Get the length of default string in bytes for the entry and check the
329 * validity of the parameters
330 * @param[in] entry - Pointer to bios attribute table entry
331 * @param[out] def_string_length Pointer to length of default string in bytes
332 * @return pldm_completion_codes
333 */
334int pldm_bios_table_attr_entry_string_decode_def_string_length_check(
335 const struct pldm_bios_attr_table_entry *entry,
336 uint16_t *def_string_length);
337
John Wangca230822019-10-16 11:39:27 +0800338/** @struct pldm_bios_table_attr_entry_integer_info
339 *
340 * An auxiliary structure for passing parameters to @ref
341 * pldm_bios_table_attr_entry_integer_encode
342 *
343 */
344struct pldm_bios_table_attr_entry_integer_info {
345 uint16_t name_handle; //!< attribute name handle
346 bool read_only; //!< indicate whether the attribute is read-only
347 uint64_t lower_bound; //!< The lower bound on the integer value
348 uint64_t upper_bound; //!< The upper bound on the integer value
349 uint32_t scalar_increment; //!< The scalar value that is used for the
350 //!< increments to this integer
351 uint64_t default_value; //!< The default value of the integer
352};
353
John Wang827c5de2019-11-07 18:27:27 +0800354/** @brief Check fields in @ref pldm_bios_table_attr_entry_integer_info
355 * @param[in] info - Pointer to the pldm_bios_table_attr_entry_integer_info
356 * @param[out] errmsg - Pointer to an errmsg stored in the statically allocated
357 * memory
358 * @return pldm_completion_codes
359 */
360int pldm_bios_table_attr_entry_integer_info_check(
361 const struct pldm_bios_table_attr_entry_integer_info *info,
362 const char **errmsg);
363
John Wangca230822019-10-16 11:39:27 +0800364/** @brief Get length that an attribute entry(type: integer) will take
365 * @return The length that an entry(type: integer) will take
366 */
367size_t pldm_bios_table_attr_entry_integer_encode_length();
368
369/** @brief Create an entry of BIOS Attribute Table (type: integer)
370 * @param[out] entry - Pointer to a buffer to create an entry
371 * @param[in] entry_length - Length of the buffer to create an entry
372 * @param[in] info - Pointer to an auxiliary structure @ref
373 * pldm_bios_table_attr_entry_integer_info
374 */
375void pldm_bios_table_attr_entry_integer_encode(
376 void *entry, size_t entry_length,
377 const struct pldm_bios_table_attr_entry_integer_info *info);
378
379/** @brief Create an entry of BIOS Attribute Table (type: integer) and check the
380 * validity of the parameters
381 * @param[out] entry - Pointer to a buffer to create an entry
382 * @param[in] entry_length - Length of the buffer to create an entry
383 * @param[in] info - Pointer to an auxiliary structure @ref
384 * pldm_bios_table_attr_entry_integer_info
385 * @return pldm_completion_codes
386 */
387int pldm_bios_table_attr_entry_integer_encode_check(
388 void *entry, size_t entry_length,
389 const struct pldm_bios_table_attr_entry_integer_info *info);
390
John Wang3ad21752019-10-06 16:42:21 +0800391/** @brief Get length that an attribute value entry(type: enum) will take
392 * @param[in] count - Total number of current values for this enumeration
393 * @return The length that an entry(type: enum) will take
394 */
395size_t pldm_bios_table_attr_value_entry_encode_enum_length(uint8_t count);
396
397/** @brief Create an attribute value entry(type: enum)
398 * @param[out] entry - Pointer to bios attribute value entry
399 * @param[in] entry_length - Length of attribute value entry
400 * @param[in] attr_handle - This handle points to an attribute in the
401 * BIOS Attribute Vlaue Table.
402 * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
403 * Table
404 * @param[in] count - Total number of current values for this enum attribute
405 * @param[in] handle_indexes - Index into the array(provided in the BIOS
406 * Attribute Table) of the possible values of string handles for this attribute.
407 */
408void pldm_bios_table_attr_value_entry_encode_enum(
409 void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
410 uint8_t count, uint8_t *handle_indexes);
411
John Wang49484a12019-12-02 14:21:53 +0800412/** @brief Get number of current values for the enum entry
413 * @param[in] entry - Pointer to bios attribute value table entry
414 * @return Total number of current values for this enumeration
415 */
416uint8_t pldm_bios_table_attr_value_entry_enum_decode_number(
417 const struct pldm_bios_attr_val_table_entry *entry);
418
John Wang3ad21752019-10-06 16:42:21 +0800419/** @brief Create an attribute value entry(type: enum) and check the validity of
420 * the parameters
421 * @param[out] entry - Pointer to bios attribute value entry
422 * @param[in] entry_length - Length of attribute value entry
423 * @param[in] attr_handle - This handle points to an attribute in the
424 * BIOS Attribute Vlaue Table.
425 * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
426 * Table
427 * @param[in] count - Total number of current values for this enum attribute
428 * @param[in] handle_indexes - Index into the array(provided in the BIOS
429 * Attribute Table) of the possible values of string handles for this attribute.
430 * @return pldm_completion_codes
431 */
432int pldm_bios_table_attr_value_entry_encode_enum_check(
433 void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
434 uint8_t count, uint8_t *handle_indexes);
435
436/** @brief Get length that an attribute value entry(type: string) will take
437 * @param[in] string_length - Length of the current string in byte, 0 indicates
438 * that the current string value is not set.
439 * @return The length that an entry(type: string) will take
440 */
441size_t
442pldm_bios_table_attr_value_entry_encode_string_length(uint16_t string_length);
443
444/** @brief Create an attribute value entry(type: string)
445 * @param[out] entry - Pointer to bios attribute value entry
446 * @param[in] entry_length - Length of attribute value entry
447 * @param[in] attr_handle - This handle points to an attribute in the
448 * BIOS Attribute Vlaue Table.
449 * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
450 * Table
451 * @param[in] string_length - Length of current string in bytes. 0 indicates
452 * that the current string value is not set.
453 * @param[in] string - The current string itsel
454 */
455void pldm_bios_table_attr_value_entry_encode_string(
456 void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
457 uint16_t string_length, const char *string);
John Wang49484a12019-12-02 14:21:53 +0800458
459/** @brief Get length of the current string in bytes
460 * @param [in] entry - Pointer to bios attribute value table entry
461 * @return The length of the current string in bytes
462 */
463uint16_t pldm_bios_table_attr_value_entry_string_decode_length(
464 const struct pldm_bios_attr_val_table_entry *entry);
465
John Wang3ad21752019-10-06 16:42:21 +0800466/** @brief Create an attribute value entry(type: string) and check the validity
467 * of the parameters
468 * @param[out] entry - Pointer to bios attribute value entry
469 * @param[in] entry_length - Length of attribute value entry
470 * @param[in] attr_handle - This handle points to an attribute in the
471 * BIOS Attribute Vlaue Table.
472 * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
473 * Table
474 * @param[in] string_length - Length of current string in bytes. 0 indicates
475 * that the current string value is not set.
476 * @param[in] string - The current string itsel
477 * @return pldm_completion_codes
478 */
479int pldm_bios_table_attr_value_entry_encode_string_check(
480 void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
481 uint16_t string_length, const char *string);
482
John Wangca230822019-10-16 11:39:27 +0800483/** @brief Get length that an attribute value entry(type: integer) will take
484 * @return The length that an entry(type: integer) will take
485 */
486size_t pldm_bios_table_attr_value_entry_encode_integer_length();
487
488/** @brief Create an attribute value entry(type: integer)
489 * @param[out] entry - Pointer to bios attribute value entry
490 * @param[in] entry_length - Length of attribute value entry
491 * @param[in] attr_handle - This handle points to an attribute in the
492 * BIOS Attribute Vlaue Table.
493 * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
494 * Table
495 * @param[in] cv - Current Value
496 */
497void pldm_bios_table_attr_value_entry_encode_integer(void *entry,
498 size_t entry_length,
499 uint16_t attr_handle,
500 uint8_t attr_type,
501 uint64_t cv);
502
503/** @brief Create an attribute value entry(type: integer) and check the validity
504 * of the parameters
505 * @param[out] entry - Pointer to bios attribute value entry
506 * @param[in] entry_length - Length of attribute value entry
507 * @param[in] attr_handle - This handle points to an attribute in the
508 * BIOS Attribute Vlaue Table.
509 * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
510 * Table
511 * @param[in] cv - Current Value
512 * @return pldm_completion_codes
513 */
514int pldm_bios_table_attr_value_entry_encode_integer_check(void *entry,
515 size_t entry_length,
516 uint16_t attr_handle,
517 uint8_t attr_type,
518 uint64_t cv);
John Wang79c37f12019-10-31 15:46:31 +0800519
John Wang3342adb2019-11-29 16:03:58 +0800520/** @brief Get the handle from the attribute value entry
521 * @param[in] entry - Pointer to bios attribute value entry
522 * @return handle to identify the attribute in the attribute value table
523 */
524uint16_t pldm_bios_table_attr_value_entry_decode_handle(
525 const struct pldm_bios_attr_val_table_entry *entry);
526
John Wang8e877e02020-02-03 16:06:55 +0800527/** @brief Get the length of the attribute value entry
John Wang3342adb2019-11-29 16:03:58 +0800528 * @param[in] entry - Pointer to bios attribute value entry
John Wang8e877e02020-02-03 16:06:55 +0800529 * @return Length of the entry
John Wang3342adb2019-11-29 16:03:58 +0800530 */
John Wang8e877e02020-02-03 16:06:55 +0800531size_t pldm_bios_table_attr_value_entry_length(
John Wang3342adb2019-11-29 16:03:58 +0800532 const struct pldm_bios_attr_val_table_entry *entry);
533
534/** @brief Find an entry in attribute value table by handle
535 * @param[in] table - The BIOS Attribute Value Table
536 * @param[in] length - Length of the BIOS Attribute Value Table
537 * @param[in] handle - handle to identify the attribute in the attribute value
538 * table
539 * @return Pointer to the entry
540 */
541const struct pldm_bios_attr_val_table_entry *
542pldm_bios_table_attr_value_find_by_handle(const void *table, size_t length,
543 uint16_t handle);
544
John Wang79c37f12019-10-31 15:46:31 +0800545/** @brief Get the size of pad and checksum
546 * @param[in] size_without_pad - Table size without pad
547 * @return The size of pad and checksum
548 */
549size_t pldm_bios_table_pad_checksum_size(size_t size_without_pad);
550
551/** @brief Append pad and checksum at the end of the table
552 * @param[in,out] table - Pointer to a buffer of a bios table
553 * @param[in] size - Size of the buffer of a bios table
554 * @param[in] size_without_pad - Table size without pad and checksum
John Wang871c9272019-12-09 18:02:15 +0800555 * @return Total size of the table
John Wang79c37f12019-10-31 15:46:31 +0800556 */
John Wang871c9272019-12-09 18:02:15 +0800557size_t pldm_bios_table_append_pad_checksum(void *table, size_t size,
558 size_t size_without_pad);
559
560/** @brief Build a new table and update an entry
561 * @param[in] src_table - Pointer to the source table
562 * @param[in] src_length - Size of the source table
563 * @param[out] dest_table - Pointer to the buffer of destination table
564 * @param[in,out] dest_length - Buffer size of the destination table as input
565 * parameter and will be assigned the length of
566 * the new table, if the function returns
567 * PLDM_SUCCESS
568 * @param[in] entry - Pointer to an entry
569 * @param[in] entry_length - Size of the entry
570 * @return pldm_completion_codes
571 */
572int pldm_bios_table_attr_value_copy_and_update(
573 const void *src_table, size_t src_length, void *dest_table,
574 size_t *dest_length, const void *entry, size_t entry_length);
John Wang79c37f12019-10-31 15:46:31 +0800575
John Wang02700402019-10-06 16:34:29 +0800576#ifdef __cplusplus
577}
578#endif
579
580#endif