All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/1] eficonfig: Add a 'scan-only' mode in eficonfig
@ 2023-03-01 14:44 Ilias Apalodimas
  2023-03-02  2:21 ` Masahisa Kojima
  0 siblings, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2023-03-01 14:44 UTC (permalink / raw)
  To: u-boot; +Cc: masahisa.kojima, Ilias Apalodimas, Heinrich Schuchardt

eficonfig will automatically scan and add Boot#### variables on launch.
It will also perform automatic management of the automatically added
variables (e.g it might decide to delete a boot option if the DP
disappears).  This functionality is useful outside the context of
eficonfig as well.

So let's add a -a flag to eficonfig that will only perform the
automatic variable management and exit.  That would allow users
to define a bootcmd along the lines of 'eficonfig -a && bootefi bootmgr',
that matches the §3.5.1.1 'Removable Media Boot Behavior' behaviour
described in the EFI spec.

Open questions:
- Is this ok to add on eficonfig? Similar functionality is described in the EFI
  spec as part of the efibootmgr
- Having the functionality on the command gives us the flexibility to run the
  run the command when needed.  Alternatively we could move it to the efibootmgr
  and hide it behing a Kconfig option
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 cmd/eficonfig.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 720f52b48b8c..9b6631816997 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -2693,10 +2693,18 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a
 {
 	efi_status_t ret;
 	struct efimenu *efi_menu;
+	bool exit_on_scan = false;

-	if (argc > 1)
+	if (argc > 2)
 		return CMD_RET_USAGE;

+	if (argc > 1) {
+		if (!strcmp(argv[1], "-a"))
+			exit_on_scan = true;
+		else
+			return CMD_RET_FAILURE;
+	}
+
 	ret = efi_init_obj_list();
 	if (ret != EFI_SUCCESS) {
 		log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n",
@@ -2713,6 +2721,9 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a
 	if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
 		return ret;

+	if (exit_on_scan)
+		return EFI_SUCCESS;
+
 	while (1) {
 		efi_menu = eficonfig_create_fixed_menu(maintenance_menu_items,
 						       ARRAY_SIZE(maintenance_menu_items));
@@ -2734,8 +2745,14 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a
 	return CMD_RET_SUCCESS;
 }

+static char eficonfig_help_text[] =
+	" - UEFI menu to configure UEFI variables\n"
+	"\n"
+	"eficonfig - Spawn the configuration menu\n"
+	"  -a Scan, configure Boot#### variables and exit\n";
+
 U_BOOT_CMD(
-	eficonfig, 1, 0, do_eficonfig,
+	eficonfig, 2, 0, do_eficonfig,
 	"provide menu-driven UEFI variable maintenance interface",
-	""
+	eficonfig_help_text
 );
--
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-02  9:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-01 14:44 [RFC PATCH 1/1] eficonfig: Add a 'scan-only' mode in eficonfig Ilias Apalodimas
2023-03-02  2:21 ` Masahisa Kojima
2023-03-02  6:44   ` AKASHI Takahiro
2023-03-02  9:07     ` Ilias Apalodimas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.