1 // SPDX-License-Identifier: GPL-2.0+
3 * Verified Boot for Embedded (VBE) command
5 * Copyright 2022 Google LLC
17 static int do_vbe_list(struct cmd_tbl *cmdtp, int flag, int argc,
25 static int do_vbe_select(struct cmd_tbl *cmdtp, int flag, int argc,
28 struct bootstd_priv *std;
32 ret = bootstd_get_priv(&std);
34 return CMD_RET_FAILURE;
36 std->vbe_bootmeth = NULL;
39 if (vbe_find_by_any(argv[1], &dev))
40 return CMD_RET_FAILURE;
42 std->vbe_bootmeth = dev;
47 static int do_vbe_info(struct cmd_tbl *cmdtp, int flag, int argc,
50 struct bootstd_priv *std;
54 ret = bootstd_get_priv(&std);
56 return CMD_RET_FAILURE;
57 if (!std->vbe_bootmeth) {
58 printf("No VBE bootmeth selected\n");
59 return CMD_RET_FAILURE;
61 ret = bootmeth_get_state_desc(std->vbe_bootmeth, buf, sizeof(buf));
63 printf("Failed (err=%d)\n", ret);
64 return CMD_RET_FAILURE;
66 len = strnlen(buf, sizeof(buf));
67 if (len >= sizeof(buf)) {
68 printf("Buffer overflow\n");
69 return CMD_RET_FAILURE;
79 static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int argc,
82 struct vbe_handoff *handoff = NULL;
85 if (IS_ENABLED(CONFIG_BLOBLIST)) {
86 handoff = bloblist_find(BLOBLISTT_VBE,
87 sizeof(struct vbe_handoff));
90 printf("No VBE state\n");
91 return CMD_RET_FAILURE;
95 for (i = PHASE_NONE; i < PHASE_COUNT; i++) {
96 if (handoff->phases & (1 << i))
97 printf(" %s", spl_phase_name(i));
100 if (!handoff->phases)
107 #ifdef CONFIG_SYS_LONGHELP
108 static char vbe_help_text[] =
109 "list - list VBE bootmeths\n"
110 "vbe select - select a VBE bootmeth by sequence or name\n"
111 "vbe info - show information about a VBE bootmeth\n"
112 "vbe state - show VBE state";
115 U_BOOT_CMD_WITH_SUBCMDS(vbe, "Verified Boot for Embedded", vbe_help_text,
116 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_vbe_list),
117 U_BOOT_SUBCMD_MKENT(select, 2, 1, do_vbe_select),
118 U_BOOT_SUBCMD_MKENT(state, 2, 1, do_vbe_state),
119 U_BOOT_SUBCMD_MKENT(info, 2, 1, do_vbe_info));