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 06BD2C433EF for ; Sat, 23 Oct 2021 23:30:58 +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 7D1F660E9C for ; Sat, 23 Oct 2021 23:30:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7D1F660E9C 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 6140C8359A; Sun, 24 Oct 2021 01:30:21 +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="eaSIVuwd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 145EC83461; Sun, 24 Oct 2021 01:28:06 +0200 (CEST) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (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 C69C78343C for ; Sun, 24 Oct 2021 01:27:21 +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-x32e.google.com with SMTP id b4-20020a9d7544000000b00552ab826e3aso9338818otl.4 for ; Sat, 23 Oct 2021 16:27:21 -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=aQ4NaVYbfet0uh1iG2YOVY+xBYR3bzR0i6PGrIbN7rU=; b=eaSIVuwd9m6U5yehAdeQYeeHdWXq9ONaKkC9oSgvcBTf8g4kX8ubELgQlCaIhflcvB U40j5ezo01BHN3ZWkEknAXefntz6olu+USbbMdWzXpim/z8Rvajb0S9+FF/KGVJnSNkx JykV1XTjDYiNuNYJx+VnsM+I8CX+NZtFe/mbg= 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=aQ4NaVYbfet0uh1iG2YOVY+xBYR3bzR0i6PGrIbN7rU=; b=J4ljNS4ShKynrUPWB3/z46mwt8ujW3jWvuy3R0/nJEGcOAduF7U15OFFJyG1qoNpLt rrfIVjPtCfcABJSWmnVpt0Gj13D444PxEzFpN/qlq8SF2iNPL/sS54LPLQYl2GbkN9LW 2l+q+uUIgLglhmycliI7jwkCPrKoaF4S0yabcMxOBzaKxDKyIY1NM3g28K4UihKXJl23 9x0H6enr/o88JYtL/vFGSVmyiEk63/IHLGuXOhrYFjRTTNg8v7jGwIIwK29vQD4Akf3m FNTNWobhqgxVwP323Z7BI3FNrnoV6Rt5Oey6XE1b4QaZxMf3FW2w1dHLSnp/m4xT+Fy2 Y7tw== X-Gm-Message-State: AOAM530AtS8AvQKmluK2B7o1VccyrniR3rAwkHH5AskyYq32JGNWvMTy Ok+K0wWXdcffzTFReIe5XLoY+hMXfmU= X-Google-Smtp-Source: ABdhPJxQ8izfC2kf2XtnMjtV4xKXhQKe5bwoQ/yV+mzGH78xqsVlyc97PdnpfvC6A+c1XVyiRTjzAg== X-Received: by 2002:a05:6830:1c2e:: with SMTP id f14mr7068281ote.202.1635031640259; Sat, 23 Oct 2021 16:27:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Oct 2021 16:27:19 -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 32/41] bootstd: Add a system bootdev for strange boot methods Date: Sat, 23 Oct 2021 17:26:26 -0600 Message-Id: <20211023232635.9195-23-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 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 --- (no changes since v1) boot/Makefile | 2 +- boot/bootstd-uclass.c | 6 ++++ boot/system_bootdev.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 boot/system_bootdev.c diff --git a/boot/Makefile b/boot/Makefile index c2345435201..795665f7ce5 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -23,7 +23,7 @@ obj-y += image.o image-board.o obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o -obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o system_bootdev.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index 7dddd72bc4a..3952560eee5 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -143,6 +143,12 @@ int dm_scan_other(bool pre_reloc_only) } } + /* Create the system bootdev too */ + ret = device_bind_driver(bootstd, "system_bootdev", "system-bootdev", + &dev); + if (ret) + return log_msg_ret("sys", ret); + return 0; } diff --git a/boot/system_bootdev.c b/boot/system_bootdev.c new file mode 100644 index 00000000000..2cf7cd4dc11 --- /dev/null +++ b/boot/system_bootdev.c @@ -0,0 +1,64 @@ +// 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 + */ + +#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, +}; -- 2.33.0.1079.g6e70778dc9-goog