diff options
Diffstat (limited to 'util/cbi-util.c')
-rw-r--r-- | util/cbi-util.c | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/util/cbi-util.c b/util/cbi-util.c index fe0c4c2bce..5bea9a04b9 100644 --- a/util/cbi-util.c +++ b/util/cbi-util.c @@ -1,4 +1,4 @@ -/* Copyright 2018 The Chromium OS Authors. All rights reserved. +/* Copyright 2018 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -20,10 +20,10 @@ #include "cros_board_info.h" #include "crc8.h" -#define ARGS_MASK_BOARD_VERSION BIT(0) -#define ARGS_MASK_FILENAME BIT(1) -#define ARGS_MASK_SIZE BIT(2) -#define ARGS_MASK_SKU_ID BIT(3) +#define ARGS_MASK_BOARD_VERSION BIT(0) +#define ARGS_MASK_FILENAME BIT(1) +#define ARGS_MASK_SIZE BIT(2) +#define ARGS_MASK_SKU_ID BIT(3) /* TODO: Set it by macro */ const char cmd_name[] = "cbi-util"; @@ -41,6 +41,7 @@ enum { OPT_PCB_SUPPLIER, OPT_SSFC, OPT_REWORK_ID, + OPT_FACTORY_CALIBRATION_DATA, OPT_SIZE, OPT_ERASE_BYTE, OPT_SHOW_ALL, @@ -48,27 +49,26 @@ enum { }; static const struct option opts_create[] = { - {"file", 1, 0, OPT_FILENAME}, - {"board_version", 1, 0, OPT_BOARD_VERSION}, - {"oem_id", 1, 0, OPT_OEM_ID}, - {"sku_id", 1, 0, OPT_SKU_ID}, - {"dram_part_num", 1, 0, OPT_DRAM_PART_NUM}, - {"oem_name", 1, 0, OPT_OEM_NAME}, - {"model_id", 1, 0, OPT_MODEL_ID}, - {"fw_config", 1, 0, OPT_FW_CONFIG}, - {"pcb_supplier", 1, 0, OPT_PCB_SUPPLIER}, - {"ssfc", 1, 0, OPT_SSFC}, - {"rework_id", 1, 0, OPT_REWORK_ID}, - {"size", 1, 0, OPT_SIZE}, - {"erase_byte", 1, 0, OPT_ERASE_BYTE}, - {NULL, 0, 0, 0} + { "file", 1, 0, OPT_FILENAME }, + { "board_version", 1, 0, OPT_BOARD_VERSION }, + { "oem_id", 1, 0, OPT_OEM_ID }, + { "sku_id", 1, 0, OPT_SKU_ID }, + { "dram_part_num", 1, 0, OPT_DRAM_PART_NUM }, + { "oem_name", 1, 0, OPT_OEM_NAME }, + { "model_id", 1, 0, OPT_MODEL_ID }, + { "fw_config", 1, 0, OPT_FW_CONFIG }, + { "pcb_supplier", 1, 0, OPT_PCB_SUPPLIER }, + { "ssfc", 1, 0, OPT_SSFC }, + { "rework_id", 1, 0, OPT_REWORK_ID }, + { "factory_calibration_data", 1, 0, OPT_FACTORY_CALIBRATION_DATA }, + { "size", 1, 0, OPT_SIZE }, + { "erase_byte", 1, 0, OPT_ERASE_BYTE }, + { NULL, 0, 0, 0 } }; -static const struct option opts_show[] = { - {"file", 1, 0, OPT_FILENAME}, - {"all", 0, 0, OPT_SHOW_ALL}, - {NULL, 0, 0, 0} -}; +static const struct option opts_show[] = { { "file", 1, 0, OPT_FILENAME }, + { "all", 0, 0, OPT_SHOW_ALL }, + { NULL, 0, 0, 0 } }; static const char *field_name[] = { /* Same order as enum cbi_data_tag */ @@ -82,6 +82,7 @@ static const char *field_name[] = { "PCB_SUPPLIER", "SSFC", "REWORK_ID", + "FACTORY_CALIBRATION_DATA", }; BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT); @@ -105,6 +106,7 @@ const char help_create[] = " --pcb_supplier <value> PCB supplier\n" " --ssfc <value> Second Source Factory Cache bit-field\n" " --rework_id <lvalue> REWORK_ID\n" + " --factory_calibration_data <value> Factory calibration data\n" "\n" "<value> must be a positive integer <= 0XFFFFFFFF, <lvalue> must be a\n" " positive integer <= 0xFFFFFFFFFFFFFFFF and field size can be\n" @@ -147,8 +149,9 @@ static void print_help_show(void) static void print_help(void) { printf("\nUsage: %s <create|show> [ARGS]\n" - "\n" - "Utility for CBI:Cros Board Info images.\n", cmd_name); + "\n" + "Utility for CBI:Cros Board Info images.\n", + cmd_name); print_help_create(); print_help_show(); } @@ -314,6 +317,7 @@ static int cmd_create(int argc, char **argv) struct integer_field pcb_supplier; struct integer_field ssfc; struct long_integer_field rework; + struct integer_field factory_calibration_data; const char *dram_part_num; const char *oem_name; } bi; @@ -398,11 +402,16 @@ static int cmd_create(int argc, char **argv) if (parse_uint64_field(optarg, &bi.rework)) return -1; break; + case OPT_FACTORY_CALIBRATION_DATA: + if (parse_integer_field(optarg, + &bi.factory_calibration_data)) + return -1; + break; } } if (set_mask != (ARGS_MASK_BOARD_VERSION | ARGS_MASK_FILENAME | - ARGS_MASK_SIZE | ARGS_MASK_SKU_ID)) { + ARGS_MASK_SIZE | ARGS_MASK_SKU_ID)) { fprintf(stderr, "Missing required arguments\n"); print_help_create(); return -1; @@ -427,9 +436,12 @@ static int cmd_create(int argc, char **argv) p = cbi_set_data(p, CBI_TAG_FW_CONFIG, &bi.fw_config.val, bi.fw_config.size); p = cbi_set_data(p, CBI_TAG_PCB_SUPPLIER, &bi.pcb_supplier.val, - bi.pcb_supplier.size); + bi.pcb_supplier.size); p = cbi_set_data(p, CBI_TAG_SSFC, &bi.ssfc.val, bi.ssfc.size); p = cbi_set_data(p, CBI_TAG_REWORK_ID, &bi.rework.val, bi.rework.size); + p = cbi_set_data(p, CBI_TAG_FACTORY_CALIBRATION_DATA, + &bi.factory_calibration_data.val, + bi.factory_calibration_data.size); p = cbi_set_string(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num); p = cbi_set_string(p, CBI_TAG_OEM_NAME, bi.oem_name); @@ -460,7 +472,7 @@ static void print_string(const uint8_t *buf, enum cbi_data_tag tag) name = d->tag < CBI_TAG_COUNT ? field_name[d->tag] : "???"; printf(" %s: %.*s (%u, %u)\n", name, d->size, (const char *)d->value, - d->tag, d->size); + d->tag, d->size); } static void print_integer(const uint8_t *buf, enum cbi_data_tag tag) @@ -489,12 +501,12 @@ static void print_integer(const uint8_t *buf, enum cbi_data_tag tag) v = *(uint64_t *)d->value; break; default: - printf(" %s: Integer of size %d not supported\n", - name, d->size); + printf(" %s: Integer of size %d not supported\n", name, + d->size); return; } printf(" %s: %llu (0x%llx, %u, %u)\n", name, (unsigned long long)v, - (unsigned long long)v, d->tag, d->size); + (unsigned long long)v, d->tag, d->size); } static int cmd_show(int argc, char **argv) @@ -564,6 +576,7 @@ static int cmd_show(int argc, char **argv) print_integer(buf, CBI_TAG_PCB_SUPPLIER); print_integer(buf, CBI_TAG_SSFC); print_integer(buf, CBI_TAG_REWORK_ID); + print_integer(buf, CBI_TAG_FACTORY_CALIBRATION_DATA); print_string(buf, CBI_TAG_DRAM_PART_NUM); print_string(buf, CBI_TAG_OEM_NAME); |