]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootstd: Make efi_mgr bootmeth work for non-sandbox setups
authorMark Kettenis <kettenis@openbsd.org>
Sun, 3 Sep 2023 20:40:00 +0000 (22:40 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 1 Nov 2023 16:26:44 +0000 (12:26 -0400)
Enable the bootflow based on this bootmeth if the BootOrder EFI
variable is set.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
boot/bootmeth_efi_mgr.c

index e9d973429f75ebd7d8a6d8362b2c712cce85a005..e6c42d41fb804b18b5f1f2ba4ffb4e6293e1126e 100644 (file)
@@ -14,6 +14,8 @@
 #include <bootmeth.h>
 #include <command.h>
 #include <dm.h>
+#include <efi_loader.h>
+#include <efi_variable.h>
 
 /**
  * struct efi_mgr_priv - private info for the efi-mgr driver
@@ -46,13 +48,26 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
 static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
        struct efi_mgr_priv *priv = dev_get_priv(dev);
+       efi_status_t ret;
+       efi_uintn_t size;
+       u16 *bootorder;
 
        if (priv->fake_dev) {
                bflow->state = BOOTFLOWST_READY;
                return 0;
        }
 
-       /* To be implemented */
+       ret = efi_init_obj_list();
+       if (ret)
+               return log_msg_ret("init", ret);
+
+       /* Enable this method if the "BootOrder" UEFI exists. */
+       bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid,
+                               &size);
+       if (bootorder) {
+               bflow->state = BOOTFLOWST_READY;
+               return 0;
+       }
 
        return -EINVAL;
 }