diff options
author | Furquan Shaikh <furquan@google.com> | 2019-03-06 14:44:37 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-08 21:20:36 -0800 |
commit | c67a566dbcca552b3d7cea57832685c2a83033d6 (patch) | |
tree | dc358e43acf0bc4e9ccf7b1df220f6897caf406f /include/cros_board_info.h | |
parent | 03e1bfd9a375d52236323978e151ed6fdc68a59a (diff) | |
download | chrome-ec-c67a566dbcca552b3d7cea57832685c2a83033d6.tar.gz |
cbi: Add a new API for cbi_set_string
This change introduces cbi_set_string that can be used by callers to
add string data to CBI. Internally, this function ensures that the
data is not NULL and call cbi_set_data for the string with a size of
strlen + 1. It is added so that callers don't have to repeat the same
operations for string data.
BUG=b:124282048
BRANCH=None
TEST=None
Change-Id: Iad9da206c5e87735eac3adee6fce151fd1f0a53a
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1506440
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include/cros_board_info.h')
-rw-r--r-- | include/cros_board_info.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/cros_board_info.h b/include/cros_board_info.h index 8ed8737731..e7a1f1bb48 100644 --- a/include/cros_board_info.h +++ b/include/cros_board_info.h @@ -90,6 +90,22 @@ uint8_t *cbi_set_data(uint8_t *p, enum cbi_data_tag tag, const void *buf, int size); /** + * Store string data in memory in CBI data format. + * + * @param p Pointer to the buffer where a new data item will be stored. It + * should be pointing to the data section of CBI. + * @param tag Tag of the data item + * @param str Pointer to the string data being copied. If pointer is NULL, + * this function will ignore adding the tag as well. Else, the + * string data will be added to CBI using size of strlen + 1. This + * string is assumed to be NUL-terminated and NUL gets stored in + * CBI along with the string data. + * @return Address of the byte following the stored data in the destination + * buffer. + */ +uint8_t *cbi_set_string(uint8_t *p, enum cbi_data_tag tag, const char *str); + +/** * Find a data field in CBI * * @param cbi Buffer containing CBI struct |