diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-02-22 09:25:50 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-23 03:36:35 -0800 |
commit | 546c606b5f0d4a3b8af54a17f5c729e670061fdc (patch) | |
tree | bb152d9c9e274976f0e3bc337e2042df6818f031 /include/cros_board_info.h | |
parent | d015bc937c0eecf1cb8f1b163874ea69c890dea4 (diff) | |
download | chrome-ec-546c606b5f0d4a3b8af54a17f5c729e670061fdc.tar.gz |
CBI: Share common code between host tool and firmware
This patch makes EC firmware and cbi-util share the common code.
BUG=b:70294260
BRANCH=none
TEST=Set fields using ectool. Verify the contents by cbi command.
Verify cbi-util creates the same binary as before.
Verify emerge ec-utils ec-devutils pass.
Change-Id: If5e65e48dd03960e0adf23ef775f67aecf785d85
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/932001
Diffstat (limited to 'include/cros_board_info.h')
-rw-r--r-- | include/cros_board_info.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/cros_board_info.h b/include/cros_board_info.h index eb239f9696..fb667ef899 100644 --- a/include/cros_board_info.h +++ b/include/cros_board_info.h @@ -62,4 +62,39 @@ int cbi_get_oem_id(uint32_t *oem_id); int cbi_get_board_info(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size); int cbi_set_board_info(enum cbi_data_tag tag, const uint8_t *buf, uint8_t size); +/* + * Utility functions + */ + +/** + * Calculate 8-bit CRC of CBI + * + * @param h Pointer to CBI header + * @return CRC value + */ +uint8_t cbi_crc8(const struct cbi_header *h); + +/** + * Store 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 buf Pointer to the buffer containing the data being copied. + * @param size Size of the data + * @return Address of the byte following the stored data in the + * destination buffer + */ +uint8_t *cbi_set_data(uint8_t *p, enum cbi_data_tag tag, + const void *buf, int size); + +/** + * Find a data field in CBI + * + * @param cbi Buffer containing CBI struct + * @param tag Tag of the data field to search + * @return Pointer to the data or NULL if not found. + */ +struct cbi_data *cbi_find_tag(const void *cbi, enum cbi_data_tag tag); + #endif /* __CROS_EC_CROS_BOARD_INFO_H */ |