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>
16 static int do_vbe_list(struct cmd_tbl *cmdtp, int flag, int argc,
24 static int do_vbe_select(struct cmd_tbl *cmdtp, int flag, int argc,
27 struct bootstd_priv *std;
31 ret = bootstd_get_priv(&std);
33 return CMD_RET_FAILURE;
35 std->vbe_bootmeth = NULL;
38 if (vbe_find_by_any(argv[1], &dev))
39 return CMD_RET_FAILURE;
41 std->vbe_bootmeth = dev;
46 static int do_vbe_info(struct cmd_tbl *cmdtp, int flag, int argc,
49 struct bootstd_priv *std;
53 ret = bootstd_get_priv(&std);
55 return CMD_RET_FAILURE;
56 if (!std->vbe_bootmeth) {
57 printf("No VBE bootmeth selected\n");
58 return CMD_RET_FAILURE;
60 ret = bootmeth_get_state_desc(std->vbe_bootmeth, buf, sizeof(buf));
62 printf("Failed (err=%d)\n", ret);
63 return CMD_RET_FAILURE;
65 len = strnlen(buf, sizeof(buf));
66 if (len >= sizeof(buf)) {
67 printf("Buffer overflow\n");
68 return CMD_RET_FAILURE;
78 static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int argc,
81 struct vbe_handoff *handoff = NULL;
84 if (IS_ENABLED(CONFIG_BLOBLIST)) {
85 handoff = bloblist_find(BLOBLISTT_VBE,
86 sizeof(struct vbe_handoff));
89 printf("No VBE state\n");
90 return CMD_RET_FAILURE;
94 for (i = PHASE_NONE; i < PHASE_COUNT; i++) {
95 if (handoff->phases & (1 << i))
96 printf(" %s", spl_phase_name(i));
107 "list - list VBE bootmeths\n"
108 "vbe select - select a VBE bootmeth by sequence or name\n"
109 "vbe info - show information about a VBE bootmeth\n"
110 "vbe state - show VBE state");
112 U_BOOT_CMD_WITH_SUBCMDS(vbe, "Verified Boot for Embedded", vbe_help_text,
113 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_vbe_list),
114 U_BOOT_SUBCMD_MKENT(select, 2, 1, do_vbe_select),
115 U_BOOT_SUBCMD_MKENT(state, 2, 1, do_vbe_state),
116 U_BOOT_SUBCMD_MKENT(info, 2, 1, do_vbe_info));