mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-18 21:21:26 +02:00
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
124 lines
2.6 KiB
C
124 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Bootmethod for EFI boot manager
|
|
*
|
|
* Copyright 2021 Google LLC
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
*/
|
|
|
|
#define LOG_CATEGORY UCLASS_BOOTSTD
|
|
|
|
#include <bootdev.h>
|
|
#include <bootflow.h>
|
|
#include <bootmeth.h>
|
|
#include <command.h>
|
|
#include <dm.h>
|
|
#include <efi_loader.h>
|
|
#include <efi_variable.h>
|
|
#include <malloc.h>
|
|
|
|
/**
|
|
* struct efi_mgr_priv - private info for the efi-mgr driver
|
|
*
|
|
* @fake_bootflow: Fake a valid bootflow for testing
|
|
*/
|
|
struct efi_mgr_priv {
|
|
bool fake_dev;
|
|
};
|
|
|
|
void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev)
|
|
{
|
|
struct efi_mgr_priv *priv = dev_get_priv(dev);
|
|
|
|
priv->fake_dev = fake_dev;
|
|
}
|
|
|
|
static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
|
|
{
|
|
int ret;
|
|
|
|
/* Must be an bootstd device */
|
|
ret = bootflow_iter_check_system(iter);
|
|
if (ret)
|
|
return log_msg_ret("net", ret);
|
|
|
|
return 0;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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) {
|
|
free(bootorder);
|
|
bflow->state = BOOTFLOWST_READY;
|
|
return 0;
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
|
|
const char *file_path, ulong addr, ulong *sizep)
|
|
{
|
|
/* Files are loaded by the 'bootefi bootmgr' command */
|
|
|
|
return -ENOSYS;
|
|
}
|
|
|
|
static int efi_mgr_boot(struct udevice *dev, struct bootflow *bflow)
|
|
{
|
|
int ret;
|
|
|
|
/* Booting is handled by the 'bootefi bootmgr' command */
|
|
ret = efi_bootmgr_run(EFI_FDT_USE_INTERNAL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bootmeth_efi_mgr_bind(struct udevice *dev)
|
|
{
|
|
struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
|
|
|
|
plat->desc = "EFI bootmgr flow";
|
|
plat->flags = BOOTMETHF_GLOBAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct bootmeth_ops efi_mgr_bootmeth_ops = {
|
|
.check = efi_mgr_check,
|
|
.read_bootflow = efi_mgr_read_bootflow,
|
|
.read_file = efi_mgr_read_file,
|
|
.boot = efi_mgr_boot,
|
|
};
|
|
|
|
static const struct udevice_id efi_mgr_bootmeth_ids[] = {
|
|
{ .compatible = "u-boot,efi-bootmgr" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(bootmeth_3efi_mgr) = {
|
|
.name = "bootmeth_efi_mgr",
|
|
.id = UCLASS_BOOTMETH,
|
|
.of_match = efi_mgr_bootmeth_ids,
|
|
.ops = &efi_mgr_bootmeth_ops,
|
|
.bind = bootmeth_efi_mgr_bind,
|
|
.priv_auto = sizeof(struct efi_mgr_priv),
|
|
};
|