From cafe8712e8143ae8e5e5d733d74bc46bffe0be92 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 30 Jul 2022 15:52:04 -0600 Subject: video: Renname vbe.h to vesa.h We want to use VBE to mean Verfiied Boot for Embedded in U-Boot. Rename the existing VBE (Vesa BIOS extensions) to allow this. Verified Boot for Embedded is documented doc/develop/vbe.rst Signed-off-by: Simon Glass --- cmd/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/elf.c b/cmd/elf.c index 2b33c50bd02..ce40d3f72a7 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -14,7 +14,7 @@ #include #include #ifdef CONFIG_X86 -#include +#include #include #include #include -- cgit v1.2.3 From e141075f1c46a587960e1b0541494417243e6b90 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 30 Jul 2022 15:52:15 -0600 Subject: dm: core: Support sandbox with read interface Update the 'read' command to work correctly with sandbox. Signed-off-by: Simon Glass --- cmd/read.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/read.c b/cmd/read.c index 99c7e3854e1..fecfadaa1fa 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -10,6 +10,7 @@ #include #include +#include #include int do_read(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) @@ -45,7 +46,7 @@ int do_read(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 1; } - addr = (void *)hextoul(argv[3], NULL); + addr = map_sysmem(hextoul(argv[3], NULL), 0); blk = hextoul(argv[4], NULL); cnt = hextoul(argv[5], NULL); -- cgit v1.2.3 From bc06aa035d8f78a713a3d339d45f3d05ef0f0d67 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 30 Jul 2022 15:52:21 -0600 Subject: bootstd: Allow bootmeths to be marked as global The current way of handling things like EFI bootmgr is a bit odd, since that bootmeth handles selection of the bootdev itself. VBE needs to work the same way, so we should support it properly. Add a flag that indicates that the bootmeth is global, rather than being invoked on each bootdev. Provide a helper to read a bootflow from the bootmeth. Signed-off-by: Simon Glass --- cmd/bootmeth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/bootmeth.c b/cmd/bootmeth.c index c9a27fe8ac6..9fbcccdba7e 100644 --- a/cmd/bootmeth.c +++ b/cmd/bootmeth.c @@ -69,7 +69,9 @@ static int do_bootmeth_list(struct cmd_tbl *cmdtp, int flag, int argc, } } - if (order == -1) + if (ucp->flags & BOOTMETHF_GLOBAL) + printf("%5s", "glob"); + else if (order == -1) printf("%5s", "-"); else printf("%5x", order); -- cgit v1.2.3 From eccb25cd5922edebc15f135923aa2b4bbd26527d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 30 Jul 2022 15:52:23 -0600 Subject: bootstd: Allow the bootdev to be optional in bootflows With global bootmeths we want to scan without a bootdev. Update the logic to allow this. Change the bootflow command to show the bootdev only when valid. Signed-off-by: Simon Glass --- cmd/bootflow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/bootflow.c b/cmd/bootflow.c index af4b9c37323..47899245ee8 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -69,8 +69,8 @@ static void show_bootflow(int index, struct bootflow *bflow, bool errors) { printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, bflow->method->name, bootflow_state_get_name(bflow->state), - dev_get_uclass_name(dev_get_parent(bflow->dev)), bflow->part, - bflow->name, bflow->fname); + bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) : + "(none)", bflow->part, bflow->name, bflow->fname); if (errors) report_bootflow_err(bflow, bflow->err); } -- cgit v1.2.3 From 2b80bc1eee28c20173c09ee5d887cce02097552f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 30 Jul 2022 15:52:25 -0600 Subject: bootstd: Support bootflows with global bootmeths Add support for handling this concept in bootflows. Update the 'bootflow' command to allow only the normal bootmeths to be used. This alllows skipping EFI bootmgr and VBE, for example. Signed-off-by: Simon Glass --- cmd/bootflow.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 47899245ee8..313103d2775 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -95,7 +95,8 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, struct bootflow_iter iter; struct udevice *dev; struct bootflow bflow; - bool all = false, boot = false, errors = false, list = false; + bool all = false, boot = false, errors = false, no_global = false; + bool list = false; int num_valid = 0; bool has_args; int ret, i; @@ -112,6 +113,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, all = strchr(argv[1], 'a'); boot = strchr(argv[1], 'b'); errors = strchr(argv[1], 'e'); + no_global = strchr(argv[1], 'G'); list = strchr(argv[1], 'l'); argc--; argv++; @@ -137,6 +139,8 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, flags |= BOOTFLOWF_SHOW; if (all) flags |= BOOTFLOWF_ALL; + if (no_global) + flags |= BOOTFLOWF_SKIP_GLOBAL; /* * If we have a device, just scan for bootflows attached to that device @@ -383,7 +387,7 @@ static int do_bootflow_boot(struct cmd_tbl *cmdtp, int flag, int argc, #ifdef CONFIG_SYS_LONGHELP static char bootflow_help_text[] = #ifdef CONFIG_CMD_BOOTFLOW_FULL - "scan [-abel] [bdev] - scan for valid bootflows (-l list, -a all, -e errors, -b boot)\n" + "scan [-abeGl] [bdev] - scan for valid bootflows (-l list, -a all, -e errors, -b boot, -G no global)\n" "bootflow list [-e] - list scanned bootflows (-e errors)\n" "bootflow select [|] - select a bootflow\n" "bootflow info [-d] - show info on current bootflow (-d dump bootflow)\n" -- cgit v1.2.3 From 5fe76d460d857b00d582d7cd6cea9ac740ea912b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 30 Jul 2022 15:52:37 -0600 Subject: 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 --- cmd/Kconfig | 10 +++++++ cmd/Makefile | 1 + cmd/vbe.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 cmd/vbe.c (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 7d19706a8ec..211ebe9c878 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -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 diff --git a/cmd/Makefile b/cmd/Makefile index 5e43a1e022e..6e87522b62e 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -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 diff --git a/cmd/vbe.c b/cmd/vbe.c new file mode 100644 index 00000000000..a5737edc047 --- /dev/null +++ b/cmd/vbe.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Verified Boot for Embedded (VBE) command + * + * Copyright 2022 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +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)); -- cgit v1.2.3