bootmenu: add removable media entries
UEFI specification requires booting from removal media using
a architecture-specific default image name such as BOOTAA64.EFI.
This commit adds the removable media entries into bootmenu,
so that user can select the removable media and boot with
default image.
The bootmenu automatically enumerates the possible bootable
media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL,
add it as new UEFI boot option(BOOT####) and update BootOrder
variable. This automatically generated UEFI boot option
has the dedicated guid in the optional_data to distinguish it from
the UEFI boot option user adds manually. This optional_data is
removed when the efi bootmgr loads the selected UEFI boot option.
This commit also provides the BOOT#### variable maintenance feature.
Depending on the system hardware setup, some devices
may not exist at a later system boot, so bootmenu checks the
available device in each bootmenu invocation and automatically
removes the BOOT#### variable corrensponding to the non-existent
media device.
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 704d36d..3340be1 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -7,7 +7,7 @@
#include <common.h>
#include <command.h>
#include <ansi.h>
-#include <efi_loader.h>
+#include <efi_config.h>
#include <efi_variable.h>
#include <env.h>
#include <log.h>
@@ -220,7 +220,7 @@
return 1;
}
-#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
+#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && (CONFIG_IS_ENABLED(CMD_EFICONFIG))
/**
* prepare_uefi_bootorder_entry() - generate the uefi bootmenu entries
*
@@ -340,11 +340,21 @@
if (ret < 0)
goto cleanup;
-#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
+#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && (CONFIG_IS_ENABLED(CMD_EFICONFIG))
if (i < MAX_COUNT - 1) {
- ret = prepare_uefi_bootorder_entry(menu, &iter, &i);
- if (ret < 0 && ret != -ENOENT)
- goto cleanup;
+ efi_status_t efi_ret;
+
+ /*
+ * UEFI specification requires booting from removal media using
+ * a architecture-specific default image name such as BOOTAA64.EFI.
+ */
+ efi_ret = eficonfig_generate_media_device_boot_option();
+ if (efi_ret != EFI_SUCCESS && efi_ret != EFI_NOT_FOUND)
+ goto cleanup;
+
+ ret = prepare_uefi_bootorder_entry(menu, &iter, &i);
+ if (ret < 0 && ret != -ENOENT)
+ goto cleanup;
}
#endif