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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD12EC433EF for ; Sat, 23 Oct 2021 23:32:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3043460E9C for ; Sat, 23 Oct 2021 23:32:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3043460E9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E940835CC; Sun, 24 Oct 2021 01:31:01 +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="ZpmhMyMi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F22983549; Sun, 24 Oct 2021 01:28:09 +0200 (CEST) Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (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 D949183531 for ; Sun, 24 Oct 2021 01:27:22 +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-ot1-x329.google.com with SMTP id l10-20020a056830154a00b00552b74d629aso9319737otp.5 for ; Sat, 23 Oct 2021 16:27:22 -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=pzvCyORSt+UHcxzQL1g3wUCikEAAxGb212f3JEuxHvs=; b=ZpmhMyMi72R8bMXcINywaDGwqebMKcq9Vndvw3sBEZ+u53hxl1If+eA4y7GY/Yz+wc ZNgz/L2uWJ+wzp5uXSVijUiOdV/hNnRvRgZ6gKZMtWM2buGA7hcaVwmTeZ/8aaK+aqM9 V3pgH8JHQyqYxA7tHvThrtGaw/B5+sbtFuRPo= 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=pzvCyORSt+UHcxzQL1g3wUCikEAAxGb212f3JEuxHvs=; b=GGkrC9dWol0q3Qiae25vv/0J8WXc4oQUvEACVKNcUM4RYewYMhGtXlvi2fZnJO19ZO oq1OQem8OVw2UFdo3ninRXnzI210aw8U3q9sZs5o50H397l5+VFg8rwZxakBfzClCi0E luR5AApMgkbRjNMeWF9mrbe1GbE3Pb7NBXrurGBg0la0/pABdYwNo0kvfNse8H3+T5qt 6ZD3DhuDg0HJVo+r3+BIBwZFmlkDtcC+5cFdeNaegrEkQxvUiCOmdC2Gez+C6YoTKZPz BJPInYzvybeb3fLqz/HaX+ZbJAiHcJWNGLn/5qNaI9DivmlSKNsG7N5iUMCfo5sLwwME NgmA== X-Gm-Message-State: AOAM5307MOiEzY2yU+vIJbxnWQnwf9BhfiYotlQsqFgvdCvo7vkIJ8e0 +CvwqgJN2oAsCMsCqjK/W73pXVKtmr7Lug== X-Google-Smtp-Source: ABdhPJxAqahS1lZ1PoinizcyIjcCouPk+Ar1bH7/IR3+VamJDWAA7eaV6ODV+xgtFqEBqE32nSndow== X-Received: by 2002:a9d:d02:: with SMTP id 2mr6889541oti.358.1635031641351; Sat, 23 Oct 2021 16:27:21 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l24sm2253885oop.4.2021.10.23.16.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Oct 2021 16:27:21 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Daniel Schwierzeck , Steffen Jaeckel , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Lukas Auer , Dennis Gilmore , Simon Glass Subject: [PATCH v2 33/41] bootstd: Add an implementation of EFI bootmgr Date: Sat, 23 Oct 2021 17:26:27 -0600 Message-Id: <20211023232635.9195-24-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211023232635.9195-1-sjg@chromium.org> References: <20211023232635.9195-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 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 v1) boot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 boot/bootmeth_efi_mgr.c diff --git a/boot/Makefile b/boot/Makefile index 795665f7ce5..0bbda0e5364 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -31,6 +31,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 +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..3b67cd24984 --- /dev/null +++ b/boot/bootmeth_efi_mgr.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Bootmethod for EFI boot manager + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#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.33.0.1079.g6e70778dc9-goog