[PATCH] cmd/bootefi: correct command syntax

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Thu May 19 19:03:44 CEST 2022


For indicating the address and size of a memory region other commands use a
<addr>[:<size>] syntax. Do the same for bootefi.

Fixes: 2058983689f0 ("cmd: bootefi: restore ability to boot arbitrary blob")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 cmd/bootefi.c             | 21 +++++++++++++++------
 doc/usage/cmd/bootefi.rst |  8 ++++----
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index d80353fa71..827fcd97df 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -649,6 +649,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
 		      char *const argv[])
 {
 	efi_status_t ret;
+	char *img_addr, *img_size, *str_copy, *pos;
 	void *fdt;
 
 	if (argc < 2)
@@ -662,7 +663,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
 		return CMD_RET_FAILURE;
 	}
 
-	if (argc > 2 && strcmp(argv[2], "-")) {
+	if (argc > 2) {
 		uintptr_t fdt_addr;
 
 		fdt_addr = hextoul(argv[2], NULL);
@@ -684,16 +685,24 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
 	if (!strcmp(argv[1], "selftest"))
 		return do_efi_selftest();
 #endif
+	str_copy = strdup(argv[1]);
+	if (!str_copy) {
+		log_err("Out of memory\n");
+		return CMD_RET_FAILURE;
+	}
+	pos = str_copy;
+	img_addr = strsep(&pos, ":");
+	img_size = strsep(&pos, ":");
+	ret = do_bootefi_image(img_addr, img_size);
+	free(str_copy);
 
-	return do_bootefi_image(argv[1], argc > 3 ? argv[3] : NULL);
+	return ret;
 }
 
 #ifdef CONFIG_SYS_LONGHELP
 static char bootefi_help_text[] =
-	"<image address> [fdt address [image size]]\n"
-	"  - boot EFI payload stored at <image address>\n"
-	"    fdt address, address of device-tree or '-'\n"
-	"    image size, required if image not preloaded\n"
+	"<image address>[:<image size>] [<fdt address>]\n"
+	"  - boot EFI payload\n"
 #ifdef CONFIG_CMD_BOOTEFI_HELLO
 	"bootefi hello\n"
 	"  - boot a sample Hello World application stored within U-Boot\n"
diff --git a/doc/usage/cmd/bootefi.rst b/doc/usage/cmd/bootefi.rst
index 4cc8c0718c..cb03df4e1c 100644
--- a/doc/usage/cmd/bootefi.rst
+++ b/doc/usage/cmd/bootefi.rst
@@ -9,10 +9,10 @@ Synopsis
 
 ::
 
-    bootefi [image_addr] [fdt_addr [image_size]]
-    bootefi bootmgr [fdt_addr]
-    bootefi hello [fdt_addr]
-    bootefi selftest [fdt_addr]
+    bootefi <image_addr>[:<image_size>] [<fdt_addr>]
+    bootefi bootmgr [<fdt_addr>]
+    bootefi hello [<fdt_addr>]
+    bootefi selftest [<fdt_addr>]
 
 Description
 -----------
-- 
2.34.1



More information about the U-Boot mailing list