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
19 * struct efi_mgr_priv - private info for the efi-mgr driver
21 * @fake_bootflow: Fake a valid bootflow for testing
27 void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev)
29 struct efi_mgr_priv *priv = dev_get_priv(dev);
31 priv->fake_dev = fake_dev;
34 static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
38 /* Must be an bootstd device */
39 ret = bootflow_iter_uses_system(iter);
41 return log_msg_ret("net", ret);
46 static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
48 struct efi_mgr_priv *priv = dev_get_priv(dev);
51 bflow->state = BOOTFLOWST_READY;
55 /* To be implemented */
60 static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
61 const char *file_path, ulong addr, ulong *sizep)
63 /* Files are loaded by the 'bootefi bootmgr' command */
68 static int efi_mgr_boot(struct udevice *dev, struct bootflow *bflow)
72 /* Booting is handled by the 'bootefi bootmgr' command */
73 ret = run_command("bootefi bootmgr", 0);
78 static int bootmeth_efi_mgr_bind(struct udevice *dev)
80 struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
82 plat->desc = "EFI bootmgr flow";
83 plat->flags = BOOTMETHF_GLOBAL;
88 static struct bootmeth_ops efi_mgr_bootmeth_ops = {
89 .check = efi_mgr_check,
90 .read_bootflow = efi_mgr_read_bootflow,
91 .read_file = efi_mgr_read_file,
95 static const struct udevice_id efi_mgr_bootmeth_ids[] = {
96 { .compatible = "u-boot,efi-bootmgr" },
100 U_BOOT_DRIVER(bootmeth_efi_mgr) = {
101 .name = "bootmeth_efi_mgr",
102 .id = UCLASS_BOOTMETH,
103 .of_match = efi_mgr_bootmeth_ids,
104 .ops = &efi_mgr_bootmeth_ops,
105 .bind = bootmeth_efi_mgr_bind,
106 .priv_auto = sizeof(struct efi_mgr_priv),