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 0DEEBC4332F for ; Wed, 19 Jan 2022 01:52:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6148C837E7; Wed, 19 Jan 2022 02:52:43 +0100 (CET) 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="LgdP/hub"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C307D831EA; Wed, 19 Jan 2022 02:52:40 +0100 (CET) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 2392F83815 for ; Wed, 19 Jan 2022 02:44:03 +0100 (CET) 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-io1-xd2f.google.com with SMTP id p7so989956iod.2 for ; Tue, 18 Jan 2022 17:44:03 -0800 (PST) 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=MwHZzbXNR7wQHiLnrcgymfVcvG29nj0B0nj9x/qIIFY=; b=LgdP/hubAOOCFKJcTU78qDqYn62Vvm/XWdidajZJRPh3tHoPvF37ZII7S3IetnSIAJ Cxh/19PZ7Y1yqDe34UMMBdvTkY6ppq0T14CQcHiDdqPcGcQ6miukv34Uu0yqj2pNCeBk GBWLfniRCEV7So2jGXRz4FXH29zKjaouvTS1w= 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=MwHZzbXNR7wQHiLnrcgymfVcvG29nj0B0nj9x/qIIFY=; b=1TMOM+XcF35LzLPyJrsGjSiqqmgCGyzApv7mH844/ck5+ZrtYrl1btLpLJxRO/a41k 4IwqYpaWVEtoPRsA/7krspdB0Ryo1eUPX7BasKA6uBTr3IjPX12soqkqrMzagAEauomQ dze2kJmbSy6ZG0XYVY+WwnwHUKmfHGN3K6TKnA+EG0er2oFK7pWQhYUpIbfOG9DNyKBc cwK4laabuUsGABuY/EZimQJoV69mdT17I5K7+/u1pDg3cpgJYFzccJHSaxdNcTFoQMce XxlmJgC9PnkHNREKzGsuF7gqtAMwyB2ah0s8THFe1CD/kIj6crfVKz7V+LO+8bcV3/oS dxeQ== X-Gm-Message-State: AOAM53388p6VthU/Rd7Vm7HNJPWjVJn8k0R6zRxrQI4iwd0AoMbjOTaY /5MX4T6Nq+N4PIiHsp4sAuDlwaYFidtbXw== X-Google-Smtp-Source: ABdhPJx1CaT54DsWZmIFH+Ed+bWTFsLcLcFggg54pYr/b6+5sWwGgbC/dcLtC6N0C2rD0fwTami/Dw== X-Received: by 2002:a5d:87d8:: with SMTP id q24mr13802414ios.154.1642556641811; Tue, 18 Jan 2022 17:44:01 -0800 (PST) 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 j18sm10546314ila.86.2022.01.18.17.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 17:44:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Daniel Schwierzeck , Dennis Gilmore , Steffen Jaeckel , Lukas Auer , Michal Simek , Tom Rini , Heinrich Schuchardt , Simon Glass Subject: [PATCH v3 23/31] bootstd: Add a system bootdev for strange boot methods Date: Tue, 18 Jan 2022 18:43:07 -0700 Message-Id: <20220119014315.1938157-15-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220119014315.1938157-1-sjg@chromium.org> References: <20220119014315.1938157-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.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 --- Changes in v3: - Add a log category boot/Makefile | 2 +- boot/bootstd-uclass.c | 6 ++++ boot/system_bootdev.c | 66 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 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 63fded98baf..e29a34366ee 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -150,6 +150,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..432d2034780 --- /dev/null +++ b/boot/system_bootdev.c @@ -0,0 +1,66 @@ +// 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 + */ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#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.34.1.703.g22d0c6ccf7-goog