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 6F13FC433FE for ; Wed, 19 Jan 2022 11:47:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2675B832CD; Wed, 19 Jan 2022 12:47:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="XmtE3jj/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C520837E4; Wed, 19 Jan 2022 12:47:33 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 75DF68303A for ; Wed, 19 Jan 2022 12:47:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1642592845; bh=bfEzssr8VHntnvorzem1mdUwoBJXZvJ5+TSbkxS+qnU=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=XmtE3jj/hm1nFDQlkyTba7InxQkArG3MY1nMpiV397lOLJ3jDYAQjLTb/+AJGWho7 JBepOmvwYnmQRNqeloOSsHq6Tv9+dXZDAXklOWGCyVtv69dSSgAkZZlYZUjRrFHqgs yErCFhUKQJ0P7syHXETS91hyiBzl8GsFyc/R2MQo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([88.152.144.107]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N0oBr-1mMA5A2wb7-00wqGa; Wed, 19 Jan 2022 12:47:25 +0100 Message-ID: Date: Wed, 19 Jan 2022 12:47:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 24/31] bootstd: Add an implementation of EFI bootmgr Content-Language: en-US To: Simon Glass , U-Boot Mailing List Cc: Ilias Apalodimas , Daniel Schwierzeck , Dennis Gilmore , Steffen Jaeckel , Lukas Auer , Michal Simek , Tom Rini References: <20220119014315.1938157-1-sjg@chromium.org> <20220119014315.1938157-16-sjg@chromium.org> From: Heinrich Schuchardt In-Reply-To: <20220119014315.1938157-16-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ik0Mak32w/ZebAye9JHghGMRLoaOTPZt3WL7odBLt8tv4RAp5Jr /AFbMGq6xNkrOIWBjE5WUom5DgppoHbraVpgXyH+2VyqV2kiHGlYjD6BfjzsI2wcrN6SOhC 8A6i2EvyhtvdFnnv3gRb+BlWCTH0BV9O5TFsomiOFZKFs89hJSfu+GoLf3WGqHlS14LE3WQ L/b4iQBvM57q/22wlxirg== X-UI-Out-Filterresults: notjunk:1;V03:K0:AV4fvpR1DsI=:AYk8KHSsQi6+1hVtnWL6za Tnbl4QW6IkQHP9QT9eBdDaWxJcomMQDVheW1DuT/HqPj8MLNphXwZDXvB5VO4FcfqIIeJScDM UGuquYLwprQjJGWrICjQJmWJp3AiNvgT5/7V9Q91Kv1sigmQdX9KtsEfswU+mdCF/1zraN19P umvgr3wa0pIE5l6mXHj4ZOzu2fzmUFgni1z19YC2nqdypOFj2au3FuIFaGm0YVzOE3lEUKhoP TB2ogxfyShclnqj9hufrS8NY+3mmcIAGd8ri/0wbzPNfXY2gNX6rZxRQlcbSvi4jKlF6InaTS OKGTOsRDeUqVPV2j+8Ulj4Tujw0epaPAHgap+/aUhY6ZKlnUR2zz5om3j34cQzyyhKYO8vqyD Gmh3+kk72rQHjDHeI7El7Wpc7hlohTFz6oNTMIbX1vet9JfmhFTpFz3+1RYgPc0dLJf5LV43o Xvn54EesgYZMEW5l/3oh+/NxO57BKJMdSEs6Bp/QMGmCZ/6yy+O6lO5NWfRLXL+QGpb0MKvul zZHaVRzD81kiLNN1lH+9cudn+XTCv/FOYnmVohlUwOrm1TcqIFCjtyRGxWLc3rZKqUPZBbM4B 0DnAhUONO4fYyvbDPnJCfvcJPSRPPGSZjxU+kT/FObBrSYd54O4kSz0PXN8VYs1/I2UqSIaNH f3svBQrMlQl5U2FsaDdqd/bkXE+t8g1SlOOTr+oihfqiuI1NTXi0Rka6/NM5iWgtue9dI7NA2 1+vYu3Z1OmSXLYdz3gfcuW3acZG6VrSFAUMkkrPlmDN7qr09lWcnWl19VqeGccxMZX8h8dt2g BEz5KMoe7xc6IdQLoOd2Qo/Lmsx+3ks/kN/4hT3TrqzMxDGp4hS5FiurIc6xZbR/QZPw7BQ0+ 3amizi19Rc8Dt+gpfbVsFxc4/7FPe1vGcHVMjBXYOLPvzAp7C0fSnhAMUCsJHES0hm73JxOHb UF/AIhJuD90TjTSyjDeNl5WLMh1jDX7JV2ofbwam2ydKFQSSqgNMDzXZ6WrKarhbxYkAgKiSP 1GiFuJrNbP02/D7BitR4pXWFxnwU+4wJ447msoHvAmX12dmOCNhhfeBvYCZA2XpVwCxlAY/ZH EiMbK2z49FxUgQ= 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.2 at phobos.denx.de X-Virus-Status: Clean On 1/19/22 02:43, Simon Glass wrote: > 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 > --- > > 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 795665f7ce5..38b10d81f0d 100644 > --- a/boot/Makefile > +++ b/boot/Makefile > @@ -31,6 +31,9 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) +=3D bootstd-uclass.o > obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) +=3D bootmeth_distro.o > obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) +=3D bootmeth_pxe.o > obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) +=3D bootmeth_efi.o > +ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL > +obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) +=3D bootmeth_efi_mgr.o > +endif > > obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) +=3D image-fdt.o > obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) +=3D 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 *ite= r) > +{ > + int ret; > + > + /* Must be an bootstd device */ > + ret =3D 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 =3D BOOTFLOWST_READY; > + > + return 0; > +} > + > +static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflo= w, > + 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 =3D run_command("bootefi bootmgr", 0); You are missing to provide the device tree. Best regards Heinrich > + > + return 0; > +} > + > +static int bootmeth_efi_mgr_bind(struct udevice *dev) > +{ > + struct bootmeth_uc_plat *plat =3D dev_get_uclass_plat(dev); > + > + plat->desc =3D "EFI bootmgr flow"; > + > + return 0; > +} > + > +static struct bootmeth_ops efi_mgr_bootmeth_ops =3D { > + .check =3D efi_mgr_check, > + .read_bootflow =3D efi_mgr_read_bootflow, > + .read_file =3D efi_mgr_read_file, > + .boot =3D efi_mgr_boot, > +}; > + > +static const struct udevice_id efi_mgr_bootmeth_ids[] =3D { > + { .compatible =3D "u-boot,efi-bootmgr" }, > + { } > +}; > + > +U_BOOT_DRIVER(bootmeth_zefi_mgr) =3D { > + .name =3D "bootmeth_efi_mgr", > + .id =3D UCLASS_BOOTMETH, > + .of_match =3D efi_mgr_bootmeth_ids, > + .ops =3D &efi_mgr_bootmeth_ops, > + .bind =3D bootmeth_efi_mgr_bind, > +};