drivers/option: Add forms in cbtables
[coreboot2.git] / util / cbfstool / flashmap / valstr.h
blob200d7df1d67fe0a211ef5e2dea45740d837b3878
1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #ifndef FLASHMAP_LIB_VALSTR_H__
4 #define FLASHMAP_LIB_VALSTR_H__
6 #include <inttypes.h>
8 /* value + string structure for common conversions */
9 struct valstr {
10 uint32_t val; /* field value */
11 const char *str; /* field description */
15 * val2str_default - convert value to string
17 * @val: value to convert
18 * @vs: value-string data
19 * @def_str: default string to return if no matching value found
21 * returns pointer to string
22 * returns def_str if no matching value found
24 const char *val2str_default(uint32_t val, const struct valstr *vs,
25 const char *def_str);
28 * val2str - convert value to string
30 * @val: value to convert
31 * @vs: value-string data
33 * returns pointer to string
34 * returns pointer to "unknown" static string if not found
36 const char *val2str(uint32_t val, const struct valstr *vs);
39 * str2val - convert string to value
41 * @str: string to convert
42 * @vs: value-string data
44 * returns value for string
45 * returns value for last entry in value-string data if not found
47 uint32_t str2val(const char *str, const struct valstr *vs);
49 #endif /* FLASHMAP_LIB_VALSTR_H__ */