From a080b98981a74e96ef2ff6b4de36b222fe42b8e5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 24 Apr 2022 23:31:18 -0600 Subject: bootstd: Add a system bootdev for strange boot methods Some boot methods don't act on a single bootdev but instead do their own thing. An example is EFI bootmgr which scan various devices using its own logic. Add a bootdev to handle this. Signed-off-by: Simon Glass --- boot/system_bootdev.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 boot/system_bootdev.c (limited to 'boot/system_bootdev.c') diff --git a/boot/system_bootdev.c b/boot/system_bootdev.c new file mode 100644 index 00000000000..432d2034780 --- /dev/null +++ b/boot/system_bootdev.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Bootdevice for system, used for bootmeths not tied to any partition device + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int system_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, + struct bootflow *bflow) +{ + int ret; + + /* Must be an bootstd device */ + ret = bootflow_iter_uses_system(iter); + if (ret) + return log_msg_ret("net", ret); + + ret = bootmeth_check(bflow->method, iter); + if (ret) + return log_msg_ret("check", ret); + + ret = bootmeth_read_bootflow(bflow->method, bflow); + if (ret) + return log_msg_ret("method", ret); + + return 0; +} + +static int system_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_6_SYSTEM; + + return 0; +} + +struct bootdev_ops system_bootdev_ops = { + .get_bootflow = system_get_bootflow, +}; + +static const struct udevice_id system_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-system" }, + { } +}; + +U_BOOT_DRIVER(system_bootdev) = { + .name = "system_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &system_bootdev_ops, + .bind = system_bootdev_bind, + .of_match = system_bootdev_ids, +}; -- cgit v1.2.3