From mboxrd@z Thu Jan 1 00:00:00 1970 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 88AE1C433EF for ; Mon, 25 Apr 2022 05:36:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6716083EE8; Mon, 25 Apr 2022 07:33:56 +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="iR2MKAb6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF3AF83E4F; Mon, 25 Apr 2022 07:33:04 +0200 (CEST) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 8D65283E53 for ; Mon, 25 Apr 2022 07:32:33 +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-ej1-x634.google.com with SMTP id kq17so4283939ejb.4 for ; Sun, 24 Apr 2022 22:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EUXKnj7jMaBEE3QkYoFtiQCbpJyxKOuD9+sbGiS/e0c=; b=iR2MKAb6u9zk4QRZwv6ZNn3AmYKkyTVUo1TtXSYCZ08s90Sg5PRi2mMis9i4y5jRH0 WuifAgZCC8U2QVH+SpgnsVuni4/aIevPgAv6+S1ErmOUQnp7j5Z0j4r9Vj344Tx78aGd 0bNK1pCyQm1OYaj0uH461G3KWOvfdlVsZjUBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EUXKnj7jMaBEE3QkYoFtiQCbpJyxKOuD9+sbGiS/e0c=; b=1LcbpoY4nY+lzwKbaaJRO4+bcF8GPSWLIiY6eqVw2OIfUZ3AxNIcL3Pz5iNzkTikWT gNh5KGkAGYjMLQEocarpDVsG1ybVn9tUrhR7ewusFEa/mnEXKE03SaIK9JimfPFRm5J5 bDGvm3AKgXa+yT9IVEGu7+Iki1Gh690Z/yPGr4jUhKbs7O5ftu15J2yBTZ2MGHxbGE7z HRlhNMqnSMzHxA81Un01nnuHcwwvPvHHR3DA0hRPY94r7M9G5d924k6qndEbKpO/39n1 /b8yuF3AEOcqGFc9A9e+GMsXkde/b6xPGcKik+L6HxGILek08lQaASZfv9xB1Er26vpJ pG7g== X-Gm-Message-State: AOAM530lwT38h4MqFI6BIGSm+2S6NGde2AjXjEdH4+E+E8+Ku6XelNPR tPPvo9dM2JA5e6H/dNeu+NCXgRRZufGj60Xt X-Google-Smtp-Source: ABdhPJz2HxW1JzCnKqa4G+UUD2pWunveypDn6N+qdghoPcxWZAVJvz5oi1WQwgg8ilJxoCLVu72iGw== X-Received: by 2002:a17:907:3e10:b0:6ef:f04b:c21e with SMTP id hp16-20020a1709073e1000b006eff04bc21emr14758289ejc.747.1650864752905; Sun, 24 Apr 2022 22:32:32 -0700 (PDT) Received: from sjg1.c.hospitality.swisscom.com (d54c768e3.static.telenet.be. [84.199.104.227]) by smtp.gmail.com with ESMTPSA id s12-20020a1709062ecc00b006e8558c9a5csm3230784eji.94.2022.04.24.22.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 22:32:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Dennis Gilmore , Lukas Auer , Daniel Schwierzeck , Tom Rini , Michal Simek , Ilias Apalodimas , Steffen Jaeckel , Simon Glass Subject: [PATCH v5 26/34] bootstd: Add an implementation of EFI bootmgr Date: Sun, 24 Apr 2022 23:31:19 -0600 Message-Id: <20220425053127.19950-18-sjg@chromium.org> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog In-Reply-To: <20220425053127.19950-1-sjg@chromium.org> References: <20220425053127.19950-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.5 at phobos.denx.de X-Virus-Status: Clean Add a bootmeth driver which handles EFI boot manager, using EFI_LOADER. In effect, this provides the same functionality as the 'bootefi bootmgr' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc. For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without CONFIG_CMDLINE being enabled. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Add a log category boot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 86 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 boot/bootmeth_efi_mgr.c diff --git a/boot/Makefile b/boot/Makefile index 7325dbc1dd6..fe221d7f441 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -27,6 +27,9 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o +ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL +obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o +endif obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c new file mode 100644 index 00000000000..a6914466db7 --- /dev/null +++ b/boot/bootmeth_efi_mgr.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Bootmethod for EFI boot manager + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include +#include +#include +#include +#include +#include + +static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) +{ + int ret; + + /* Must be an bootstd device */ + ret = bootflow_iter_uses_system(iter); + if (ret) + return log_msg_ret("net", ret); + + return 0; +} + +static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + /* + * Just assume there is something to boot since we don't have any way + * of knowing in advance + */ + bflow->state = BOOTFLOWST_READY; + + return 0; +} + +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 = run_command("bootefi bootmgr", 0); + + 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"; + + 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_zefi_mgr) = { + .name = "bootmeth_efi_mgr", + .id = UCLASS_BOOTMETH, + .of_match = efi_mgr_bootmeth_ids, + .ops = &efi_mgr_bootmeth_ops, + .bind = bootmeth_efi_mgr_bind, +}; -- 2.36.0.rc2.479.g8af0fa9b8e-goog