1 // SPDX-License-Identifier: GPL-2.0+
3 * Bootmethod for EFI boot manager
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
9 #define LOG_CATEGORY UCLASS_BOOTSTD
18 static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
22 /* Must be an bootstd device */
23 ret = bootflow_iter_uses_system(iter);
25 return log_msg_ret("net", ret);
30 static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
33 * Just assume there is something to boot since we don't have any way
34 * of knowing in advance
36 bflow->state = BOOTFLOWST_READY;
41 static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
42 const char *file_path, ulong addr, ulong *sizep)
44 /* Files are loaded by the 'bootefi bootmgr' command */
49 static int efi_mgr_boot(struct udevice *dev, struct bootflow *bflow)
53 /* Booting is handled by the 'bootefi bootmgr' command */
54 ret = run_command("bootefi bootmgr", 0);
59 static int bootmeth_efi_mgr_bind(struct udevice *dev)
61 struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
63 plat->desc = "EFI bootmgr flow";
64 plat->flags = BOOTMETHF_GLOBAL;
69 static struct bootmeth_ops efi_mgr_bootmeth_ops = {
70 .check = efi_mgr_check,
71 .read_bootflow = efi_mgr_read_bootflow,
72 .read_file = efi_mgr_read_file,
76 static const struct udevice_id efi_mgr_bootmeth_ids[] = {
77 { .compatible = "u-boot,efi-bootmgr" },
81 U_BOOT_DRIVER(bootmeth_efi_mgr) = {
82 .name = "bootmeth_efi_mgr",
83 .id = UCLASS_BOOTMETH,
84 .of_match = efi_mgr_bootmeth_ids,
85 .ops = &efi_mgr_bootmeth_ops,
86 .bind = bootmeth_efi_mgr_bind,