summaryrefslogtreecommitdiff
path: root/include/cros_board_info.h
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-02-14 15:20:09 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-16 18:47:52 -0800
commit5946911129779469abc40e40beb278c1685af462 (patch)
tree2276e781353f50c02daef46f22c10e54087d77d7 /include/cros_board_info.h
parentf29bf0fbbd0e83fcae6dd71cb2bc23647c80b8be (diff)
downloadchrome-ec-5946911129779469abc40e40beb278c1685af462.tar.gz
CBI: Make data offset and size variable
Currently CBI data offset and size are fixed. This patch makes them variable. Each data item consists of <tag><size><value> where <tag> is a numeric value assigned to each data item, <size> is the number of bytes used for <value>. BUG=b:70294260 BRANCH=none TEST=Use 'ectool cbi set' to set board version, oem, sku. Verify the contents by cbi console command and ectool cbi get. 1. ectool cbi set 0 0x202 2 2 (Init CBI and write board ver. of size 2) 2. ectool cbi set 1 1 1 (write oem id of size 1) 3. ectool cbi set 2 2 1 (write sku id of size 1) 4. ectool cbi get 0 514 (0x202) 5. ectool cbi get 1 1 (0x1) 6. ectool cbi get 2 2 (0x2) 7. Run cbi console command: CBI_VERSION: 0x0000 TOTAL_SIZE: 18 BOARD_VERSION: 514 (0x202) OEM_ID: 1 (0x1) SKU_ID: 2 (0x2) 43 42 49 8c 00 00 12 00 00 02 02 02 01 01 01 02 01 02 Change-Id: I5a30a4076e3eb448f4808d2af8ec4ef4c016ae5e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/920905 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'include/cros_board_info.h')
-rw-r--r--include/cros_board_info.h37
1 files changed, 21 insertions, 16 deletions
diff --git a/include/cros_board_info.h b/include/cros_board_info.h
index 8d140f1d25..eb239f9696 100644
--- a/include/cros_board_info.h
+++ b/include/cros_board_info.h
@@ -8,9 +8,11 @@
#define __CROS_EC_CROS_BOARD_INFO_H
#include "common.h"
+#include "ec_commands.h"
-#define CBI_VERSION_MAJOR 0
-#define CBI_VERSION_MINOR 0
+#define CBI_VERSION_MAJOR 0
+#define CBI_VERSION_MINOR 0
+#define CBI_EEPROM_SIZE 256
static const uint8_t cbi_magic[] = { 0x43, 0x42, 0x49 }; /* 'C' 'B' 'I' */
struct cbi_header {
@@ -29,22 +31,14 @@ struct cbi_header {
/* Total size of data. It can be larger than sizeof(struct board_info)
* if future versions add additional fields. */
uint16_t total_size;
+ /* List of data items (i.e. struct cbi_data[]) */
+ uint8_t data[];
} __attribute__((packed));
-struct board_info {
- struct cbi_header head;
- /* Board version */
- union {
- struct {
- uint8_t minor_version;
- uint8_t major_version;
- };
- uint16_t version;
- };
- /* OEM ID */
- uint8_t oem_id;
- /* SKU ID */
- uint8_t sku_id;
+struct cbi_data {
+ uint8_t tag; /* enum cbi_data_tag */
+ uint8_t size; /* size of value[] */
+ uint8_t value[]; /* data value */
} __attribute__((packed));
/**
@@ -57,4 +51,15 @@ int cbi_get_board_version(uint32_t *version);
int cbi_get_sku_id(uint32_t *sku_id);
int cbi_get_oem_id(uint32_t *oem_id);
+/**
+ * Primitive accessors
+ *
+ * @param tag Tag of the target data.
+ * @param buf Buffer where data is passed.
+ * @param size (IN) Size of <buf>. (OUT) Size of the data returned.
+ * @return EC_SUCCESS on success or EC_ERROR_* otherwise.
+ */
+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);
+
#endif /* __CROS_EC_CROS_BOARD_INFO_H */