vbe: Add a new vbe command

Add a command to look at VBE methods and their status. Provide a test for
all of this as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2022-07-30 15:52:37 -06:00
committed by Tom Rini
parent 11361c5965
commit 5fe76d460d
4 changed files with 213 additions and 0 deletions

View File

@@ -330,6 +330,16 @@ config BOOTM_RTEMS
help
Support booting RTEMS images via the bootm command.
config CMD_VBE
bool "vbe - Verified Boot for Embedded"
depends on BOOTMETH_VBE
default y
help
Provides various subcommands related to VBE, such as listing the
available methods, looking at the state and changing which method
is used to boot. Updating the parameters is not currently
supported.
config BOOTM_VXWORKS
bool "Support booting VxWorks OS images"
depends on CMD_BOOTM

View File

@@ -179,6 +179,7 @@ obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o
obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o
obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
obj-$(CONFIG_CMD_VBE) += vbe.o
obj-$(CONFIG_CMD_XIMG) += ximg.o
obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o
obj-$(CONFIG_CMD_SPL) += spl.o

87
cmd/vbe.c Normal file
View File

@@ -0,0 +1,87 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Verified Boot for Embedded (VBE) command
*
* Copyright 2022 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <common.h>
#include <bootmeth.h>
#include <bootstd.h>
#include <command.h>
#include <vbe.h>
static int do_vbe_list(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
vbe_list();
return 0;
}
static int do_vbe_select(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
struct bootstd_priv *std;
struct udevice *dev;
int ret;
ret = bootstd_get_priv(&std);
if (ret)
return CMD_RET_FAILURE;
if (argc < 2) {
std->vbe_bootmeth = NULL;
return 0;
}
if (vbe_find_by_any(argv[1], &dev))
return CMD_RET_FAILURE;
std->vbe_bootmeth = dev;
return 0;
}
static int do_vbe_info(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
struct bootstd_priv *std;
char buf[256];
int ret, len;
ret = bootstd_get_priv(&std);
if (ret)
return CMD_RET_FAILURE;
if (!std->vbe_bootmeth) {
printf("No VBE bootmeth selected\n");
return CMD_RET_FAILURE;
}
ret = bootmeth_get_state_desc(std->vbe_bootmeth, buf, sizeof(buf));
if (ret) {
printf("Failed (err=%d)\n", ret);
return CMD_RET_FAILURE;
}
len = strnlen(buf, sizeof(buf));
if (len >= sizeof(buf)) {
printf("Buffer overflow\n");
return CMD_RET_FAILURE;
}
puts(buf);
if (buf[len] != '\n')
putc('\n');
return 0;
}
#ifdef CONFIG_SYS_LONGHELP
static char vbe_help_text[] =
"list - list VBE bootmeths\n"
"vbe select - select a VBE bootmeth by sequence or name\n"
"vbe info - show information about a VBE bootmeth";
#endif
U_BOOT_CMD_WITH_SUBCMDS(vbe, "Verified Boot for Embedded", vbe_help_text,
U_BOOT_SUBCMD_MKENT(list, 1, 1, do_vbe_list),
U_BOOT_SUBCMD_MKENT(select, 2, 1, do_vbe_select),
U_BOOT_SUBCMD_MKENT(info, 2, 1, do_vbe_info));