diff options
author | Evan Benn <evanbenn@chromium.org> | 2023-01-12 17:22:57 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-13 15:50:18 +0000 |
commit | 43ab0587f36ef40aba334b94489dfe4225fe1bbb (patch) | |
tree | 0f94c40118cee9c0904a173a0fadcbb30778d088 /futility | |
parent | ea185f1c07a88e96ad7bd664a97582559dc6e53f (diff) | |
download | vboot-43ab0587f36ef40aba334b94489dfe4225fe1bbb.tar.gz |
2lib: Add vb2_get_gbb_flag_descriptionfirmware-ti50-prepvt-15315.B
Add a function to convert a gbb flag to the name and description of that
flag. Use this function in cmd_gbb to format a help page and implement
--explicit.
BUG=b:260531154
BRANCH=None
TEST=futility gbb --get /dev/bios -e
TEST=futility gbb --help
Change-Id: I884b6e0e7322128409f8d62d76824d8e6e6ca330
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4161092
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'futility')
-rw-r--r-- | futility/cmd_gbb_utility.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c index 3ca93b94..b40cceda 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -18,6 +18,7 @@ #include "futility.h" #include "updater.h" #include "updater_utils.h" +#include "2gbb_flags.h" #ifdef USE_FLASHROM #define FLASH_ARG_HELP \ @@ -50,6 +51,7 @@ static void print_help(int argc, char *argv[]) " -k, --rootkey=FILE \tFile name to export Root Key.\n" " -b, --bmpfv=FILE \tFile name to export Bitmap FV.\n" " -r --recoverykey=FILE\tFile name to export Recovery Key.\n" + " -e --explicit \tReport header flags by name.\n" "\n" "SET MODE:\n" "-s, --set \tSet (write) to flash or file, " @@ -71,8 +73,21 @@ static void print_help(int argc, char *argv[]) " %s -g bios.bin\n" " %s --set --hwid='New Model' -k key.bin" " bios.bin newbios.bin\n" - " %s -c 0x100,0x1000,0x03DE80,0x1000 gbb.blob\n\n", + " %s -c 0x100,0x1000,0x03DE80,0x1000 gbb.blob\n\n" + "GBB Flags:\n" + " To get a developer-friendly device, try 0x18 (dev_mode boot_usb).\n" + " For early bringup development, try 0x40b9.\n", argv[0], argv[0], argv[0], argv[0]); + for (vb2_gbb_flags_t flag = 1; flag; flag <<= 1) { + const char *name; + const char *description; + if (vb2_get_gbb_flag_description(flag, &name, &description) != + VB2_SUCCESS) + break; + printf(" 0x%08x\t%s\n" + " \t%s\n", + flag, name, description); + } } enum { @@ -96,13 +111,14 @@ static struct option long_opts[] = { {"recoverykey", 1, NULL, 'r'}, {"hwid", 0, NULL, OPT_HWID}, {"flags", 0, NULL, OPT_FLAGS}, + {"explicit", 0, NULL, 'e'}, {"digest", 0, NULL, OPT_DIGEST}, {"flash", 0, NULL, OPT_FLASH}, {"help", 0, NULL, OPT_HELP}, {NULL, 0, NULL, 0}, }; -static const char *short_opts = ":gsc:o:k:b:r:" SHARED_FLASH_ARGS_SHORTOPTS; +static const char *short_opts = ":gsc:o:k:b:r:e" SHARED_FLASH_ARGS_SHORTOPTS; /* Change the has_arg field of a long_opts entry */ static void opt_has_arg(const char *name, int val) @@ -443,6 +459,7 @@ static int do_gbb(int argc, char *argv[]) int sel_hwid = 0; int sel_digest = 0; int sel_flags = 0; + int explicit_flags = 0; uint8_t *inbuf = NULL; off_t filesize; uint8_t *outbuf = NULL; @@ -497,6 +514,10 @@ static int do_gbb(int argc, char *argv[]) opt_flags = optarg; sel_flags = 1; break; + case 'e': + sel_flags = 1; + explicit_flags = 1; + break; case OPT_DIGEST: sel_digest = 1; break; @@ -628,6 +649,24 @@ static int do_gbb(int argc, char *argv[]) errorcnt++; break; } + if (explicit_flags) { + vb2_gbb_flags_t remaining_flags = gbb->flags; + while (remaining_flags) { + vb2_gbb_flags_t lsb_flag = + remaining_flags & -remaining_flags; + remaining_flags &= ~lsb_flag; + const char *name; + const char *description; + if (vb2_get_gbb_flag_description( + lsb_flag, &name, &description) == + VB2_SUCCESS) { + printf("%s\n", name); + } else { + printf("unknown set flag: 0x%08x\n", + lsb_flag); + } + } + } break; case DO_SET: |