1 // SPDX-License-Identifier: GPL-2.0+
3 * Verified Boot for Embedded (VBE) command
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
15 static int do_vbe_list(struct cmd_tbl *cmdtp, int flag, int argc,
23 static int do_vbe_select(struct cmd_tbl *cmdtp, int flag, int argc,
26 struct bootstd_priv *std;
30 ret = bootstd_get_priv(&std);
32 return CMD_RET_FAILURE;
34 std->vbe_bootmeth = NULL;
37 if (vbe_find_by_any(argv[1], &dev))
38 return CMD_RET_FAILURE;
40 std->vbe_bootmeth = dev;
45 static int do_vbe_info(struct cmd_tbl *cmdtp, int flag, int argc,
48 struct bootstd_priv *std;
52 ret = bootstd_get_priv(&std);
54 return CMD_RET_FAILURE;
55 if (!std->vbe_bootmeth) {
56 printf("No VBE bootmeth selected\n");
57 return CMD_RET_FAILURE;
59 ret = bootmeth_get_state_desc(std->vbe_bootmeth, buf, sizeof(buf));
61 printf("Failed (err=%d)\n", ret);
62 return CMD_RET_FAILURE;
64 len = strnlen(buf, sizeof(buf));
65 if (len >= sizeof(buf)) {
66 printf("Buffer overflow\n");
67 return CMD_RET_FAILURE;
77 #ifdef CONFIG_SYS_LONGHELP
78 static char vbe_help_text[] =
79 "list - list VBE bootmeths\n"
80 "vbe select - select a VBE bootmeth by sequence or name\n"
81 "vbe info - show information about a VBE bootmeth";
84 U_BOOT_CMD_WITH_SUBCMDS(vbe, "Verified Boot for Embedded", vbe_help_text,
85 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_vbe_list),
86 U_BOOT_SUBCMD_MKENT(select, 2, 1, do_vbe_select),
87 U_BOOT_SUBCMD_MKENT(info, 2, 1, do_vbe_info));