Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE282C19F28 for ; Sat, 30 Jul 2022 21:55:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5196C844C0; Sat, 30 Jul 2022 23:53:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Fj3MM23i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FBE08420A; Sat, 30 Jul 2022 23:53:27 +0200 (CEST) Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0ED258414C for ; Sat, 30 Jul 2022 23:53:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-10ea30a098bso4716799fac.8 for ; Sat, 30 Jul 2022 14:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=T1qrWCV1dCIjjAiKrvaiKRAQd2WibG38Virrf2RpX6o=; b=Fj3MM23iHTnA/qIsh4/Gijv1TcY7GoWDJRkzhIZyIghVS3Mr/In3EOwTIY1F23V1lM 1DN2jINWgHeWvZtEcUd8RR3m/l+82T8GK8XOzX80GAx2GMjIizJM9S43Hd3tM/ty8BH2 WEy/FXjmjAoA6e/3qpvVv4C8fV4heyfuOKXzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=T1qrWCV1dCIjjAiKrvaiKRAQd2WibG38Virrf2RpX6o=; b=QYQvxx/DcKLntfJRHDU+63cgGI5qFJhhcxF8sGN4yJoR+nZ7BdM2Gqrh1+8JbOOngJ BSBja+m48PJngJcCociZeZeJgb79YA/bVKTC7v6rvEtPTtGjjjG7VMQnpVMkOugU+Mit xuKx88tFG5E1SfewSsfy7qSKFTU3g27j3vWrepeoDP/4Kw6GoMXNx6FJTaTmXGtkNBVP GBfyesNGPgeGHvF7sMCDaLBH8TfbWC/71FAl+jXdINS61KTZ3jQRTGL1T/Z7taRAxxdH utBaBoimXkKNedqX+EpbA2XdX+Pv8wk+wO1QjXdivPzkdW1Sglo36hgaMpcKHjG9sjoH F5gg== X-Gm-Message-State: AJIora9/oSD1TMMBpkMztA6e2KeFqmNkrDRD4YS6xBqUky9+xGJpL3qC i+cnDVaTwYVOYHyjg985liLwcpbYBHrmszXu X-Google-Smtp-Source: AGRyM1svdBbaqP1ngi7Am31nYZV1CGBtMNxQ0MQmoSlbJdUyK+C6nsdIP+tmleXsOUCRDZmkczujGg== X-Received: by 2002:a05:6870:8902:b0:101:a2a3:479c with SMTP id i2-20020a056870890200b00101a2a3479cmr4497158oao.215.1659218004446; Sat, 30 Jul 2022 14:53:24 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 19-20020a544193000000b0032f75714af1sm1699656oiy.18.2022.07.30.14.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 14:53:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Bin Meng , Simon Glass Subject: [PATCH v2 19/35] bootstd: Allow bootmeths to be marked as global Date: Sat, 30 Jul 2022 15:52:21 -0600 Message-Id: <20220730215237.818368-15-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220730215237.818368-1-sjg@chromium.org> References: <20220730215237.818368-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The current way of handling things like EFI bootmgr is a bit odd, since that bootmeth handles selection of the bootdev itself. VBE needs to work the same way, so we should support it properly. Add a flag that indicates that the bootmeth is global, rather than being invoked on each bootdev. Provide a helper to read a bootflow from the bootmeth. Signed-off-by: Simon Glass --- (no changes since v1) boot/Kconfig | 7 +++++++ boot/bootmeth-uclass.c | 14 ++++++++++++++ boot/bootmeth_efi_mgr.c | 3 ++- cmd/bootmeth.c | 4 +++- include/bootmeth.h | 23 +++++++++++++++++++++++ lib/efi_loader/Kconfig | 1 + 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index 7a9ee483bc3..b8adc64b9a7 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -343,6 +343,13 @@ config BOOTSTD_BOOTCOMMAND standard boot does not support all of the features of distro boot yet. +config BOOTMETH_GLOBAL + bool + help + Add support for global bootmeths. This feature is used by VBE and + EFI bootmgr, since they take full control over which bootdevs are + selected to boot. + config BOOTMETH_DISTRO bool "Bootdev support for distro boot" depends on CMD_PXE diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 1e276c0f26b..88bbb32c47f 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -71,6 +71,20 @@ int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow, return ops->read_file(dev, bflow, file_path, addr, sizep); } +int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + const struct bootmeth_ops *ops = bootmeth_get_ops(dev); + + if (!ops->read_bootflow) + return -ENOSYS; + memset(bflow, '\0', sizeof(*bflow)); + bflow->dev = NULL; + bflow->method = dev; + bflow->state = BOOTFLOWST_BASE; + + return ops->read_bootflow(dev, bflow); +} + /** * bootmeth_setup_iter_order() - Set up the ordering of bootmeths to scan * diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index a6914466db7..08d9328af4e 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -61,6 +61,7 @@ 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; } @@ -77,7 +78,7 @@ static const struct udevice_id efi_mgr_bootmeth_ids[] = { { } }; -U_BOOT_DRIVER(bootmeth_zefi_mgr) = { +U_BOOT_DRIVER(bootmeth_efi_mgr) = { .name = "bootmeth_efi_mgr", .id = UCLASS_BOOTMETH, .of_match = efi_mgr_bootmeth_ids, diff --git a/cmd/bootmeth.c b/cmd/bootmeth.c index c9a27fe8ac6..9fbcccdba7e 100644 --- a/cmd/bootmeth.c +++ b/cmd/bootmeth.c @@ -69,7 +69,9 @@ static int do_bootmeth_list(struct cmd_tbl *cmdtp, int flag, int argc, } } - if (order == -1) + if (ucp->flags & BOOTMETHF_GLOBAL) + printf("%5s", "glob"); + else if (order == -1) printf("%5s", "-"); else printf("%5x", order); diff --git a/include/bootmeth.h b/include/bootmeth.h index 4967031a0a8..c93367b0995 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -12,13 +12,24 @@ struct bootflow; struct bootflow_iter; struct udevice; +/** + * enum bootmeth_flags - Flags for bootmeths + * + * @BOOTMETHF_GLOBAL: bootmeth handles bootdev selection automatically + */ +enum bootmeth_flags { + BOOTMETHF_GLOBAL = BIT(0), +}; + /** * struct bootmeth_uc_plat - information the uclass keeps about each bootmeth * * @desc: A long description of the bootmeth + * @flags: Flags for this bootmeth (enum bootmeth_flags) */ struct bootmeth_uc_plat { const char *desc; + int flags; }; /** struct bootmeth_ops - Operations for boot methods */ @@ -267,4 +278,16 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align); int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong addr, ulong *sizep); +/** + * bootmeth_get_bootflow() - Get a bootflow from a global bootmeth + * + * Check the bootmeth for a bootflow which can be used. In this case the + * bootmeth handles all bootdev selection, etc. + * + * @dev: bootmeth device to read from + * @bflow: Bootflow information + * @return 0 on success, -ve if a bootflow could not be found or had an error + */ +int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow); + #endif diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index e3f2402d0e8..e4c51ed231d 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -37,6 +37,7 @@ if EFI_LOADER config CMD_BOOTEFI_BOOTMGR bool "UEFI Boot Manager" default y + select BOOTMETH_GLOBAL help Select this option if you want to select the UEFI binary to be booted via UEFI variables Boot####, BootOrder, and BootNext. This enables the -- 2.37.1.455.g008518b4e5-goog