From patchwork Mon Nov 4 17:50:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006418 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GJ3xAMWl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzYH5Y1bz1xxN for ; Tue, 5 Nov 2024 04:51:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B848588DEE; Mon, 4 Nov 2024 18:51:22 +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="GJ3xAMWl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DA0AC88DE6; Mon, 4 Nov 2024 18:51:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 A395B8862E for ; Mon, 4 Nov 2024 18:51:19 +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-xd2b.google.com with SMTP id ca18e2360f4ac-83ab6cbd8b1so181687639f.1 for ; Mon, 04 Nov 2024 09:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742678; x=1731347478; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SK/Gghx1vy+dGfptNii4udvfUUiCRgGiDtVAuoFwOjg=; b=GJ3xAMWlbiUYbHfsv5LzwEWWAZMYXCAtWZlNJDPd+rSuz1iyDzQRmkGKs3h/zFwjOC 1B2cYG/PPv3k4UH01JVJh0lK44lhD9FolxFJCHyieogzxVz2leHx3RkRUugIJkAsLeHQ ykSCaPgE8TmOlNy5NvtLtZ48gjjs9KXU07iv0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742678; x=1731347478; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SK/Gghx1vy+dGfptNii4udvfUUiCRgGiDtVAuoFwOjg=; b=G2EqxYntFf2GUoEi+S0401HREINBmfYy1grGnRZxwnvS6s1mLaEEIw/7/g5iF6Jj9f 5aZAE/g/vAOWwKszKT6obJtt16KKqIgxtvjftLGTtiCt55NSpKeh/IW8+fTSYwd4VuUC CXyLhSLXiqrDhneB0eZC+EHMeAJZPczvR8aRZn/hiXN1YW742ig+QNt/7oZp0+z2mFQX pheqc0RJrIAFNHsS1JJKS9ug0nyftCSW5NEU0RUC3aVljGsvvFIhpqY9Yz1iMVtSGxaO R8ZKEV/Rrsq+U0H4FJuPKScbXTdQ+94XHooNynJb58OBmyIf2vUJAgWEC02b4O+yX5LW 4vJw== X-Gm-Message-State: AOJu0YzOc4kuWYJ/otTD13u7NTA/ZaoULmb0Ih8hyapxYNpwnrf5uay1 wrumZWz3C5OHZOcfNfWuHav0BwIVwVwZxHL5a9blfkEoCM6O/EENsVu+V/LnnzY+hovgKnGI/e0 = X-Google-Smtp-Source: AGHT+IFErXK2X+AA4xDvc0vwloFDQjRIrXmN9mVeF8dt1GJYsHqvxUVBj07avS/1FAVf9hDLvZjFwA== X-Received: by 2002:a05:6602:1487:b0:835:45ed:bc23 with SMTP id ca18e2360f4ac-83b7190bdb6mr1253842139f.3.1730742677791; Mon, 04 Nov 2024 09:51:17 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Dragan Simic , Heinrich Schuchardt , Ilias Apalodimas , Nam Cao , Peter Robinson , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tony Dinh Subject: [PATCH v3 01/19] bootstd: Move bootflow-adding to bootstd Date: Mon, 4 Nov 2024 10:50:52 -0700 Message-Id: <20241104175110.1048449-2-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean This relates to more than just the bootdev, since there is a global list of bootflows. Move the function to the bootstd file and rename it. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 25 ------------------------- boot/bootstd-uclass.c | 25 +++++++++++++++++++++++++ cmd/bootflow.c | 2 +- include/bootdev.h | 15 --------------- include/bootstd.h | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 41 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 64ec4fde493..eddbf60600c 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -32,31 +32,6 @@ enum { BOOT_TARGETS_MAX_LEN = 100, }; -int bootdev_add_bootflow(struct bootflow *bflow) -{ - struct bootstd_priv *std; - struct bootflow *new; - int ret; - - ret = bootstd_get_priv(&std); - if (ret) - return ret; - - new = malloc(sizeof(*bflow)); - if (!new) - return log_msg_ret("bflow", -ENOMEM); - memcpy(new, bflow, sizeof(*bflow)); - - list_add_tail(&new->glob_node, &std->glob_head); - if (bflow->dev) { - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev); - - list_add_tail(&new->bm_node, &ucp->bootflow_head); - } - - return 0; -} - int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index fdb8d69e320..bf6e49ad97a 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -61,6 +61,31 @@ void bootstd_clear_glob(void) bootstd_clear_glob_(std); } +int bootstd_add_bootflow(struct bootflow *bflow) +{ + struct bootstd_priv *std; + struct bootflow *new; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return ret; + + new = malloc(sizeof(*bflow)); + if (!new) + return log_msg_ret("bflow", -ENOMEM); + memcpy(new, bflow, sizeof(*bflow)); + + list_add_tail(&new->glob_node, &std->glob_head); + if (bflow->dev) { + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev); + + list_add_tail(&new->bm_node, &ucp->bootflow_head); + } + + return 0; +} + static int bootstd_remove(struct udevice *dev) { struct bootstd_priv *priv = dev_get_priv(dev); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index f67948d7368..8962464bbf8 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -207,7 +207,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, bflow.err = ret; if (!ret) num_valid++; - ret = bootdev_add_bootflow(&bflow); + ret = bootstd_add_bootflow(&bflow); if (ret) { printf("Out of memory\n"); return CMD_RET_FAILURE; diff --git a/include/bootdev.h b/include/bootdev.h index ad4af0d1310..8db198dd56b 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -195,21 +195,6 @@ void bootdev_list(bool probe); */ void bootdev_clear_bootflows(struct udevice *dev); -/** - * bootdev_add_bootflow() - Add a bootflow to the bootdev's list - * - * All fields in @bflow must be set up. Note that @bflow->dev is used to add the - * bootflow to that device. - * - * @dev: Bootdev device to add to - * @bflow: Bootflow to add. Note that fields within bflow must be allocated - * since this function takes over ownership of these. This functions makes - * a copy of @bflow itself (without allocating its fields again), so the - * caller must dispose of the memory used by the @bflow pointer itself - * Return: 0 if OK, -ENOMEM if out of memory - */ -int bootdev_add_bootflow(struct bootflow *bflow); - /** * bootdev_first_bootflow() - Get the first bootflow from a bootdev * diff --git a/include/bootstd.h b/include/bootstd.h index ac756e98d84..3fc93a4ec2e 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -105,4 +105,21 @@ void bootstd_clear_glob(void); */ int bootstd_prog_boot(void); +/** + * bootstd_add_bootflow() - Add a bootflow to the bootdev's and global list + * + * All fields in @bflow must be set up. Note that @bflow->dev is used to add the + * bootflow to that device. + * + * The bootflow is also added to the global list of all bootflows + * + * @dev: Bootdev device to add to + * @bflow: Bootflow to add. Note that fields within bflow must be allocated + * since this function takes over ownership of these. This functions makes + * a copy of @bflow itself (without allocating its fields again), so the + * caller must dispose of the memory used by the @bflow pointer itself + * Return: 0 if OK, -ENOMEM if out of memory + */ +int bootstd_add_bootflow(struct bootflow *bflow); + #endif From patchwork Mon Nov 4 17:50:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006419 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ehbl2zQm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzYL0dwqz1xyD for ; Tue, 5 Nov 2024 04:51:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 145ED88DFB; Mon, 4 Nov 2024 18:51:25 +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="ehbl2zQm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6EAC288E1C; Mon, 4 Nov 2024 18:51:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 47F428880B for ; Mon, 4 Nov 2024 18:51:21 +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-xd2e.google.com with SMTP id ca18e2360f4ac-83ac05206f6so171458539f.2 for ; Mon, 04 Nov 2024 09:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742679; x=1731347479; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eZi1iH5xTnU6wsXBL2jxaYVAIGlwutaFkGYvoL31L6E=; b=ehbl2zQmeq0+NJ5aa+aMPUQodCg8/BuAKQPdA3HM215zJH9waTsYME6BD0SB8PXxGT U2z28GV9MPtBbpKdAhH/IP15nAWz+nsFVXohwCRjxpUydGyN8BjYBauvzBEhVQPQt4sB n5NAh3luC0QBfTISJyFO8KvMOAsPPSse301wc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742679; x=1731347479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eZi1iH5xTnU6wsXBL2jxaYVAIGlwutaFkGYvoL31L6E=; b=nY3s1quX6lPTsosTO3qbw1FpU3/ufs50Eve6rEAuy1M/tg9kO7SFzaWAv8AAHIoxzY Ot90P6U9JcAhncBTgCESySr45bJWWjIP0+jnYyTQMd2XzYZylcJCcXEybGgKBwgGbdcR m5FdSo8oMS69TRZxUYZ8bopJSlAifF/Qzvo+oVaK+m+jq0INdwtE0hdP+Dgone5Z/6hf cYjrXXo3iSIPMta+8VO2x/M8IT36CiVY0BvNOKIhxVIlN6OjDq0NYWkj/+R3eeAW34o4 hk+t1byXVvDAa94p3NzoH+9RdqQ1yOMAXe0n0J+/QpQVVaKwpF8ogEi07WsiCJdVHhBL fJAw== X-Gm-Message-State: AOJu0Yy78do2kCJQIhIOTm6FH132XTLHcsJYaFvR63lAH0rQdGD8a+hB Q0knNiNmuAcmDx7zpEU3pxxqDxcZZ0UBVf+zyqFj2HkObBjWYWN9PB88NHXMbKm7r55wfgNTAZA = X-Google-Smtp-Source: AGHT+IFq+QJIesTrXBv7jaHCFFvG55+d0eusKpkXSy+7DBpxCbOz4mk8N3ZgPsxH503bFkOEYCsZ8w== X-Received: by 2002:a05:6602:641c:b0:837:7f8e:dfe2 with SMTP id ca18e2360f4ac-83b64f38eeamr1732407339f.2.1730742679466; Mon, 04 Nov 2024 09:51:19 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:18 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Dragan Simic , Heinrich Schuchardt , Ilias Apalodimas , Nam Cao , Peter Robinson , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tony Dinh Subject: [PATCH v3 02/19] bootstd: Move bootflow-clearing to bootstd Date: Mon, 4 Nov 2024 10:50:53 -0700 Message-Id: <20241104175110.1048449-3-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean This relates to more than just the bootdev, since there is a global list of bootflows. Move the function to the bootstd file and rename it. Signed-off-by: Simon Glass Acked-by: Heinrich Schuchardt --- (no changes since v1) boot/bootdev-uclass.c | 19 +++++-------------- boot/bootstd-uclass.c | 15 +++++++++++++++ cmd/bootflow.c | 2 +- include/bootdev.h | 10 ---------- include/bootstd.h | 10 ++++++++++ 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index eddbf60600c..26b003427ec 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -557,19 +557,6 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, return ops->get_bootflow(dev, iter, bflow); } -void bootdev_clear_bootflows(struct udevice *dev) -{ - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - - while (!list_empty(&ucp->bootflow_head)) { - struct bootflow *bflow; - - bflow = list_first_entry(&ucp->bootflow_head, struct bootflow, - bm_node); - bootflow_remove(bflow); - } -} - int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, int *method_flagsp) { @@ -935,7 +922,11 @@ static int bootdev_post_bind(struct udevice *dev) static int bootdev_pre_unbind(struct udevice *dev) { - bootdev_clear_bootflows(dev); + int ret; + + ret = bootstd_clear_bootflows_for_bootdev(dev); + if (ret) + return log_msg_ret("bun", ret); return 0; } diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index bf6e49ad97a..596d3e5e41d 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -86,6 +86,21 @@ int bootstd_add_bootflow(struct bootflow *bflow) return 0; } +int bootstd_clear_bootflows_for_bootdev(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + while (!list_empty(&ucp->bootflow_head)) { + struct bootflow *bflow; + + bflow = list_first_entry(&ucp->bootflow_head, struct bootflow, + bm_node); + bootflow_remove(bflow); + } + + return 0; +} + static int bootstd_remove(struct udevice *dev) { struct bootstd_priv *priv = dev_get_priv(dev); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 8962464bbf8..1c1146ce11e 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -197,7 +197,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, show_header(); } if (dev) - bootdev_clear_bootflows(dev); + bootstd_clear_bootflows_for_bootdev(dev); else bootstd_clear_glob(); for (i = 0, diff --git a/include/bootdev.h b/include/bootdev.h index 8db198dd56b..f9cae2fd1fd 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -185,16 +185,6 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, */ void bootdev_list(bool probe); -/** - * bootdev_clear_bootflows() - Clear bootflows from a bootdev - * - * Each bootdev maintains a list of discovered bootflows. This provides a - * way to clear it. These bootflows are removed from the global list too. - * - * @dev: bootdev device to update - */ -void bootdev_clear_bootflows(struct udevice *dev); - /** * bootdev_first_bootflow() - Get the first bootflow from a bootdev * diff --git a/include/bootstd.h b/include/bootstd.h index 3fc93a4ec2e..4220ece785d 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -122,4 +122,14 @@ int bootstd_prog_boot(void); */ int bootstd_add_bootflow(struct bootflow *bflow); +/** + * bootstd_clear_bootflows_for_bootdev() - Clear bootflows from a bootdev + * + * Each bootdev maintains a list of discovered bootflows. This provides a + * way to clear it. These bootflows are removed from the global list too. + * + * @dev: bootdev device to update + */ +int bootstd_clear_bootflows_for_bootdev(struct udevice *dev); + #endif From patchwork Mon Nov 4 17:50:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006420 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nWQdPEwa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzYV5mFTz1xxN for ; Tue, 5 Nov 2024 04:51:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65BC288ED9; Mon, 4 Nov 2024 18:51:26 +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="nWQdPEwa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03CD088D7E; Mon, 4 Nov 2024 18:51:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 D565788DFA for ; Mon, 4 Nov 2024 18:51:22 +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-xd36.google.com with SMTP id ca18e2360f4ac-83ab5b4b048so212339739f.2 for ; Mon, 04 Nov 2024 09:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742681; x=1731347481; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wm4E9xlZw9x6n5A9J58U+VgJ1bv+Wqol7oUbwpKYvJg=; b=nWQdPEwadrPigzM4rmlELABqbXbTk5p//5195MnRx0r56J/dSSNKDaMN4RqxAX8aP3 iWxguaFXe9EPvJiBYOKNs4CFhZ/uhOOXGjCCbb3yN+1xI/4wamJ2rQmhiAcU4XxsYVwU BlyBWnGB5SNoLGYeDmr5JNQ+6XiUa2sJmH67c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742681; x=1731347481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wm4E9xlZw9x6n5A9J58U+VgJ1bv+Wqol7oUbwpKYvJg=; b=AnUD0CQS+fGOBIf9RDFw4C1DGGHvUAezsfTfn97NViHm3s1JhnMh0LSIZbSrELhYA/ WvCxRVofDC9Ak+IwF3OgmPbzqXxlaREnsKet7uH2QdE9o8xcsm05zXOACjEjZzEsC+ZS afH/BXq8t8RZNI+/RQOg0udaAYGLcb3wLN1WSwCVaQQGyyHjnRJPObesVXnnqGHDbQlI wavpWSToGtjIQY3zvpMGpKnkZfbI5UsB3gdNdC2hFTXJoUBS92nMtdS6Yuim7h1WmVQf SOP8Htm66MAaWp5pw3Pgp8yIBVxlIi2bR5kY477viR20o1+CB4+LmXlzTEuoULXovVVN jLNQ== X-Gm-Message-State: AOJu0YyiFQ+1y9coxgEvdnFwH40ADyPadRgAIrATAkHiZNj32q8Y1o5m vpDKJqbGQqmmHUok4dku/c/Xw6v6l4ltFfGCUDAdRP1AiicKdlaJ9AL8sm7V8GF3ca67jHjUIN8 = X-Google-Smtp-Source: AGHT+IGUkdL1xDPoUl341/Fbb7EWT1vyGF0R4jYE3lwJBYn+dOTaOhUSWM4ezXuw7/nIbTaeZHwUbw== X-Received: by 2002:a05:6e02:12e1:b0:3a6:ac17:13e4 with SMTP id e9e14a558f8ab-3a6ac1717a2mr146600335ab.18.1730742681096; Mon, 04 Nov 2024 09:51:21 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Peter Robinson Subject: [PATCH v3 03/19] bootstd: Add a function to get bootstd only if available Date: Mon, 4 Nov 2024 10:50:54 -0700 Message-Id: <20241104175110.1048449-4-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Provide a function which is safe to call in the 'unbind' path, which returns the bootstd priv data if available. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootstd-uclass.c | 11 +++++++++++ include/bootstd.h | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index 596d3e5e41d..b2f80808c85 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -140,6 +140,17 @@ const char *const *const bootstd_get_prefixes(struct udevice *dev) return std->prefixes ? std->prefixes : default_prefixes; } +struct bootstd_priv *bootstd_try_priv(void) +{ + struct udevice *dev; + + dev = uclass_try_first_device(UCLASS_BOOTSTD); + if (!dev || !device_active(dev)) + return NULL; + + return dev_get_priv(dev); +} + int bootstd_get_priv(struct bootstd_priv **stdp) { struct udevice *dev; diff --git a/include/bootstd.h b/include/bootstd.h index 4220ece785d..4535d91e2ad 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -89,6 +89,23 @@ const char *const *const bootstd_get_prefixes(struct udevice *dev); */ int bootstd_get_priv(struct bootstd_priv **stdp); +/** + * bootstd_try_priv() - Try to get the (single) state for the bootstd system + * + * The state holds a global list of all bootflows that have been found. This + * function returns the state if available, but takes care not to create the + * device (or uclass) if it doesn't exist. + * + * This function is safe to use in the 'unbind' path. It will always return NULL + * unless the bootstd device is probed and ready, e.g. bootstd_get_priv() has + * previously been called. + * + * TODO(sjg@chromium.org): Consider adding a bootstd pointer to global_data + * + * Return: pointer if the device exists, else NULL + */ +struct bootstd_priv *bootstd_try_priv(void); + /** * bootstd_clear_glob() - Clear the global list of bootflows * From patchwork Mon Nov 4 17:50:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006421 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XCgPPwYF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzYj10zrz1xxN for ; Tue, 5 Nov 2024 04:51:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE88088DFA; Mon, 4 Nov 2024 18:51:27 +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="XCgPPwYF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C8A4F88F4E; Mon, 4 Nov 2024 18:51:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (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 8067188618 for ; Mon, 4 Nov 2024 18:51:24 +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-oi1-x22d.google.com with SMTP id 5614622812f47-3e602a73ba1so2471031b6e.2 for ; Mon, 04 Nov 2024 09:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742683; x=1731347483; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pBYTjdxWCadibcCbIw2uY5w6dzpPH2gyh9V5jrl7U1s=; b=XCgPPwYF4g1q73PSFUqBcNVedW5vfkoehvQf8Y8spPECkYQSw1SOX8sMFBVyppQHpr CjrgHcOyWwqwmCu9yvvJQiLoPiN97UW7JhbVZkE7HM+G+MH4SEsqaCbSbrtvNd+5E/iH 5JAVxla4Mxy6tMCE6rPu5PLWyZUluJB2SF8fs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742683; x=1731347483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pBYTjdxWCadibcCbIw2uY5w6dzpPH2gyh9V5jrl7U1s=; b=wfrR24XApUOjWGzesXtVeFTRRR1AjBrsMJMU0F6fYQs1fup1J4erHqDElOtAcAhSDi en9AXbcD4zv/IZB6F0eDHlzCaReySMhLeMMf+kAEbrVVpiqTjeNSkvAXCvBnwSUj7T+H uF0RMNvNYuoQD+9OcJIs/nYjIobFRgUvWfxRWJLpd/+pv2r5OBMSUeMveyaBPPxT9fw9 KleROJKljCjMmUU/LHIQfBs5afoWOAW+97U04wR0cl7xtyQr6/wE/fNXrKxCR2rMm1IJ OTWVno7rJkUdgNzGgkntR+2V+lwQI7S+CSj2og5xflfA1+TwRh9bz+MW7RKNEQJxhCnn g7Ow== X-Gm-Message-State: AOJu0YxubvF82Qpw2TvxYh4VhRVyPuqCUpU6AhGjXlNxHgod/jh9T3M+ DIBi2lKp5mBO4K9JKpVzzYpPBd9xUGDTAkrDJdrH3esNfnWs23JOcq5+L2FIX3atxT+t17su9y0 = X-Google-Smtp-Source: AGHT+IFCUt85+bwixIYLuQ3BEiDpplmU8ZtVmhJslxrEkKjwFT/AhZUbE8FEUOGnTNY0TFUvv2wIZg== X-Received: by 2002:a05:6808:1a2a:b0:3e6:1e56:93b6 with SMTP id 5614622812f47-3e66091594amr15062349b6e.38.1730742682622; Mon, 04 Nov 2024 09:51:22 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Dragan Simic , Guillaume La Roque , Heinrich Schuchardt , Igor Opaniuk , Ilias Apalodimas , Julien Masson , Mattijs Korpershoek , Maximilian Brune , Nam Cao , Peter Robinson , Quentin Schulz , Shantur Rathore , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tony Dinh Subject: [PATCH v3 04/19] bootstd: Drop the bootdev-specific list of bootflows Date: Mon, 4 Nov 2024 10:50:55 -0700 Message-Id: <20241104175110.1048449-5-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean This list is only used by two functions, which can be updated to iterate through the global list. Take this approach, which allows the bootdev list to be dropped. Overall this makes the code slightly more complicated, but will allow moving the bootflow list into an alist Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 61 +++++++++++++++++++++++++++---------------- boot/bootflow.c | 2 -- boot/bootstd-uclass.c | 17 +++++------- include/bootdev.h | 2 -- include/bootflow.h | 5 +--- include/bootstd.h | 2 +- 6 files changed, 48 insertions(+), 41 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 26b003427ec..81adfb4cfb7 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -32,30 +32,57 @@ enum { BOOT_TARGETS_MAX_LEN = 100, }; +struct bootflow *bootdev_next_bootflow_(struct bootstd_priv *std, + struct udevice *dev, + struct bootflow *prev) +{ + struct bootflow *bflow = prev; + + if (bflow) { + if (list_is_last(&bflow->glob_node, &std->glob_head)) + return NULL; + bflow = list_entry(bflow->glob_node.next, struct bootflow, + glob_node); + } else { + if (list_empty(&std->glob_head)) + return NULL; + + bflow = list_first_entry(&std->glob_head, struct bootflow, + glob_node); + } + + while (bflow->dev != dev) { + if (list_is_last(&bflow->glob_node, &std->glob_head)) + return NULL; + bflow = list_entry(bflow->glob_node.next, struct bootflow, + glob_node); + } + + return bflow; +} + int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp) { - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + struct bootstd_priv *std = bootstd_try_priv(); + struct bootflow *bflow; - if (list_empty(&ucp->bootflow_head)) + bflow = bootdev_next_bootflow_(std, dev, NULL); + if (!bflow) return -ENOENT; - - *bflowp = list_first_entry(&ucp->bootflow_head, struct bootflow, - bm_node); + *bflowp = bflow; return 0; } int bootdev_next_bootflow(struct bootflow **bflowp) { - struct bootflow *bflow = *bflowp; - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev); - - *bflowp = NULL; + struct bootstd_priv *std = bootstd_try_priv(); + struct bootflow *bflow; - if (list_is_last(&bflow->bm_node, &ucp->bootflow_head)) + bflow = bootdev_next_bootflow_(std, (*bflowp)->dev, *bflowp); + if (!bflow) return -ENOENT; - - *bflowp = list_entry(bflow->bm_node.next, struct bootflow, bm_node); + *bflowp = bflow; return 0; } @@ -911,15 +938,6 @@ void bootdev_list_hunters(struct bootstd_priv *std) printf("(total hunters: %d)\n", n_ent); } -static int bootdev_post_bind(struct udevice *dev) -{ - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - - INIT_LIST_HEAD(&ucp->bootflow_head); - - return 0; -} - static int bootdev_pre_unbind(struct udevice *dev) { int ret; @@ -936,6 +954,5 @@ UCLASS_DRIVER(bootdev) = { .name = "bootdev", .flags = DM_UC_FLAG_SEQ_ALIAS, .per_device_plat_auto = sizeof(struct bootdev_uc_plat), - .post_bind = bootdev_post_bind, .pre_unbind = bootdev_pre_unbind, }; diff --git a/boot/bootflow.c b/boot/bootflow.c index d8807eb109d..804809dc100 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -476,8 +476,6 @@ void bootflow_free(struct bootflow *bflow) void bootflow_remove(struct bootflow *bflow) { - if (bflow->dev) - list_del(&bflow->bm_node); list_del(&bflow->glob_node); bootflow_free(bflow); diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index b2f80808c85..91e90bdf43c 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -77,25 +77,22 @@ int bootstd_add_bootflow(struct bootflow *bflow) memcpy(new, bflow, sizeof(*bflow)); list_add_tail(&new->glob_node, &std->glob_head); - if (bflow->dev) { - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev); - - list_add_tail(&new->bm_node, &ucp->bootflow_head); - } return 0; } int bootstd_clear_bootflows_for_bootdev(struct udevice *dev) { - struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + struct bootstd_priv *std = bootstd_try_priv(); - while (!list_empty(&ucp->bootflow_head)) { + if (std) { struct bootflow *bflow; + struct list_head *pos; - bflow = list_first_entry(&ucp->bootflow_head, struct bootflow, - bm_node); - bootflow_remove(bflow); + list_for_each(pos, &std->glob_head) { + bflow = list_entry(pos, struct bootflow, glob_node); + bootflow_remove(bflow); + } } return 0; diff --git a/include/bootdev.h b/include/bootdev.h index f9cae2fd1fd..991b6229c1c 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -109,11 +109,9 @@ struct bootdev_hunter { * This is attached to each device in the bootdev uclass and accessible via * dev_get_uclass_plat(dev) * - * @bootflows: List of available bootflows for this bootdev * @piro: Priority of this bootdev */ struct bootdev_uc_plat { - struct list_head bootflow_head; enum bootdev_prio_t prio; }; diff --git a/include/bootflow.h b/include/bootflow.h index 4d2fc7b69b5..64d1d6c3786 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -56,12 +56,10 @@ enum bootflow_flags_t { /** * struct bootflow - information about a bootflow * - * This is connected into two separate linked lists: + * This is connected into a linked list: * - * bm_sibling - links all bootflows in the same bootdev * glob_sibling - links all bootflows in all bootdevs * - * @bm_node: Points to siblings in the same bootdev * @glob_node: Points to siblings in the global list (all bootdev) * @dev: Bootdev device which produced this bootflow, NULL for flows created by * BOOTMETHF_GLOBAL bootmeths @@ -92,7 +90,6 @@ enum bootflow_flags_t { * @bootmeth_priv: Private data for the bootmeth */ struct bootflow { - struct list_head bm_node; struct list_head glob_node; struct udevice *dev; struct udevice *blk; diff --git a/include/bootstd.h b/include/bootstd.h index 4535d91e2ad..8aff536e3cb 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -123,7 +123,7 @@ void bootstd_clear_glob(void); int bootstd_prog_boot(void); /** - * bootstd_add_bootflow() - Add a bootflow to the bootdev's and global list + * bootstd_add_bootflow() - Add a bootflow to the global list * * All fields in @bflow must be set up. Note that @bflow->dev is used to add the * bootflow to that device. From patchwork Mon Nov 4 17:50:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006422 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FwBM9jK6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzYs3whBz1xxN for ; Tue, 5 Nov 2024 04:52:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AEE4D88E4B; Mon, 4 Nov 2024 18:51:29 +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="FwBM9jK6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7469588FAA; Mon, 4 Nov 2024 18:51:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 11A1E88DA3 for ; Mon, 4 Nov 2024 18:51:26 +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-xd2e.google.com with SMTP id ca18e2360f4ac-83aac75fcceso155025639f.0 for ; Mon, 04 Nov 2024 09:51:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742684; x=1731347484; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rlxpAnvzilHql2ijYgWfvMUeiV8hrluRg5hes2LjLTM=; b=FwBM9jK6ri92Ei110uCTZfTZaPmrEtCrUkOY5jDoMbMm7tOPLfArhfEWcB4jwcZS9D KFGksq3LfeSCWwKiYrbbBONx8Davg4Fpb1GkmvQwaCxSsVo1YfW0VViV0ZM0umVJajrT pbhGvOifd5bD2BQnKsDxINtSblzFi5Za+Kspk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742684; x=1731347484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rlxpAnvzilHql2ijYgWfvMUeiV8hrluRg5hes2LjLTM=; b=nlFKmOBuil3/e+r5lje9AvUwDGPHpdoyiYPlHNhM4PCRb8f41dWcoAiwbqMYRD+iB1 QAcLm2kiGBieNB7E/gP61ea4Qt8nhzwph0kgf8eVcNt0DQc/BSY+P4yewhaCzDAkoca+ 7VXc5R9eA4witC7GRmSWx3JJmLv6CgS7nEV8mMZrwd0fDSvf0sfZ9/5kpRT/w4YT6CAv yfhpbPhTHdqlfbMkneERjrS043ES3oEum9lf9MHeUTA2BEQQESSZ/VGJ1x8uDB1mWVG0 dZ5lSw5L8BlBN3GXt7coghjgEFW3hljIptobS+MJo2gze20fGTjrJrykA4OgqL0Tcmp1 Mwmg== X-Gm-Message-State: AOJu0YyjmH7HRNPyeDVd1MNwjymbhz1EuJlqtpS8YgamrQE3veO5S9Dh 4rUn5RwWJ6ZISWwgfzwsjFw/IaqojJOINkUtY6bGHjiQI5x8jZJk3GgHX/EKb3dO0pNA/Epsoaw = X-Google-Smtp-Source: AGHT+IGvvqxoJeaCYdM1ytp5xFLpsW0lynArH8Ib5RxOfNeeORKLuc8845Gj3s2eqO3ExHT8BZMpAw== X-Received: by 2002:a05:6602:2c06:b0:83a:bd82:77f with SMTP id ca18e2360f4ac-83b719757c9mr1602527439f.8.1730742684190; Mon, 04 Nov 2024 09:51:24 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Dragan Simic , Guillaume La Roque , Heinrich Schuchardt , Igor Opaniuk , Julien Masson , Mattijs Korpershoek , Maximilian Brune , Moritz Fischer , Nam Cao , Peter Robinson , Quentin Schulz , Shantur Rathore , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tony Dinh Subject: [PATCH v3 05/19] bootstd: Move the bootflow list into an alist Date: Mon, 4 Nov 2024 10:50:56 -0700 Message-Id: <20241104175110.1048449-6-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Use an alist for this data structure as it is somewhat simpler to manage. This means that bootstd holds a simple list of bootflow structs and can drop it at will, without chasing down lists. Signed-off-by: Simon Glass --- Changes in v3: - Update bootstd_add_bootflow() to return the element number boot/bootdev-uclass.c | 47 +++++++++++++------------------------------ boot/bootflow.c | 16 ++++----------- boot/bootstd-uclass.c | 42 +++++++++++++++++++------------------- cmd/bootdev.c | 2 +- cmd/bootflow.c | 2 +- include/bootflow.h | 11 +++++----- include/bootstd.h | 8 +++++--- 7 files changed, 51 insertions(+), 77 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 81adfb4cfb7..a4e1d79ec9b 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -32,41 +32,17 @@ enum { BOOT_TARGETS_MAX_LEN = 100, }; -struct bootflow *bootdev_next_bootflow_(struct bootstd_priv *std, - struct udevice *dev, - struct bootflow *prev) -{ - struct bootflow *bflow = prev; - - if (bflow) { - if (list_is_last(&bflow->glob_node, &std->glob_head)) - return NULL; - bflow = list_entry(bflow->glob_node.next, struct bootflow, - glob_node); - } else { - if (list_empty(&std->glob_head)) - return NULL; - - bflow = list_first_entry(&std->glob_head, struct bootflow, - glob_node); - } - - while (bflow->dev != dev) { - if (list_is_last(&bflow->glob_node, &std->glob_head)) - return NULL; - bflow = list_entry(bflow->glob_node.next, struct bootflow, - glob_node); - } - - return bflow; -} - int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp) { - struct bootstd_priv *std = bootstd_try_priv(); + struct bootstd_priv *std; struct bootflow *bflow; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return log_msg_ret("bff", ret); - bflow = bootdev_next_bootflow_(std, dev, NULL); + bflow = alist_getw(&std->bootflows, 0, struct bootflow); if (!bflow) return -ENOENT; *bflowp = bflow; @@ -76,10 +52,15 @@ int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp) int bootdev_next_bootflow(struct bootflow **bflowp) { - struct bootstd_priv *std = bootstd_try_priv(); + struct bootstd_priv *std; struct bootflow *bflow; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return log_msg_ret("bff", ret); - bflow = bootdev_next_bootflow_(std, (*bflowp)->dev, *bflowp); + bflow = alist_nextw(&std->bootflows, *bflowp); if (!bflow) return -ENOENT; *bflowp = bflow; diff --git a/boot/bootflow.c b/boot/bootflow.c index 804809dc100..7ce04fd92cd 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -55,11 +55,10 @@ int bootflow_first_glob(struct bootflow **bflowp) if (ret) return ret; - if (list_empty(&std->glob_head)) + if (!std->bootflows.count) return -ENOENT; - *bflowp = list_first_entry(&std->glob_head, struct bootflow, - glob_node); + *bflowp = alist_getw(&std->bootflows, 0, struct bootflow); return 0; } @@ -67,20 +66,16 @@ int bootflow_first_glob(struct bootflow **bflowp) int bootflow_next_glob(struct bootflow **bflowp) { struct bootstd_priv *std; - struct bootflow *bflow = *bflowp; int ret; ret = bootstd_get_priv(&std); if (ret) return ret; - *bflowp = NULL; - - if (list_is_last(&bflow->glob_node, &std->glob_head)) + *bflowp = alist_nextw(&std->bootflows, *bflowp); + if (!*bflowp) return -ENOENT; - *bflowp = list_entry(bflow->glob_node.next, struct bootflow, glob_node); - return 0; } @@ -476,10 +471,7 @@ void bootflow_free(struct bootflow *bflow) void bootflow_remove(struct bootflow *bflow) { - list_del(&bflow->glob_node); - bootflow_free(bflow); - free(bflow); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index 91e90bdf43c..8c0fd4e63c3 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -6,6 +6,7 @@ * Written by Simon Glass */ +#include #include #include #include @@ -42,13 +43,11 @@ static int bootstd_of_to_plat(struct udevice *dev) static void bootstd_clear_glob_(struct bootstd_priv *priv) { - while (!list_empty(&priv->glob_head)) { - struct bootflow *bflow; + struct bootflow *bflow; - bflow = list_first_entry(&priv->glob_head, struct bootflow, - glob_node); + alist_for_each(bflow, &priv->bootflows) bootflow_remove(bflow); - } + alist_empty(&priv->bootflows); } void bootstd_clear_glob(void) @@ -64,36 +63,37 @@ void bootstd_clear_glob(void) int bootstd_add_bootflow(struct bootflow *bflow) { struct bootstd_priv *std; - struct bootflow *new; int ret; ret = bootstd_get_priv(&std); if (ret) return ret; - new = malloc(sizeof(*bflow)); - if (!new) - return log_msg_ret("bflow", -ENOMEM); - memcpy(new, bflow, sizeof(*bflow)); - - list_add_tail(&new->glob_node, &std->glob_head); + ret = std->bootflows.count; + bflow = alist_add(&std->bootflows, *bflow); + if (!bflow) + return log_msg_ret("bf2", -ENOMEM); - return 0; + return ret; } int bootstd_clear_bootflows_for_bootdev(struct udevice *dev) { struct bootstd_priv *std = bootstd_try_priv(); + struct bootflow *from, *to; - if (std) { - struct bootflow *bflow; - struct list_head *pos; + /* if bootstd does not exist we cannot have any bootflows */ + if (!std) + return 0; - list_for_each(pos, &std->glob_head) { - bflow = list_entry(pos, struct bootflow, glob_node); - bootflow_remove(bflow); - } + /* Drop any bootflows that mention this dev */ + alist_for_each_filter(from, to, &std->bootflows) { + if (from->dev == dev) + bootflow_remove(from); + else + *to++ = *from; } + alist_update_end(&std->bootflows, to); return 0; } @@ -165,7 +165,7 @@ static int bootstd_probe(struct udevice *dev) { struct bootstd_priv *std = dev_get_priv(dev); - INIT_LIST_HEAD(&std->glob_head); + alist_init_struct(&std->bootflows, struct bootflow); return 0; } diff --git a/cmd/bootdev.c b/cmd/bootdev.c index fa7285ba25e..4bc229e809a 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -81,7 +81,7 @@ static int do_bootdev_info(struct cmd_tbl *cmdtp, int flag, int argc, dev = priv->cur_bootdev; - /* Count the number of bootflows, including how many are valid*/ + /* Count the number of bootflows, including how many are valid */ num_valid = 0; for (ret = bootdev_first_bootflow(dev, &bflow), i = 0; !ret; diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 1c1146ce11e..f88995a478f 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -208,7 +208,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, if (!ret) num_valid++; ret = bootstd_add_bootflow(&bflow); - if (ret) { + if (ret < 0) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/include/bootflow.h b/include/bootflow.h index 64d1d6c3786..9b24fb5c3eb 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -56,11 +56,8 @@ enum bootflow_flags_t { /** * struct bootflow - information about a bootflow * - * This is connected into a linked list: + * All bootflows are listed in bootstd's bootflow alist in struct bootstd_priv * - * glob_sibling - links all bootflows in all bootdevs - * - * @glob_node: Points to siblings in the global list (all bootdev) * @dev: Bootdev device which produced this bootflow, NULL for flows created by * BOOTMETHF_GLOBAL bootmeths * @blk: Block device which contains this bootflow, NULL if this is a network @@ -90,7 +87,6 @@ enum bootflow_flags_t { * @bootmeth_priv: Private data for the bootmeth */ struct bootflow { - struct list_head glob_node; struct udevice *dev; struct udevice *blk; int part; @@ -390,7 +386,10 @@ const char *bootflow_state_get_name(enum bootflow_state_t state); /** * bootflow_remove() - Remove a bootflow and free its memory * - * This updates the linked lists containing the bootflow then frees it. + * This updates the 'global' linked list containing the bootflow, then frees it. + * It does not remove it from bootflows alist in struct bootstd_priv + * + * This does not free bflow itself, since this is assumed to be in an alist * * @bflow: Bootflow to remove */ diff --git a/include/bootstd.h b/include/bootstd.h index 8aff536e3cb..3398e48e88b 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -9,6 +9,7 @@ #ifndef __bootstd_h #define __bootstd_h +#include #include #include #include @@ -30,7 +31,8 @@ struct udevice; * terminated) * @cur_bootdev: Currently selected bootdev (for commands) * @cur_bootflow: Currently selected bootflow (for commands) - * @glob_head: Head for the global list of all bootflows across all bootdevs + * @bootflows: (struct bootflow) Global list of all bootflows across all + * bootdevs * @bootmeth_count: Number of bootmeth devices in @bootmeth_order * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none @@ -44,7 +46,7 @@ struct bootstd_priv { const char **env_order; struct udevice *cur_bootdev; struct bootflow *cur_bootflow; - struct list_head glob_head; + struct alist bootflows; int bootmeth_count; struct udevice **bootmeth_order; struct udevice *vbe_bootmeth; @@ -135,7 +137,7 @@ int bootstd_prog_boot(void); * since this function takes over ownership of these. This functions makes * a copy of @bflow itself (without allocating its fields again), so the * caller must dispose of the memory used by the @bflow pointer itself - * Return: 0 if OK, -ENOMEM if out of memory + * Return: element number in the list, if OK, -ENOMEM if out of memory */ int bootstd_add_bootflow(struct bootflow *bflow); From patchwork Mon Nov 4 17:50:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006423 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KSwjuVGJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzZ232hfz1xxN for ; Tue, 5 Nov 2024 04:52:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 218BF88E50; Mon, 4 Nov 2024 18:51:32 +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="KSwjuVGJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A5CC28880B; Mon, 4 Nov 2024 18:51:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 7353588F95 for ; Mon, 4 Nov 2024 18:51:28 +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-il1-x132.google.com with SMTP id e9e14a558f8ab-3a6bf539cabso7310225ab.3 for ; Mon, 04 Nov 2024 09:51:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742686; x=1731347486; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ozNG7fiNCfQdI+g22LplNj6OcHOBkmFo6yfCi0oTzto=; b=KSwjuVGJvr04W5MY/oACayq7kwh2eu2jJPpZG1VMEcIPM/k9QQhmUzDGpajdxADuEy CtaaBf8KWnMGIbdo1QxoegZJYs8JPLEdgXqyQ++Wf742cPmpzBzz9bdhrkm9kslrvaZs uR60AVcL93PV8yEpchuM2GDuixCJYbbPDaIeU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742686; x=1731347486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ozNG7fiNCfQdI+g22LplNj6OcHOBkmFo6yfCi0oTzto=; b=B7N8HG6JJVw13pDKQbOnfhw0jOhHw3jgE1Ce+GDrIeyIlS7pdY2fCbqkhEaiZc50wB dS0Z1qhVTk9I0lwwiNISdpokSN8z6dgvSJUu+LeR87kWsoMPRyy56XzMvSP6r02oyMoc UR1HWT/WMeiQ2BHOiTqwKn7B1rLeIEBJu8//EKHnAMcek7NJW9UWIaKSOISrJINzdnBr aRM6jf/K5y5x/AW+YXiDNC+b+BIrcsaJvTyQHsuXRubb4iIyEBy4prXFrXWYxdsbarOT nyLEarHDvwMdxVJRJtHgZRPw3oGpVjAhiCJCUBAEB206uQ7cTu2goI/RD49Im2q7V9Tg Qs8g== X-Gm-Message-State: AOJu0Yzl8krAXIlBRuVP4JYAz3otEtL2pK7ckHGHCUbYU7xZwimsKh0w 11NWqPvKqliaNreKeYu4sKhumsE/7lC1cu5T//SLc6n0jHqSfaMLjTbECAD+JcEFTxpUWu8Ws1c = X-Google-Smtp-Source: AGHT+IGPeFJCuO2KL+8kPGVwjjHrUkQmz45Vq7S6nhvJ0vnNiNEvIXoip//fmZqPl0nw+Xrt8i9fvQ== X-Received: by 2002:a05:6e02:1688:b0:3a6:be66:ce53 with SMTP id e9e14a558f8ab-3a6be66d4b1mr87825235ab.18.1730742686344; Mon, 04 Nov 2024 09:51:26 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Guillaume La Roque , Heinrich Schuchardt , Igor Opaniuk , Julien Masson , Mattijs Korpershoek , Maximilian Brune , Nam Cao , Quentin Schulz , Shantur Rathore Subject: [PATCH v3 06/19] bootstd: Maintain a list of images Date: Mon, 4 Nov 2024 10:50:57 -0700 Message-Id: <20241104175110.1048449-7-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean We want to keep track of images which are loaded, or those which could perhaps be loaded. This will make it easier to manage memory allocation, as well as permit removal of the EFI set_efi_bootdev() feature. Add a list of these, attached to the bootflow. For now the list is empty. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Add an image type extension in bootflow.h - Use the word 'feature' instead of 'hack' boot/bootflow.c | 26 +++++++++++++++++++++++++ include/bootflow.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index 7ce04fd92cd..94f34dcad0f 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -23,6 +23,13 @@ enum { BF_NO_MORE_DEVICES = -ENODEV, }; +static const char *const bootflow_img[BFI_COUNT - BFI_FIRST] = { + "extlinux_cfg", + "logo", + "efi", + "cmdline", +}; + /** * bootflow_state - name for each state * @@ -455,10 +462,13 @@ void bootflow_init(struct bootflow *bflow, struct udevice *bootdev, bflow->dev = bootdev; bflow->method = meth; bflow->state = BOOTFLOWST_BASE; + alist_init_struct(&bflow->images, struct bootflow_img); } void bootflow_free(struct bootflow *bflow) { + struct bootflow_img *img; + free(bflow->name); free(bflow->subdir); free(bflow->fname); @@ -467,6 +477,10 @@ void bootflow_free(struct bootflow *bflow) free(bflow->os_name); free(bflow->fdt_fname); free(bflow->bootmeth_priv); + + alist_for_each(img, &bflow->images) + free(img->fname); + alist_empty(&bflow->images); } void bootflow_remove(struct bootflow *bflow) @@ -950,3 +964,15 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg) return 0; } + +const char *bootflow_img_type_name(enum bootflow_img_t type) +{ + const char *name; + + if (type >= BFI_FIRST && type < BFI_COUNT) + name = bootflow_img[type - BFI_FIRST]; + else + name = genimg_get_type_short_name(type); + + return name; +} diff --git a/include/bootflow.h b/include/bootflow.h index 9b24fb5c3eb..f407bb356b4 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -7,7 +7,9 @@ #ifndef __bootflow_h #define __bootflow_h +#include #include +#include #include #include @@ -85,6 +87,7 @@ enum bootflow_flags_t { * @cmdline: OS command line, or NULL if not known (allocated) * @x86_setup: Pointer to x86 setup block inside @buf, NULL if not present * @bootmeth_priv: Private data for the bootmeth + * @images: List of loaded images (struct bootstd_img) */ struct bootflow { struct udevice *dev; @@ -109,6 +112,44 @@ struct bootflow { char *cmdline; void *x86_setup; void *bootmeth_priv; + struct alist images; +}; + +/** + * bootflow_img_t: Supported image types + * + * This uses image_type_t for most types, but extends it + * + * @BFI_EXTLINUX_CFG: extlinux configuration-file + * @BFI_LOGO: logo image + * @BFI_EFI: EFI PE image + * @BFI_CMDLINE: OS command-line string + */ +enum bootflow_img_t { + BFI_FIRST = IH_TYPE_COUNT, + BFI_EXTLINUX_CFG = BFI_FIRST, + BFI_LOGO, + BFI_EFI, + BFI_CMDLINE, + + BFI_COUNT, +}; + +/** + * struct bootflow_img - Information about an image which has been loaded + * + * This keeps track of a single, loaded image. + * + * @fname: Filename used to load the image (allocated) + * @type: Image type (IH_TYPE_...) + * @addr: Address to which the image was loaded, 0 if not yet loaded + * @size: Size of the image + */ +struct bootflow_img { + char *fname; + enum bootflow_img_t type; + ulong addr; + ulong size; }; /** @@ -565,4 +606,11 @@ int bootflow_cmdline_get_arg(struct bootflow *bflow, const char *arg, */ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg); +/** + * bootflow_img_type_name() - Get the name for an image type + * + * @type: Type to check (either enum bootflow_img_t or enum image_type_t + * Return: Image name, or "unknown" if not known + */ +const char *bootflow_img_type_name(enum bootflow_img_t type); #endif From patchwork Mon Nov 4 17:50:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006424 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Dm8ZtxV7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzZC4Pc1z1xxN for ; Tue, 5 Nov 2024 04:52:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D46E88F0C; Mon, 4 Nov 2024 18:51:33 +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="Dm8ZtxV7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F358C88618; Mon, 4 Nov 2024 18:51:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 B3EC988E50 for ; Mon, 4 Nov 2024 18:51:29 +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-il1-x12d.google.com with SMTP id e9e14a558f8ab-3a6ad7c5827so14076755ab.0 for ; Mon, 04 Nov 2024 09:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742688; x=1731347488; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=orKIWmqFcQLkEeTWHV5zZxMKRZEip9/cAkBzwg8IJuo=; b=Dm8ZtxV73377e39Sv0uEERTaUWfPqRYJSGaCIZQwY35J5Jlg47ZCrdMAO9ga77ho1Q zxcHp42lq+QjScQqXlHceRGkwKwOiGd5phZBftO/njSrJCCD2W6P3UAojP/DFxyIFKa8 NQJwKEdvZ9uyZpopDhWBOMEan/8gQ0aSe5pCc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742688; x=1731347488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=orKIWmqFcQLkEeTWHV5zZxMKRZEip9/cAkBzwg8IJuo=; b=L8bM28u0at2+pqQAhUSsnOwKmcDZ+Y4KlFfz66KlquLe1OU4+ZLqQvdvt16FK83Qxw 06CBn/WRkfr2/Yd+OrHJl5NymGb6cNELvrearQZhQTwxd7DhN5AKyxia35posY47y0CF xrANkPru73dkrW1RHGYhsBwTXG75xs1Uh2LLTekeXmiS89PRZkymiZzFXZ08bzxrbmVu NiDB/s5IUaFgCdjIYCuArJfRztYeRwvbOxJanCk4B4aNZ8JyqucLGIK1m5Bi2N40YUSm 2NEVp3MUcGrTEio8/doQiuIOl5riXXnWYF4C6Bg6gSM5PoCIw1TrKNN+oSC86ErJHhEA xVGA== X-Gm-Message-State: AOJu0Yw+D7laktyCc+1XQHOaU2JzIxsOua7Sgpdw/Gs/XcWkV9LPxUc5 cSsZRQzRryUSp0OyJP6O+Zpog6Jk/9YwbbtCJI1XNzmcfdHKJLJe8DnKJHuuFmy9LWIKERMX4uw = X-Google-Smtp-Source: AGHT+IFlawNcN/HyEMMUFyFM58n/l8msfo0vhkveodlFgs0t9loQaesiY18tFTDWASlkBiUdErcxDQ== X-Received: by 2002:a05:6e02:218f:b0:3a6:af24:b8c4 with SMTP id e9e14a558f8ab-3a6b0354e19mr132529085ab.20.1730742687910; Mon, 04 Nov 2024 09:51:27 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Guillaume La Roque , Heinrich Schuchardt , Igor Opaniuk , Ion Agorria , Julien Masson , Martyn Welch , Mattijs Korpershoek , Maximilian Brune , Moritz Fischer , Nam Cao , Quentin Schulz , Shantur Rathore , Svyatoslav Ryhel Subject: [PATCH v3 07/19] bootstd: Update bootmeth_alloc_file() to record images Date: Mon, 4 Nov 2024 10:50:58 -0700 Message-Id: <20241104175110.1048449-8-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean As a first step to recording images and where they came from, update this function to do so, since it is used by two bootmeths Create a helper function in the bootflow system, since recorded images are always associated with bootflows. Signed-off-by: Simon Glass --- Changes in v3: - Add a helper in bootflow Changes in v2: - Update to use a new image-type enum in bootflow.h boot/bootflow.c | 21 +++++++++++++++++++++ boot/bootmeth-uclass.c | 12 +++++++++++- boot/bootmeth_extlinux.c | 2 +- boot/bootmeth_script.c | 3 ++- include/bootflow.h | 15 +++++++++++++++ include/bootmeth.h | 8 +++++--- 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 94f34dcad0f..a10d3012b48 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -976,3 +976,24 @@ const char *bootflow_img_type_name(enum bootflow_img_t type) return name; } + +struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char *fname, + enum bootflow_img_t type, ulong addr, + ulong size) +{ + struct bootflow_img img, *ptr; + + memset(&img, '\0', sizeof(struct bootflow_img)); + img.fname = strdup(fname); + if (!img.fname) + return NULL; + + img.type = type; + img.addr = addr; + img.size = size; + ptr = alist_add(&bflow->images, img); + if (!ptr) + return NULL; + + return ptr; +} diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 5b5fea39b3b..c219631816f 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -6,6 +6,7 @@ #define LOG_CATEGORY UCLASS_BOOTSTD +#include #include #include #include @@ -326,8 +327,10 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc, return 0; } -int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align) +int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align, + enum bootflow_img_t type) { + struct blk_desc *desc = NULL; void *buf; uint size; int ret; @@ -344,6 +347,13 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align) bflow->state = BOOTFLOWST_READY; bflow->buf = buf; + if (bflow->blk) + desc = dev_get_uclass_plat(bflow->blk); + + if (!bootflow_img_add(bflow, bflow->fname, type, map_to_sysmem(buf), + size)) + return log_msg_ret("bai", -ENOMEM); + return 0; } diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index be8fbf4df63..6c158c2a6c6 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -159,7 +159,7 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) return log_msg_ret("try", ret); size = bflow->size; - ret = bootmeth_alloc_file(bflow, 0x10000, 1); + ret = bootmeth_alloc_file(bflow, 0x10000, 1, BFI_EXTLINUX_CFG); if (ret) return log_msg_ret("read", ret); diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c index c5cbf18c2e6..a2fb2899885 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -98,7 +98,8 @@ static int script_read_bootflow_file(struct udevice *bootstd, if (!bflow->subdir) return log_msg_ret("prefix", -ENOMEM); - ret = bootmeth_alloc_file(bflow, 0x10000, ARCH_DMA_MINALIGN); + ret = bootmeth_alloc_file(bflow, 0x10000, ARCH_DMA_MINALIGN, + (enum bootflow_img_t)IH_TYPE_SCRIPT); if (ret) return log_msg_ret("read", ret); diff --git a/include/bootflow.h b/include/bootflow.h index f407bb356b4..e09cff285e4 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -613,4 +613,19 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg); * Return: Image name, or "unknown" if not known */ const char *bootflow_img_type_name(enum bootflow_img_t type); + +/** + * bootflow_img_add() - Add a new image to a bootflow + * + * @bflow: Bootflow to add to + * @fname: Image filename (will be allocated) + * @type: Image type + * @addr: Address the image was loaded to, or 0 if not loaded + * @size: Image size + * Return: pointer to the added image, or NULL if out of memory + */ +struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char *fname, + enum bootflow_img_t type, ulong addr, + ulong size); + #endif diff --git a/include/bootmeth.h b/include/bootmeth.h index a08ebf005ad..e812974ec4d 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -7,11 +7,11 @@ #ifndef __bootmeth_h #define __bootmeth_h +#include +#include #include struct blk_desc; -struct bootflow; -struct bootflow_iter; struct udevice; /** @@ -365,10 +365,12 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc, * @bflow: Information about file to read * @size_limit: Maximum file size to permit * @align: Allocation alignment (1 for unaligned) + * @type: File type (IH_TYPE_...) * Return: 0 if OK, -E2BIG if file is too large, -ENOMEM if out of memory, * other -ve on other error */ -int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align); +int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align, + enum bootflow_img_t type); /** * bootmeth_alloc_other() - Allocate and read a file for a bootflow From patchwork Mon Nov 4 17:50:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006425 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=W3t7+6UH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzZP015Mz1xxN for ; Tue, 5 Nov 2024 04:52:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 21E3088FD2; Mon, 4 Nov 2024 18:51:36 +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="W3t7+6UH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9842D88F33; Mon, 4 Nov 2024 18:51:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 5E4FA8880B for ; Mon, 4 Nov 2024 18:51:31 +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-xd31.google.com with SMTP id ca18e2360f4ac-83ac817aac3so175802439f.0 for ; Mon, 04 Nov 2024 09:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742689; x=1731347489; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WGanZBy9M3edqDmcU0oo6ewTIBOftdhFZB6GvMov7qE=; b=W3t7+6UHoo9ovLitZR3iYsxa4eiDdjeQI6oNnUdmnwRSBOEVrWYh4ETtMxDGvOiOII BhIeV7gxb5LvL9D2Rqbx2sfvDUChdno3F4+a/+9qX7F8bUAlQHSOEB6A4uUmn+0dVQ4L A2TOeIXKT35fO7zhlBRcf/vmrdBcLiv3mh3YA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742689; x=1731347489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WGanZBy9M3edqDmcU0oo6ewTIBOftdhFZB6GvMov7qE=; b=MGioWYZSMbxDOicqbymcb694bjaI/5oYRMizpcGT/5CQa8JrfmZC3pD+9bt4IvT1Nv 5QV1/H6CDqFy/9TApnwrgrrCvQo/lqwstmRgHYFnsGJyOGIAZs5r3sG/Zk9qMKplA8eu s6ZsaX3z3ODuJz8Sv4IG8OSSE8x7sQpCvbdLirGLkdUOKI52rQjJsGgOeVI7bekWeUcO iFVMe3O+NcRga1UBv8aPTPkW9faQxrVLcfuXz/1JNu9MB50nnyB5AEDt1ZcQIA/AMH3W 39Pqb5tFcmaGoEKQ1FMA4G9bYphobZBS5vLkAUAl6bpQhqj3yuyFTC6Y7s1S9pyPWwEt p+bw== X-Gm-Message-State: AOJu0YwDGCd2BZv0ASIeCZQNHxY2cwLadfDHZWKSDTrtMmSikUyBC81d HpzAPztDB4xxnuH9VmTOFyO7nzLA2xVD4Phy9efIPbwCh1ItBczzxaaRMFjRYghBUevFEPBdVX8 = X-Google-Smtp-Source: AGHT+IF59vhDAjwI9DbUgQu2tmuG58AiVrurLVwYboJi7rNFqfR/yvoc258JVi41Z2ncvp59eAKQgA== X-Received: by 2002:a05:6602:1592:b0:83a:b7a2:74e6 with SMTP id ca18e2360f4ac-83b56605610mr2610056139f.0.1730742689523; Mon, 04 Nov 2024 09:51:29 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Martyn Welch , Michael Trimarchi , Michal Simek , Tim Harvey Subject: [PATCH v3 08/19] boot: pxe: Drop the duplicate comment on get_pxe_file() Date: Mon, 4 Nov 2024 10:50:59 -0700 Message-Id: <20241104175110.1048449-9-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean This function is exported, so document it in the header file. Drop the duplicate comment in the C file. Signed-off-by: Simon Glass --- (no changes since v1) boot/pxe_utils.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index d6a4b2cb859..4fd26524286 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -133,16 +133,6 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path, return 1; } -/** - * get_pxe_file() - read a file - * - * The file is read and nul-terminated - * - * @ctx: PXE context - * @file_path: File path to read (relative to the PXE file) - * @file_addr: Address to load file to - * Returns 1 for success, or < 0 on error - */ int get_pxe_file(struct pxe_context *ctx, const char *file_path, ulong file_addr) { From patchwork Mon Nov 4 17:51:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006426 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MQzME04h; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzZY6xQfz1xxN for ; Tue, 5 Nov 2024 04:52:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7633E88F77; Mon, 4 Nov 2024 18:51:37 +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="MQzME04h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B74F089000; Mon, 4 Nov 2024 18:51:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 6D25888F33 for ; Mon, 4 Nov 2024 18:51:34 +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-xd36.google.com with SMTP id ca18e2360f4ac-83a9be2c028so160070239f.1 for ; Mon, 04 Nov 2024 09:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742692; x=1731347492; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EKhIcjVMfXAKRslJ66d+YfkbNUBgL5LHMgvcVlGlgf0=; b=MQzME04h9QvJe5IRAKcHcKRqIkRWnCjDvtIJiTD4V2mw3rPIMmcyLZoVJdXHsdXV0D p9QbsL8Bzz48xefuh9bXKeBdt/NfVLJlvjfF4daoLYL9Hf1gQROaTnodU1FJQ85Uaw42 1hcu9b7Js9d28P797TkISBqjvqwfMNvown7EE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742692; x=1731347492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EKhIcjVMfXAKRslJ66d+YfkbNUBgL5LHMgvcVlGlgf0=; b=ntSti0Ijxfrel8rpx8ISxjUIxy3NLgaolr7q6aoMASMe8S5GEnGEK/bI0VTg1E0ca7 yotRAKjJXyRgSXsFozWV6xRnH28sCWxxjFw9thLIthluBFtSE1/XVwYgg+t2AlM3GnJd 6sMsqc+JK2JwxUl9L0BL5/3TfnrLGx3r5jkeuy0Iz76bn3qEOZAEEL1WIh2/4ARc1JFE 05TLz12SuL3Nda8QLs31DhwxBcZ6T8kCtJQmTWhhePaRn9Aw1IPN8yn5Xzzj1CPdiedp 9f8KvEBMtomOWdGI6zu65mZOxKIrxNs2pS43ntaq4ZkQwUrFkcmVb87I+1sJNbIqB4D5 c8kQ== X-Gm-Message-State: AOJu0Yxeb3z7iooWMOkHgZ2pLm4zFIRsbWmY5tYmWQMm+SQ0SVOGDDMP dziCxG4XAMlTxdGoxBnTcInMnWdidclya1nCvjkCn6Tm9kL3jB4WWrcTR3ZSJo8HpisnIQMzir4 = X-Google-Smtp-Source: AGHT+IELumE7nPN8PkNnb8+Uv7AZzKPqoZM3Yeo1Hbs3B5w2m27r+qYNjYnNoe1FUB/2I2oClIkcSg== X-Received: by 2002:a05:6602:1508:b0:83a:b33a:5e08 with SMTP id ca18e2360f4ac-83b719f3db1mr1246475739f.10.1730742691165; Mon, 04 Nov 2024 09:51:31 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Ilias Apalodimas , AKASHI Takahiro , Heinrich Schuchardt , Mattijs Korpershoek , Shantur Rathore Subject: [PATCH v3 09/19] bootmeth_efi: Simplify reading files by using the common function Date: Mon, 4 Nov 2024 10:51:00 -0700 Message-Id: <20241104175110.1048449-10-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean The efiload_read_file() does similar things to a common function, so update it to use that instead. Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas --- (no changes since v2) Changes in v2: - Change the tag to bootmeth_efi boot/bootmeth_efi.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 2ad6d3b4ace..f3ddbe71405 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -110,19 +110,14 @@ static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow) static int efiload_read_file(struct bootflow *bflow, ulong addr) { struct blk_desc *desc = NULL; - loff_t bytes_read; + ulong size; int ret; if (bflow->blk) desc = dev_get_uclass_plat(bflow->blk); - ret = bootmeth_setup_fs(bflow, desc); - if (ret) - return log_msg_ret("set", ret); - ret = fs_read(bflow->fname, addr, 0, bflow->size, &bytes_read); - if (ret) - return log_msg_ret("read", ret); - bflow->buf = map_sysmem(addr, bflow->size); + ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname, + addr, &size); set_efi_bootdev(desc, bflow); From patchwork Mon Nov 4 17:51:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006428 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LDHJceL0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzZv0nX0z1xxN for ; Tue, 5 Nov 2024 04:52:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 404A588FB3; Mon, 4 Nov 2024 18:51:40 +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="LDHJceL0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7FCB188618; Mon, 4 Nov 2024 18:51:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 0251388FAA for ; Mon, 4 Nov 2024 18:51:35 +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-il1-x131.google.com with SMTP id e9e14a558f8ab-3a4e5e57678so17947895ab.1 for ; Mon, 04 Nov 2024 09:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742693; x=1731347493; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QhptQMeRbOWCdd2iETvVZAUJWqfWaZFl1UmisVnlWUQ=; b=LDHJceL0MKx76zqHaf0bH8iHiNbRWPmTXlIN7irDH9DXWShiDfiMb2+eifNIXK/A8y fKS+/ugnE+sq3yTPG95LcZJs+HrTeFA1+DwP6oehU7zlMN8BXCMVPRJz2z3JcE/VjE9c Fr+hS2rExW3VFMz0PRshfkT+nj/dzMFSloSz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742693; x=1731347493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QhptQMeRbOWCdd2iETvVZAUJWqfWaZFl1UmisVnlWUQ=; b=Ul3zCvhqjyN782t0Ih6vrii/YveZKKUkNRQi41uN79zgjLhEu6nEpnHpywqhaeqiMI 1a+bRWermnBl/9wUmwMdKU9LwnlLOnNrBuOuOfVfpQwo6twEzijZtxJbMdMmqRbheGer zU3EuzWePKjiPjsmhi54v+1xW9DxpovhJZkNZawpgEfsVXg6hPY+rEzM56cUBhqavtGA b544+ZS4cdwPZNAgbiDcdj6HL5GpJu2RZTGuAVpTMPETkOMDkcjZuYsXNM9fwaV82ZTP RT7lSNX8o2f9gzcODZcbolPHmRpI7qDps7k9gBAYPp8AT3Gfy4xxleijIquedQuT7Mk/ s8WA== X-Gm-Message-State: AOJu0YzesV/aMdsu3peA3MyKpsUd5YR3hl6wvnbrUgI+136MUG/FsFb2 QwhdNWPZzmAKvhWUkFDxV8Q0QQCwcShmlMXfmidxYNW8VfqN233mnonTR6BvYlh0JW7SMU8Hgo8 = X-Google-Smtp-Source: AGHT+IE2ScLPup+TU43juyELcmJYWucquR8VODC6MPSuT1HcnHVhwWj1wb9zpD2W+1x/BdaSiH+aiQ== X-Received: by 2002:a92:c08c:0:b0:3a6:ac4e:4d with SMTP id e9e14a558f8ab-3a6afeef2c1mr108181755ab.7.1730742692875; Mon, 04 Nov 2024 09:51:32 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Guillaume La Roque , Heinrich Schuchardt , Ilias Apalodimas , Ion Agorria , Julien Masson , Mark Kettenis , Martyn Welch , Quentin Schulz , Shantur Rathore , =?utf-8?q?Vincent_Stehl=C3=A9?= Subject: [PATCH v3 10/19] bootmeth: Update the read_file() method to include a type Date: Mon, 4 Nov 2024 10:51:01 -0700 Message-Id: <20241104175110.1048449-11-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean We want to record the type of each file which is loaded. Add an new parameter for this, to the read_file() method. Update all users. Make bootmeth_common_read_file() store information about the image that is read. Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek --- Changes in v3: - Use the helper function Changes in v2: - Update to use a new image-type enum in bootflow.h boot/bootmeth-uclass.c | 11 ++++++++--- boot/bootmeth_android.c | 3 ++- boot/bootmeth_cros.c | 3 ++- boot/bootmeth_efi.c | 5 +++-- boot/bootmeth_efi_mgr.c | 3 ++- boot/bootmeth_extlinux.c | 2 +- boot/bootmeth_pxe.c | 6 +++--- boot/bootmeth_qfw.c | 3 ++- boot/bootmeth_sandbox.c | 3 ++- boot/vbe_simple.c | 5 +++-- include/bootmeth.h | 13 +++++++++---- 11 files changed, 37 insertions(+), 20 deletions(-) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index c219631816f..1f48d0c1f51 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -84,14 +84,15 @@ int bootmeth_boot(struct udevice *dev, struct bootflow *bflow) } int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { const struct bootmeth_ops *ops = bootmeth_get_ops(dev); if (!ops->read_file) return -ENOSYS; - return ops->read_file(dev, bflow, file_path, addr, sizep); + return ops->read_file(dev, bflow, file_path, addr, type, sizep); } int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow) @@ -394,7 +395,8 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname, } int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { struct blk_desc *desc = NULL; loff_t len_read; @@ -423,6 +425,9 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, return ret; *sizep = len_read; + if (!bootflow_img_add(bflow, bflow->fname, type, addr, size)) + return log_msg_ret("bci", -ENOMEM); + return 0; } diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c index 19b1f2c377b..bd6c05ab8f9 100644 --- a/boot/bootmeth_android.c +++ b/boot/bootmeth_android.c @@ -298,7 +298,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow) } static int android_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { /* * Reading individual files is not supported since we only diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index 676f550ca25..1825293d93d 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -400,7 +400,8 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow) } static int cros_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { return -ENOSYS; } diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index f3ddbe71405..e8109e19bcb 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -117,7 +117,7 @@ static int efiload_read_file(struct bootflow *bflow, ulong addr) desc = dev_get_uclass_plat(bflow->blk); ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname, - addr, &size); + addr, BFI_EFI, &size); set_efi_bootdev(desc, bflow); @@ -189,7 +189,8 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, /* Limit FDT files to 4MB */ size = SZ_4M; ret = bootmeth_common_read_file(dev, bflow, fname, - fdt_addr, &size); + fdt_addr, (enum bootflow_img_t)IH_TYPE_FLATDT, + &size); } } diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index 23ae1e610ac..42b8863815e 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -74,7 +74,8 @@ static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow) } static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { /* Files are loaded by the 'bootefi bootmgr' command */ diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 6c158c2a6c6..ae5ae4dbb34 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -79,7 +79,7 @@ static int extlinux_getfile(struct pxe_context *ctx, const char *file_path, /* Allow up to 1GB */ *sizep = 1 << 30; ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, - sizep); + (enum bootflow_img_t)IH_TYPE_INVALID, sizep); if (ret) return log_msg_ret("read", ret); diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 05c6bece2c1..e64429f6857 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -23,7 +23,7 @@ #include static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, - char *file_addr, ulong *sizep) + char *file_addr, ulong *sizep) { struct extlinux_info *info = ctx->userdata; ulong addr; @@ -34,7 +34,7 @@ static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, /* Allow up to 1GB */ *sizep = 1 << 30; ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, - sizep); + IH_TYPE_INVALID, sizep); if (ret) return log_msg_ret("read", ret); @@ -113,7 +113,7 @@ static int extlinux_pxe_read_bootflow(struct udevice *dev, static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong addr, - ulong *sizep) + enum bootflow_img_t type, ulong *sizep) { char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; struct pxe_context *ctx = dev_get_priv(dev); diff --git a/boot/bootmeth_qfw.c b/boot/bootmeth_qfw.c index 2f8e00cf350..028c2481583 100644 --- a/boot/bootmeth_qfw.c +++ b/boot/bootmeth_qfw.c @@ -52,7 +52,8 @@ static int qfw_read_bootflow(struct udevice *dev, struct bootflow *bflow) } static int qfw_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { return -ENOSYS; } diff --git a/boot/bootmeth_sandbox.c b/boot/bootmeth_sandbox.c index 26c713bb5f3..92ba2e3f050 100644 --- a/boot/bootmeth_sandbox.c +++ b/boot/bootmeth_sandbox.c @@ -27,7 +27,8 @@ static int sandbox_read_bootflow(struct udevice *dev, struct bootflow *bflow) } static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { return -ENOSYS; } diff --git a/boot/vbe_simple.c b/boot/vbe_simple.c index 189e86d2a22..ed7b9598e38 100644 --- a/boot/vbe_simple.c +++ b/boot/vbe_simple.c @@ -160,13 +160,14 @@ static int vbe_simple_read_bootflow(struct udevice *dev, struct bootflow *bflow) } static int vbe_simple_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep) + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep) { int ret; if (vbe_phase() == VBE_PHASE_OS) { ret = bootmeth_common_read_file(dev, bflow, file_path, addr, - sizep); + type, sizep); if (ret) return log_msg_ret("os", ret); } diff --git a/include/bootmeth.h b/include/bootmeth.h index e812974ec4d..788d4046ce9 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -8,7 +8,6 @@ #define __bootmeth_h #include -#include #include struct blk_desc; @@ -117,13 +116,15 @@ struct bootmeth_ops { * @bflow: Bootflow providing info on where to read from * @file_path: Path to file (may be absolute or relative) * @addr: Address to load file + * @type: File type (IH_TYPE_...) * @sizep: On entry provides the maximum permitted size; on exit * returns the size of the file * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other * -ve value if something else goes wrong */ int (*read_file)(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep); + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep); #if CONFIG_IS_ENABLED(BOOTSTD_FULL) /** * readall() - read all files for a bootflow @@ -245,13 +246,15 @@ int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow, * @bflow: Bootflow providing info on where to read from * @file_path: Path to file (may be absolute or relative) * @addr: Address to load file + * @type: File type (IH_TYPE_...) * @sizep: On entry provides the maximum permitted size; on exit * returns the size of the file * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other * -ve value if something else goes wrong */ int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep); + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep); /** * bootmeth_read_all() - read all bootflow files @@ -397,11 +400,13 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname, * @bflow: Bootflow information * @file_path: Path to file * @addr: Address to load file to + * @type: File type (IH_TYPE_...) * @sizep: On entry, the maximum file size to accept, on exit the actual file * size read */ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, - const char *file_path, ulong addr, ulong *sizep); + const char *file_path, ulong addr, + enum bootflow_img_t type, ulong *sizep); /** * bootmeth_get_bootflow() - Get a bootflow from a global bootmeth From patchwork Mon Nov 4 17:51:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006427 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nPOxt8P0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzZk28TGz1xxN for ; Tue, 5 Nov 2024 04:52:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D44A088F33; Mon, 4 Nov 2024 18:51:39 +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="nPOxt8P0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A15AE8903C; Mon, 4 Nov 2024 18:51:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 662E488FE2 for ; Mon, 4 Nov 2024 18:51:36 +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 ca18e2360f4ac-83aad99d6bfso167134739f.0 for ; Mon, 04 Nov 2024 09:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742694; x=1731347494; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hEvs6FGRXWaE0NLebtPoX/3Qd3/ApUU6TfD58J701R4=; b=nPOxt8P01JvcAUuuCp4I31duosSBHwrLgoS/sCkTdCApStDAFDUWDg4snoEgw6dcJn 1SCSsYLNK9u7Dvjrt1VoRAA47hS+7WgS9PAVMvNsVEMxpn8+KRWJNeMs4qvIcmI/QgI3 EOevXAflRpNB0fVs9hsx9W0t8cJ/sHdK0h8a8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742694; x=1731347494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hEvs6FGRXWaE0NLebtPoX/3Qd3/ApUU6TfD58J701R4=; b=QIAupeiMuexw65vyfgfI0ev5no8JrWZ7fNIxjC5fdU6oSpZJGmTNMibg8Qt0MEk7Z5 bOODKCcOWVeZP8iDsd/tnzZhWarJ3pZ/2YsobZodDJRq50fJ2BFDNX+luP4Qay5dJnlZ hlSlKMbjlfVnCK5YB2KLOpaKIhH6/qUOGSn0y5cQwEKrmvBBMl9Z9EpZcmLMGrHNboT2 i2oNz/yXSQwwf9EJr8xZpLQEzT0qmt65J/H7BDohKeSAuylc+tl/bt/4H9EUNZlnIwOz /dcNERUKSXXIypE1JvGJhrbThx/yXy3EBK4Ngwxo6HBJ+IOUY9vfbEHrNEXupMAPESnq ofWw== X-Gm-Message-State: AOJu0Yy/Z+sw8foA1+7RBuzfspToDnB7ZmSyWFl/vD9rPfg0pC5cPCuI 3wHJS+0y8Twd8VFiQy/6gx/y57Q1mlTie0E1jyb7Te5JHs9GQRn14w9/Sqc6A9jJA0dw46y/kts = X-Google-Smtp-Source: AGHT+IEDF6HypJzKCbucmBWBwYzztyVvMdGjaFW21rLaT1LK3Habr01YUOZUet2A9Z2aVOPPysL9Sw== X-Received: by 2002:a05:6602:164f:b0:83a:9488:154c with SMTP id ca18e2360f4ac-83b64f3b524mr1682812339f.3.1730742694618; Mon, 04 Nov 2024 09:51:34 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Heinrich Schuchardt , Ilias Apalodimas , Mattijs Korpershoek , Shantur Rathore Subject: [PATCH v3 11/19] bootmeth_efi: Check the filename-allocation in the network path Date: Mon, 4 Nov 2024 10:51:02 -0700 Message-Id: <20241104175110.1048449-12-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean If the filename cannot be set we should give up. Add the missing error check. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Change the tag to bootmeth_efi boot/bootmeth_efi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index e8109e19bcb..1ff8788ebeb 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -269,6 +269,8 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) if (!bootfile_name) return log_msg_ret("bootfile_name", ret); bflow->fname = strdup(bootfile_name); + if (!bflow->fname) + return log_msg_ret("fi0", -ENOMEM); /* do the hideous EFI hack */ efi_set_bootdev("Net", "", bflow->fname, map_sysmem(addr, 0), From patchwork Mon Nov 4 17:51:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006429 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Qff/gxhF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xhzb44Ptmz1xxN for ; Tue, 5 Nov 2024 04:53:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9CAB08900E; Mon, 4 Nov 2024 18:51:41 +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="Qff/gxhF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B891788FE2; Mon, 4 Nov 2024 18:51:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 1478289025 for ; Mon, 4 Nov 2024 18:51:38 +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 ca18e2360f4ac-83ab00438acso135581839f.0 for ; Mon, 04 Nov 2024 09:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742696; x=1731347496; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oZH6FPz84MKIRwsM7KYkgPti6UFn5FOGrNJcsQaNEoM=; b=Qff/gxhFW1+tWFuob3YK8SbJSnLZUG/GsckkSDVKykKlbjCCesXLTC0dN4pTqYJ6yy OssfAIcGqyODmJTPY1yLWdqYWfl8yGKRKQp9J0EgenSXF9DwKfgcbiTx2xqAhyCJ/oyP O22k5zk5EMFMo9cwdtC+5ZuZlcw448okCJahg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742696; x=1731347496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oZH6FPz84MKIRwsM7KYkgPti6UFn5FOGrNJcsQaNEoM=; b=KAFCwf671xjZlD240ZAOSP4pgYTfiWYtzRpZJPAaYihGRZ3r8P7HJXnWpnku6DNBZh 7faOVcePHVDaAncnQYulOmpCjYCLK85wu1Ktzm6+H11miuhMop0vcuXZyHywSLj3HIYH oJ0NEiiH7QDUxhKJzYaHymFhhhhXsH9IVTY88m47M4SG30VkU8eA4j6NTMtxPMxc9q53 qykOp1AF0Bwv9mfZsXDPPCHYglTEWL5BojRhVQ5TyMroaK8FHEZtEgWrw8PSU0wtD2R5 faAWNXm/kDbO3jhE615wSsGwSNjL7I+9icLeSM4yFm1uHjUPDFhewY84oqVy45AsRBwJ E3Qw== X-Gm-Message-State: AOJu0YyI+esrmDSJXShWAvnrW4EBhQCnj4v4iGXvAyn3sogGS9a3xNzs 7o1TScvGMIv0TUoKKPiTgMl4lt632qRbtaib3NwEAmP99z1ChRzNXbdYtB1IAp23i8euMdruMzI = X-Google-Smtp-Source: AGHT+IEmWXCwF1+yUa6nheKb4nmbrGmQYDGEPYnY5N9Bm0NzAQ9JQ1V5VSgSYcKK0jhwo+D/Cn9M9g== X-Received: by 2002:a6b:7e44:0:b0:805:2048:a492 with SMTP id ca18e2360f4ac-83b7133cf86mr1024444039f.6.1730742696180; Mon, 04 Nov 2024 09:51:36 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Heinrich Schuchardt , Ilias Apalodimas , Ion Agorria , Marek Vasut , Martyn Welch , Mattijs Korpershoek , Michael Trimarchi , Sean Edmond , Svyatoslav Ryhel , Tim Harvey Subject: [PATCH v3 12/19] boot: Update extlinux pxe_getfile_func() to include type Date: Mon, 4 Nov 2024 10:51:03 -0700 Message-Id: <20241104175110.1048449-13-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Add a file-type parameter to this function and update all users. Add a proper comment to the function which we are here. This will allow tracking of the file types loaded by the extlinux bootmeth. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Update to use a new image-type enum in bootflow.h boot/bootmeth_extlinux.c | 5 +++-- boot/bootmeth_pxe.c | 5 +++-- boot/pxe_utils.c | 26 ++++++++++++++++++-------- cmd/pxe.c | 2 +- cmd/sysboot.c | 6 ++++-- include/pxe_utils.h | 14 +++++++++++++- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index ae5ae4dbb34..63cb9a4a8af 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -68,7 +68,8 @@ static int extlinux_get_state_desc(struct udevice *dev, char *buf, int maxsize) } static int extlinux_getfile(struct pxe_context *ctx, const char *file_path, - char *file_addr, ulong *sizep) + char *file_addr, enum bootflow_img_t type, + ulong *sizep) { struct extlinux_info *info = ctx->userdata; ulong addr; @@ -79,7 +80,7 @@ static int extlinux_getfile(struct pxe_context *ctx, const char *file_path, /* Allow up to 1GB */ *sizep = 1 << 30; ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, - (enum bootflow_img_t)IH_TYPE_INVALID, sizep); + type, sizep); if (ret) return log_msg_ret("read", ret); diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index e64429f6857..b2873075ba5 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -23,7 +23,8 @@ #include static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, - char *file_addr, ulong *sizep) + char *file_addr, enum bootflow_img_t type, + ulong *sizep) { struct extlinux_info *info = ctx->userdata; ulong addr; @@ -34,7 +35,7 @@ static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, /* Allow up to 1GB */ *sizep = 1 << 30; ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, - IH_TYPE_INVALID, sizep); + type, sizep); if (ret) return log_msg_ret("read", ret); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 4fd26524286..03d0ab8c578 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -6,6 +6,7 @@ #define LOG_CATEGORY LOGC_BOOT +#include #include #include #include @@ -97,7 +98,8 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len) * Returns 1 for success, or < 0 on error */ static int get_relfile(struct pxe_context *ctx, const char *file_path, - unsigned long file_addr, ulong *filesizep) + unsigned long file_addr, enum bootflow_img_t type, + ulong *filesizep) { size_t path_len; char relfile[MAX_TFTP_PATH_LEN + 1]; @@ -124,7 +126,7 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path, sprintf(addr_buf, "%lx", file_addr); - ret = ctx->getfile(ctx, relfile, addr_buf, &size); + ret = ctx->getfile(ctx, relfile, addr_buf, type, &size); if (ret < 0) return log_msg_ret("get", ret); if (filesizep) @@ -140,7 +142,8 @@ int get_pxe_file(struct pxe_context *ctx, const char *file_path, int err; char *buf; - err = get_relfile(ctx, file_path, file_addr, &size); + err = get_relfile(ctx, file_path, file_addr, BFI_EXTLINUX_CFG, + &size); if (err < 0) return err; @@ -189,13 +192,15 @@ int get_pxelinux_path(struct pxe_context *ctx, const char *file, * @file_path: File path to read (relative to the PXE file) * @envaddr_name: Name of environment variable which contains the address to * load to + * @type: File type * @filesizep: Returns the file size in bytes * Returns 1 on success, -ENOENT if @envaddr_name does not exist as an * environment variable, -EINVAL if its format is not valid hex, or other * value < 0 on other error */ static int get_relfile_envaddr(struct pxe_context *ctx, const char *file_path, - const char *envaddr_name, ulong *filesizep) + const char *envaddr_name, + enum bootflow_img_t type, ulong *filesizep) { unsigned long file_addr; char *envaddr; @@ -207,7 +212,7 @@ static int get_relfile_envaddr(struct pxe_context *ctx, const char *file_path, if (strict_strtoul(envaddr, 16, &file_addr) < 0) return -EINVAL; - return get_relfile(ctx, file_path, file_addr, filesizep); + return get_relfile(ctx, file_path, file_addr, type, filesizep); } /** @@ -395,6 +400,7 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, /* Load overlay file */ err = get_relfile_envaddr(ctx, overlayfile, "fdtoverlay_addr_r", + (enum bootflow_img_t)IH_TYPE_FLATDT, NULL); if (err < 0) { printf("Failed loading overlay %s\n", overlayfile); @@ -480,7 +486,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", - NULL) < 0) { + (enum bootflow_img_t)IH_TYPE_KERNEL, NULL) + < 0) { printf("Skipping %s for failure retrieving kernel\n", label->name); return 1; @@ -506,6 +513,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } else if (label->initrd) { ulong size; if (get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", + (enum bootflow_img_t)IH_TYPE_RAMDISK, &size) < 0) { printf("Skipping %s for failure retrieving initrd\n", label->name); @@ -651,7 +659,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (fdtfile) { int err = get_relfile_envaddr(ctx, fdtfile, - "fdt_addr_r", NULL); + "fdt_addr_r", + (enum bootflow_img_t)IH_TYPE_FLATDT, NULL); free(fdtfilefree); if (err < 0) { @@ -1538,7 +1547,8 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) if (IS_ENABLED(CONFIG_CMD_BMP)) { /* display BMP if available */ if (cfg->bmp) { - if (get_relfile(ctx, cfg->bmp, image_load_addr, NULL)) { + if (get_relfile(ctx, cfg->bmp, image_load_addr, + BFI_LOGO, NULL)) { #if defined(CONFIG_VIDEO) struct udevice *dev; diff --git a/cmd/pxe.c b/cmd/pxe.c index 982e2b1e7ea..37b8dea6ad6 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -27,7 +27,7 @@ const char *pxe_default_paths[] = { }; static int do_get_tftp(struct pxe_context *ctx, const char *file_path, - char *file_addr, ulong *sizep) + char *file_addr, enum bootflow_img_t type, ulong *sizep) { char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; int ret; diff --git a/cmd/sysboot.c b/cmd/sysboot.c index 8a060780cab..93d4a400830 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -23,7 +23,8 @@ struct sysboot_info { }; static int sysboot_read_file(struct pxe_context *ctx, const char *file_path, - char *file_addr, ulong *sizep) + char *file_addr, enum bootflow_img_t type, + ulong *sizep) { struct sysboot_info *info = ctx->userdata; loff_t len_read; @@ -110,7 +111,8 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - if (get_pxe_file(&ctx, filename, pxefile_addr_r) < 0) { + if (get_pxe_file(&ctx, filename, pxefile_addr_r) + < 0) { printf("Error reading config file\n"); pxe_destroy_ctx(&ctx); return 1; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 68ac40b64ad..0378f2889f7 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -3,6 +3,7 @@ #ifndef __PXE_UTILS_H #define __PXE_UTILS_H +#include #include /* @@ -82,8 +83,19 @@ struct pxe_menu { }; struct pxe_context; + +/** + * Read a file + * + * @ctx: PXE context + * @file_path: Full path to filename to read + * @file_addr: String containing the to which to read the file + * @type: File type + * @fileszeip: Returns file size + */ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, - char *file_addr, ulong *filesizep); + char *file_addr, enum bootflow_img_t type, + ulong *filesizep); /** * struct pxe_context - context information for PXE parsing From patchwork Mon Nov 4 17:51:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006430 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=L9vSw0mw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzbF6nkQz1xxN for ; Tue, 5 Nov 2024 04:53:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF74989099; Mon, 4 Nov 2024 18:51:44 +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="L9vSw0mw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E631D8903C; Mon, 4 Nov 2024 18:51:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 D0D9188F68 for ; Mon, 4 Nov 2024 18:51:39 +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-xd29.google.com with SMTP id ca18e2360f4ac-83ac817aac3so175807739f.0 for ; Mon, 04 Nov 2024 09:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742698; x=1731347498; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XcqduuKLurrEY0pxUHsLkciBeSyZkcn4X60OLfcBICc=; b=L9vSw0mwVjuctKsnJQzjRmCL1aG0vm8dDXXTh+APIEttPd9lfdKPwB/rm9CFSuKbGW G2l6/T8XYakzEV9E3c3AFDglXLApKONeP4tUqm9QJ1izJUbqBY73/KiTSZNjjEPqXrWP RFpZVfgR8dhQct8HG2NMZTwe5Za/77yLNCZjE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742698; x=1731347498; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XcqduuKLurrEY0pxUHsLkciBeSyZkcn4X60OLfcBICc=; b=ZjJ+PhTw92CP7IvdBKUevLPBGsvHuw3B1VAoY/n23CJCwt6NyydDar62SI+3nNGd39 BjxboLJDwcrE9LkjkeSkCT/cAew9P9Ier1YLTzgfGOagdALfhtUObn/1Misr2K/0styF dKI68qffi0fzwfb61F6HfRC0vcenCEUbDjVAQRNAtLqWPHTIDiEYiVC9sccdz6Y6f1cn HFx1rfS4j89rKr1abCN1FW7RSzfAKT/QbdmlcJZx6G2x08ASO6S7PxT+W8t1FyhomWTE JDJutumG6F3Db3/mmeP3ySv1MYb8u65oBbLhKFSU/oaxbUeWVlnmPu7BVDyR2klArLfw ZlEA== X-Gm-Message-State: AOJu0Yy2gc2kIBd9CQYPbPUXtkvav47SXxfMBBUp4bcqItmtOh2vs9fj XHL1zLoPwaCpiWRfqg7FAcNmKNM1tzyXt+qh2abE3onlBKgHaEnM/F+gL5IRBvECUxuhzWuuVDc = X-Google-Smtp-Source: AGHT+IFRmJy4LLLwoc9xursZaSSkVSyUDqoS1LqGhHx38CBPjkRpgA5yCMno+nwr6Ja4XhSQvasl3w== X-Received: by 2002:a05:6602:2cc8:b0:83a:f447:f0b9 with SMTP id ca18e2360f4ac-83b56712446mr2351611239f.9.1730742698058; Mon, 04 Nov 2024 09:51:38 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Martyn Welch , Mattijs Korpershoek Subject: [PATCH v3 13/19] boot: Update pxe bootmeth to record images Date: Mon, 4 Nov 2024 10:51:04 -0700 Message-Id: <20241104175110.1048449-14-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Record images loaded by this bootmeth. Signed-off-by: Simon Glass --- Changes in v3: - Use the helper function boot/bootmeth_pxe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index b2873075ba5..b91e61bcbc4 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -135,6 +135,9 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, return log_msg_ret("spc", -ENOSPC); *sizep = size; + if (!bootflow_img_add(bflow, file_path, type, addr, size)) + return log_msg_ret("pxi", -ENOMEM); + return 0; } From patchwork Mon Nov 4 17:51:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006431 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=EiW0nVYX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzbQ0nH5z1xxN for ; Tue, 5 Nov 2024 04:53:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69025890F6; Mon, 4 Nov 2024 18:51:45 +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="EiW0nVYX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F4B988F9F; Mon, 4 Nov 2024 18:51:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 6DFEC88F08 for ; Mon, 4 Nov 2024 18:51:41 +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-xd2a.google.com with SMTP id ca18e2360f4ac-83abcfb9f37so189353939f.1 for ; Mon, 04 Nov 2024 09:51:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742699; x=1731347499; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hndZiooSu6QplpANn6+0x+sY5q7jTfqLXOh98hT/S/o=; b=EiW0nVYXj5Be/UrR/t0bH7hhKl2VlNnaFf3XqqUXhwS9ZH3pSUUfOLt+oT79m5037n N4hIdxg3qXHoGCTmXApRTCH0YrMR/msjV3R+5s8I1fowDVF+F6d1Sxzd9HmclL9hBLI8 3j6tzAwgc6WJElA0oQrXsMMqBArClRbyRMVDo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742699; x=1731347499; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hndZiooSu6QplpANn6+0x+sY5q7jTfqLXOh98hT/S/o=; b=gjxCX3EwsKQ+Tl8hROQaqxdmQrbt9y3HSwQfN5pwJ85tjNUltOox2hsoHPqxXjjA9u EsMNKEmgQTAiuA3TrFtvzHLvxiLjmQ36c3fnUa6vjW1FHHEDe6WRJl95YaykFixhguNA wgYv1HKkJNFpZFj0i9bOGLmmg1AUd17hSb6Oe5DQMARVbT7c2ion/FF67yKOCCzq0XWw Z1haVSI8/JhwR8YLXGhypFaZaGf4gVjpNTJz86kAz7HvMssVjmjP/ua1P+sCdFG2skgY uJ7wYHZusDTM7APYBQZoGv8TNpU9mK++c0hn4ud7PUgXjinGjcTgqsih7tDFKYWyId/S oeOQ== X-Gm-Message-State: AOJu0YzdvnNaYBW3EP2t8HCm96dAsHJX3cbPI0NxpIKbSpYzKP2wqgDT Ox3U7abWXuzypOvkto7gyY3qnyBcOzyAJIlUmw0QU8xwBymd8GUm6qs/F4t2mMBCnidPgzfwfkU = X-Google-Smtp-Source: AGHT+IEHos3AUx3RPMs5qkHrGOSvqgIqCrjeWyfiG5Ool31A3tGI8WtkWx56PcQTNglHh+8CEWvJOQ== X-Received: by 2002:a05:6602:619b:b0:83b:28e2:4985 with SMTP id ca18e2360f4ac-83b28e24d1dmr2774872639f.12.1730742699624; Mon, 04 Nov 2024 09:51:39 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Guillaume La Roque , Heinrich Schuchardt , Martyn Welch , Mattijs Korpershoek , Quentin Schulz Subject: [PATCH v3 14/19] Update bootmeth_alloc_other() to record images Date: Mon, 4 Nov 2024 10:51:05 -0700 Message-Id: <20241104175110.1048449-15-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Update this function to add the image to the list. Signed-off-by: Simon Glass --- Changes in v3: - Use the helper function Changes in v2: - Update to use a new image-type enum in bootflow.h boot/bootmeth-uclass.c | 6 +++++- boot/bootmeth_script.c | 4 ++-- include/bootmeth.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 1f48d0c1f51..014b7588e8d 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -359,7 +359,7 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align, } int bootmeth_alloc_other(struct bootflow *bflow, const char *fname, - void **bufp, uint *sizep) + enum bootflow_img_t type, void **bufp, uint *sizep) { struct blk_desc *desc = NULL; char path[200]; @@ -388,6 +388,10 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname, if (ret) return log_msg_ret("all", ret); + if (!bootflow_img_add(bflow, bflow->fname, type, map_to_sysmem(buf), + size)) + return log_msg_ret("boi", -ENOMEM); + *bufp = buf; *sizep = size; diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c index a2fb2899885..020cb8a7aec 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -107,8 +107,8 @@ static int script_read_bootflow_file(struct udevice *bootstd, if (ret) return log_msg_ret("inf", ret); - ret = bootmeth_alloc_other(bflow, "boot.bmp", &bflow->logo, - &bflow->logo_size); + ret = bootmeth_alloc_other(bflow, "boot.bmp", BFI_LOGO, + &bflow->logo, &bflow->logo_size); /* ignore error */ return 0; diff --git a/include/bootmeth.h b/include/bootmeth.h index 788d4046ce9..26de593a9a4 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -384,12 +384,13 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align, * * @bflow: Information about file to read * @fname: Filename to read from (within bootflow->subdir) + * @type: File type (IH_TYPE_...) * @bufp: Returns a pointer to the allocated buffer * @sizep: Returns the size of the buffer * Return: 0 if OK, -ENOMEM if out of memory, other -ve on other error */ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname, - void **bufp, uint *sizep); + enum bootflow_img_t type, void **bufp, uint *sizep); /** * bootmeth_common_read_file() - Common handler for reading a file From patchwork Mon Nov 4 17:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006432 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JCno89xt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzbZ5zcBz1xxN for ; Tue, 5 Nov 2024 04:53:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D78E689021; Mon, 4 Nov 2024 18:51:46 +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="JCno89xt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 131948909B; Mon, 4 Nov 2024 18:51:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 0189088618 for ; Mon, 4 Nov 2024 18:51: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=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3a6bc0600f9so11414665ab.1 for ; Mon, 04 Nov 2024 09:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742701; x=1731347501; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OfQkbG5KsvvdyESx3IO4+JsNy8FNRKJ8osJbY549D3c=; b=JCno89xtZX2WNvXmV/P11HCfqRS2yobLDmdx9+mBDO29KOEO8NRe4jObjOqNkTnaZg arIfqHU1oGxqUQVgHSzYSQHrjs/5ZnnJFIqcttTBTLTrrx3hzZ57vFCPBzZDnHSGj6W1 mvyhu/kO+0VnIUyVidU91wub2rbHIH50lFbC8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742701; x=1731347501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OfQkbG5KsvvdyESx3IO4+JsNy8FNRKJ8osJbY549D3c=; b=UBcd+eyaYYfcm+03C/oUyicJUB3GPwNYuVKhKDLGM1HgHlXRl+xhjekQQ//2bNTGNy UQAbTpPIkIlKhxZkQ4xwK5dsY1ski+besTS5yC5ZfJvtgXoaTIUWNLKQvur6LNAOM+xr 8wHwktYoPfaJwbCMkATNE6+Jb93pAhtqEU7jNWMsCbmtoa/memQEk6JJ2hdxb6F2+mT3 WfiHppceU66YCUdFxcLdR/bUggqnEisu7Z8qMvdpU1ZrIDWdoC5wLdtUg9kuFuVxAyd8 I6pU+u5OnQIFTRW6WV/TQws4rnHjMSqjrV0HAhe2HSs87cLSl/uSzhD8+m1UwutkQ4i5 itTQ== X-Gm-Message-State: AOJu0YwI25ChwSpIHQocXCkWc2Y+Wo/trQu+5u0pIMH2NitVV3Ae4isP vlVp9aqxwpF+L9UHiBC87V8xnXwpt1Wz54RwYwYO3LsXl6XUnPRAd6fZFhNdC9DrvzPKRZHmONM = X-Google-Smtp-Source: AGHT+IFiHduMDhWJv+DreMXTxCwlV9TPurvx0j1hIS5++Gbh1+3Wp6WgN4UkFacdAHGa/hCk1ES9Ow== X-Received: by 2002:a05:6e02:1383:b0:3a4:e99a:cffc with SMTP id e9e14a558f8ab-3a5e2512f34mr223700865ab.20.1730742701195; Mon, 04 Nov 2024 09:51:41 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Mattijs Korpershoek , =?utf-8?q?Vincent_Stehl?= =?utf-8?q?=C3=A9?= Subject: [PATCH v3 15/19] bootstd: Update cros bootmeth to record images Date: Mon, 4 Nov 2024 10:51:06 -0700 Message-Id: <20241104175110.1048449-16-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Record images loaded by this bootmeth. Signed-off-by: Simon Glass --- Changes in v3: - Use the helper function Changes in v2: - Update to use a new image-type enum in bootflow.h boot/bootmeth_cros.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index 1825293d93d..c7b862e512a 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -243,8 +243,17 @@ static int cros_read_buf(struct bootflow *bflow, void *buf, ulong size, ret = copy_cmdline(map_sysmem(cmdline, 0), uuid, &bflow->cmdline); if (ret) return log_msg_ret("cmd", ret); + + if (!bootflow_img_add(bflow, "setup", + (enum bootflow_img_t)IH_TYPE_X86_SETUP, + setup, 0x3000)) + return log_msg_ret("cri", -ENOMEM); + bflow->x86_setup = map_sysmem(setup, 0); + if (!bootflow_img_add(bflow, "cmdline", BFI_CMDLINE, cmdline, 0x1000)) + return log_msg_ret("crc", -ENOMEM); + return 0; } @@ -306,6 +315,11 @@ static int cros_read_info(struct bootflow *bflow, const char *uuid, } priv->info_buf = buf; + if (!bootflow_img_add(bflow, "kernel", + (enum bootflow_img_t)IH_TYPE_KERNEL, 0, + priv->body_size)) + return log_msg_ret("crk", -ENOMEM); + return 0; } From patchwork Mon Nov 4 17:51:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006433 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GtAmQN0y; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xhzbm3ZnJz1xxN for ; Tue, 5 Nov 2024 04:53:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DE1589066; Mon, 4 Nov 2024 18:51:48 +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="GtAmQN0y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9218688F68; Mon, 4 Nov 2024 18:51:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 C745A89076 for ; Mon, 4 Nov 2024 18:51:44 +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-xd34.google.com with SMTP id ca18e2360f4ac-83ab694ebe5so180491039f.0 for ; Mon, 04 Nov 2024 09:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742703; x=1731347503; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4nZMgQAxnZhIKRc/vEx7lUIp+gBBuPhwvFRvSlXjm7Q=; b=GtAmQN0y73bH4R4QILQYpL4A7rOxpsmkh70u6ML6CAVmh/zCLSF7GpfAnXOXPI5S2g ui0sZ1h9etqPhUl84hr6BUmXXyAWgz+EYOqYqg+onwIfzlDuq4gRBi5Xmx8i8/PYR4dy M4n1/rfxjmzs+rSrhzo3pGxnhQJS5r6qaWJb0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742703; x=1731347503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4nZMgQAxnZhIKRc/vEx7lUIp+gBBuPhwvFRvSlXjm7Q=; b=v+5g64KbfMTNmx8of/nGjeYzYh6+TPWctIfV6B+fA9i+jg611B+Sz/BnM0iiy3PngJ utimVf97l6Cy9tXxvg5YZZK/iv33varj5cang0Z/AxFG8G78005SviwcE9EC9o1xlAL7 aoRXgAxmzxEpB4R/9sZLE5JzZaSpj2HsxpgctlOcPiZGlaJeWylp2cYXe/80+ErXScQx ysVnxLY9TkiVKDc6SbBBWGud056iUOXVw4B0QEDkPoXIRRkABe7C1plw14eC1POfVCkY vL7ke5WA1WBjYmDR6PkDJjBpjcgvlY2lKm8++c7NKK8fAFX0B3/uNPfXEJVMo5aZrTbJ 3HfA== X-Gm-Message-State: AOJu0Yxmn/8giLO6YnoTprynMUrEuntCJPLdFWvs6aLubkoWvXHN2YvG TwByIihGvCp/2e6pzpyNLKbTzqsSxg9ftgfR/v/FfZpCoIzRBI8HB1NhsdmHHAlDvypVZ5Ev0oM = X-Google-Smtp-Source: AGHT+IEsBN8QOOO0y6KMubX7un//92TzilAKkMaHJBuThulZOWHwaBzycmFpFrYdTeKSsqzQbEXHSA== X-Received: by 2002:a05:6602:1686:b0:82a:2a67:9429 with SMTP id ca18e2360f4ac-83b1c3e7abemr3245460339f.5.1730742702826; Mon, 04 Nov 2024 09:51:42 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Emil Kronborg , Etienne Carriere , Francis Laniel , Guillaume La Roque , Heinrich Schuchardt , Hou Zhiqiang , Igor Opaniuk , Ilias Apalodimas , Jerome Forissier , Julien Masson , Martyn Welch , Mattijs Korpershoek , Maxim Moskalets , Maximilian Brune , Nam Cao , Quentin Schulz , Shantur Rathore Subject: [PATCH v3 16/19] bootstd: Add a simple command to list images Date: Mon, 4 Nov 2024 10:51:07 -0700 Message-Id: <20241104175110.1048449-17-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Add a new 'bootstd images' command, which lists the images which have been loaded. Update some existing tests to use it. Provide some documentation about images in general and this command in particular. Use a more realistic kernel command-line to make the test easier to follow. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 12 ++++ cmd/Kconfig | 9 +++ cmd/Makefile | 1 + cmd/bootstd.c | 65 +++++++++++++++++++ doc/develop/bootstd/overview.rst | 21 +++++- doc/usage/cmd/bootstd.rst | 79 +++++++++++++++++++++++ doc/usage/index.rst | 1 + include/bootflow.h | 8 +++ test/boot/bootflow.c | 106 +++++++++++++++++++++++++++++++ test/py/tests/test_ut.py | 3 +- 10 files changed, 303 insertions(+), 2 deletions(-) create mode 100644 cmd/bootstd.c create mode 100644 doc/usage/cmd/bootstd.rst diff --git a/boot/bootflow.c b/boot/bootflow.c index a10d3012b48..58a1afa7a75 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -997,3 +997,15 @@ struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char *fname, return ptr; } + +int bootflow_get_seq(const struct bootflow *bflow) +{ + struct bootstd_priv *std; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return ret; + + return alist_calc_index(&std->bootflows, bflow); +} diff --git a/cmd/Kconfig b/cmd/Kconfig index 636833646f6..6ed83b39b81 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -321,6 +321,15 @@ config CMD_BOOTMETH This command is not necessary for bootstd to work. +config CMD_BOOTSTD + bool "bootstd" + depends on BOOTSTD + default y if BOOTSTD_FULL + help + Provide general information and control for bootstd. + + This command is not necessary for bootstd to work. + config BOOTM_EFI bool "Support booting UEFI FIT images" depends on EFI_BINARY_EXEC && CMD_BOOTM && FIT diff --git a/cmd/Makefile b/cmd/Makefile index d1f369deec0..c0b0ff8b742 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_BLK) += blk_common.o obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o obj-$(CONFIG_CMD_BOOTMETH) += bootmeth.o +obj-$(CONFIG_CMD_BOOTSTD) += bootstd.o obj-$(CONFIG_CMD_SOURCE) += source.o obj-$(CONFIG_CMD_BCB) += bcb.o obj-$(CONFIG_CMD_BDI) += bdinfo.o diff --git a/cmd/bootstd.c b/cmd/bootstd.c new file mode 100644 index 00000000000..e1d82744eb5 --- /dev/null +++ b/cmd/bootstd.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * 'bootstd' command + * + * Copyright 2024 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static int do_bootstd_images(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + const struct bootflow *bflow; + struct bootstd_priv *std; + int ret, i; + + ret = bootstd_get_priv(&std); + if (ret) { + printf("Cannot get bootstd (err=%d)\n", ret); + return CMD_RET_FAILURE; + } + + printf("Seq Bootflow Type At Size Filename\n"); + printf("--- ------------------- -------------- -------- -------- ----------------\n"); + + /* + * Use the ordering if we have one, so long as we are not trying to list + * all bootmethds + */ + i = 0; + alist_for_each(bflow, &std->bootflows) { + const struct bootflow_img *img; + + alist_for_each(img, &bflow->images) { + printf("%3d %-20.20s %-15.15s ", + bootflow_get_seq(bflow), bflow->name, + bootflow_img_type_name(img->type)); + if (img->addr) + printf("%8lx", img->addr); + else + printf("%8s", "-"); + printf(" %8lx %s\n", img->size, img->fname); + i++; + } + } + + printf("--- ------------------- -------------- -------- -------- ----------------\n"); + printf("(%d image%s)\n", i, i != 1 ? "s" : ""); + + return 0; +} + +U_BOOT_LONGHELP(bootstd, + "images - list loaded images"); + +U_BOOT_CMD_WITH_SUBCMDS(bootstd, "Standard-boot operation", bootstd_help_text, + U_BOOT_SUBCMD_MKENT(images, 1, 1, do_bootstd_images)); diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst index a2913cd47be..e3ce97cc4f5 100644 --- a/doc/develop/bootstd/overview.rst +++ b/doc/develop/bootstd/overview.rst @@ -453,7 +453,7 @@ drivers are bound automatically. Command interface ----------------- -Three commands are available: +Four commands are available: `bootdev` Allows listing of available bootdevs, selecting a particular one and @@ -468,6 +468,25 @@ Three commands are available: Allow listing of available bootmethds, setting the order in which they are tried and bootmeth specific configuration. See :doc:`/usage/cmd/bootmeth` +`bootstd` + Allow access to standard boot itself, so far only for listing images across + all bootflows. See :doc:`/usage/cmd/bootstd` + +Images +------ + +Standard boot keeps track of images which can or have been loaded. These are +kept in a list attached to each bootflow. They can be listed using the +``bootstd images`` command (see :doc:`/usage/cmd/bootstd`). + +For now most bootmeths load their images when scanning. Over time, some may +adjust to load them only when needed, but in this case the images will still +be visible. + +Once a bootflow has been selected, images for those that are not selected can +potentially be dropped from the memory map. For now, this is not implemented. + + .. _BootflowStates: Bootflow states diff --git a/doc/usage/cmd/bootstd.rst b/doc/usage/cmd/bootstd.rst new file mode 100644 index 00000000000..7d933852a91 --- /dev/null +++ b/doc/usage/cmd/bootstd.rst @@ -0,0 +1,79 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +.. index:: + single: bootstd (command) + +bootstd command +=============== + +Synopsis +-------- + +:: + + bootstd images + +Description +----------- + +The `bootstd` command is used to manage standard boot. At present the only +functionality available is to look at the images which have been loaded, or +could be loaded should a particular bootflow be selected. + +See :doc:`/develop/bootstd/index` for more information. + +bootflow images +~~~~~~~~~~~~~~~ + +Lists the available images and their location in memory. + +Example +------- + +This shows listing images attached to various bootflows, then checking the +content of a few of them:: + + => bootflow scan + => bootflow list + Showing all bootflows + Seq Method State Uclass Part Name Filename + --- ----------- ------ -------- ---- ------------------------ ---------------- + 0 extlinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf + 1 script ready mmc 1 mmc4.bootdev.part_1 /boot/boot.scr + 2 cros ready mmc 2 mmc5.bootdev.part_2 + 3 cros ready mmc 4 mmc5.bootdev.part_4 + --- ----------- ------ -------- ---- ------------------------ ---------------- + (4 bootflows, 4 valid) + => + => bootstd images + Seq Bootflow Type At Size Filename + --- ------------------- -------------- -------- -------- ---------------- + 0 mmc1.bootdev.part_1 extlinux_cfg 8ed5a70 253 /extlinux/extlinux.conf + 1 mmc4.bootdev.part_1 script 8ed9550 c73 /boot/boot.scr + 1 mmc4.bootdev.part_1 logo 8eda2a0 5d42 boot.bmp + 2 mmc5.bootdev.part_2 x86_setup 8ee84d0 3000 setup + 2 mmc5.bootdev.part_2 cmdline 8ee84d0 1000 cmdline + 2 mmc5.bootdev.part_2 kernel - 4000 kernel + 3 mmc5.bootdev.part_4 x86_setup 8eeb4e0 3000 setup + 3 mmc5.bootdev.part_4 cmdline 8eeb4e0 1000 cmdline + 3 mmc5.bootdev.part_4 kernel - 4000 kernel + --- ------------------- -------------- -------- -------- ---------------- + (9 images) + => md 8eda2a0 10 + 08eda2a0: 5d424d42 00000000 008a0000 007c0000 BMB]..........|. + 08eda2b0: 00ac0000 002e0000 00010000 00000018 ................ + 08eda2c0: 5cb80000 0b130000 0b130000 00000000 ...\............ + 08eda2d0: 00000000 00000000 ff0000ff 00ff0000 ................ + => md 8ee84d0 10 + 08ee84d0: 544f4f42 414d495f 2f3d4547 696c6d76 BOOT_IMAGE=/vmli + 08ee84e0: 2d7a756e 35312e35 312d302e 672d3132 nuz-5.15.0-121-g + 08ee84f0: 72656e65 72206369 3d746f6f 7665642f eneric root=/dev + 08ee8500: 6d766e2f 316e3065 72203170 7571206f /nvme0n1p1 ro qu + +Return value +------------ + +The return value $? is always 0 (true). + + +.. BootflowStates_: diff --git a/doc/usage/index.rst b/doc/usage/index.rst index cb7a23f1170..71970d5f2b3 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -40,6 +40,7 @@ Shell commands cmd/bootm cmd/bootmenu cmd/bootmeth + cmd/bootstd cmd/bootz cmd/button cmd/cat diff --git a/include/bootflow.h b/include/bootflow.h index e09cff285e4..480cf8a5af1 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -627,5 +627,13 @@ const char *bootflow_img_type_name(enum bootflow_img_t type); struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char *fname, enum bootflow_img_t type, ulong addr, ulong size); +/** + * bootflow_get_seq() - Get the sequence number of a bootflow + * + * Bootflows are numbered by their position in the bootstd list. + * + * Return: Sequence number of bootflow (0 = first) + */ +int bootflow_get_seq(const struct bootflow *bflow); #endif diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 2f859c40adb..670b9253f61 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef CONFIG_SANDBOX #include #endif @@ -73,6 +74,14 @@ static int bootflow_cmd(struct unit_test_state *uts) ut_assert_nextline("(1 bootflow, 1 valid)"); ut_assert_console_end(); + ut_assertok(run_command("bootstd images", 0)); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 mmc1.bootdev.part_1 extlinux_cfg"); + ut_assert_nextlinen("---"); + ut_assert_nextline("(1 image)"); + ut_assert_console_end(); + return 0; } BOOTSTD_TEST(bootflow_cmd, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); @@ -1188,6 +1197,19 @@ static int bootflow_cros(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_skip_to_line("(3 bootflows, 3 valid)"); + ut_assertok(run_command("bootstd images", 0)); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 mmc1.bootdev.part_1 extlinux_cfg"); + ut_assert_nextlinen(" 1 mmc5.bootdev.part_2 x86_setup"); + ut_assert_nextlinen(" 1 mmc5.bootdev.part_2 cmdline"); + ut_assert_nextlinen(" 1 mmc5.bootdev.part_2 kernel - 4000 kernel"); + ut_assert_nextlinen(" 2 mmc5.bootdev.part_4 x86_setup"); + ut_assert_nextlinen(" 2 mmc5.bootdev.part_4 cmdline"); + ut_assert_nextlinen(" 2 mmc5.bootdev.part_4 kernel - 4000 kernel"); + ut_assert_nextlinen("---"); + ut_assert_nextline("(7 images)"); + ut_assert_console_end(); return 0; @@ -1216,3 +1238,87 @@ static int bootflow_android(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); + +/* Check 'bootflow scan' provides a list of images */ +static int bootstd_images(struct unit_test_state *uts) +{ + static const char *order[] = {"mmc2", "mmc1", "mmc4", "mmc5", NULL}; + const struct legacy_img_hdr *hdr; + const struct bootflow_img *img; + const struct bootflow *bflow; + struct bootstd_priv *std; + const char **old_order; + struct udevice *dev; + ofnode root, node; + ulong data, len; + char *ptr; + + /* get access to the current bootflow */ + ut_assertok(bootstd_get_priv(&std)); + + ut_assertok(prep_mmc_bootdev(uts, "mmc4", true, &old_order)); + + /* bind mmc5 too, for cros */ + root = oftree_root(oftree_default()); + node = ofnode_find_subnode(root, "mmc5"); + ut_assert(ofnode_valid(node)); + ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false)); + + std->bootdev_order = order; + ut_assertok(run_command("bootflow scan", 0)); + ut_assert_console_end(); + std->bootdev_order = old_order; + + ut_assertok(run_command("bootflow list", 0)); + ut_assert_skip_to_line("(4 bootflows, 4 valid)"); + + ut_assertok(run_command("bootstd images", 0)); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 mmc1.bootdev.part_1 extlinux_cfg"); + ut_assert_nextlinen(" 1 mmc4.bootdev.part_1 script"); + ut_assert_nextlinen(" 1 mmc4.bootdev.part_1 logo"); + ut_assert_nextlinen(" 2 mmc5.bootdev.part_2 x86_setup"); + ut_assert_nextlinen(" 2 mmc5.bootdev.part_2 cmdline"); + ut_assert_nextlinen(" 2 mmc5.bootdev.part_2 kernel -"); + ut_assert_nextlinen(" 3 mmc5.bootdev.part_4 x86_setup"); + ut_assert_nextlinen(" 3 mmc5.bootdev.part_4 cmdline"); + ut_assert_nextlinen(" 3 mmc5.bootdev.part_4 kernel -"); + ut_assert_nextlinen("---"); + ut_assert_nextline("(9 images)"); + + /* check the first image */ + bflow = alist_get(&std->bootflows, 0, struct bootflow); + img = alist_get(&bflow->images, 0, struct bootflow_img); + ut_asserteq_strn("# extlinux.conf", map_sysmem(img->addr, 0)); + + /* check the second image */ + bflow = alist_get(&std->bootflows, 1, struct bootflow); + img = alist_get(&bflow->images, 0, struct bootflow_img); + + /* this is the length of the script in bytes */ + hdr = map_sysmem(img->addr, 0); + image_multi_getimg(hdr, 0, &data, &len); + ptr = (void *)data; + ut_asserteq_strn("# DO NOT EDIT THIS FILE", ptr); + + /* check the ChromiumOS images */ + bflow = alist_get(&std->bootflows, 2, struct bootflow); + img = alist_get(&bflow->images, 1, struct bootflow_img); + ptr = map_sysmem(img->addr, 0); + ut_asserteq_strn("BOOT_IMAGE=/vmlinuz-5.15.0-121-generic root=", ptr); + + /* + * the x86 setup is not a real binary, so just check that it is empty, + * so that if this changes in the future someone will notice and update + * this test + */ + img = alist_get(&bflow->images, 0, struct bootflow_img); + ptr = map_sysmem(img->addr, 0); + ut_asserteq(0, *(ulong *)ptr); + + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootstd_images, UTF_CONSOLE); diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 9166c8f6b6e..0508f933e3b 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -400,9 +400,10 @@ def setup_cros_image(cons): start, size, num, name = line.split(maxsplit=3) parts[int(num)] = Partition(int(start), int(size), name) + # Set up the kernel command-line dummy = os.path.join(cons.config.result_dir, 'dummy.txt') with open(dummy, 'wb') as outf: - outf.write(b'dummy\n') + outf.write(b'BOOT_IMAGE=/vmlinuz-5.15.0-121-generic root=/dev/nvme0n1p1 ro quiet splash vt.handoff=7') # For now we just use dummy kernels. This limits testing to just detecting # a signed kernel. We could add support for the x86 data structures so that From patchwork Mon Nov 4 17:51:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006434 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ShFH833G; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xhzby2Crsz1xxN for ; Tue, 5 Nov 2024 04:53:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 925F188F68; Mon, 4 Nov 2024 18:51:51 +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="ShFH833G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BB4E89078; Mon, 4 Nov 2024 18:51:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 7591788F9F for ; Mon, 4 Nov 2024 18:51:46 +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-xd2b.google.com with SMTP id ca18e2360f4ac-83ac817aac3so175812339f.0 for ; Mon, 04 Nov 2024 09:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742705; x=1731347505; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AH/I0XxzGK7id4U27Iqu4i8aUtBlEM5rJQ2ItONwAmk=; b=ShFH833GQbdcQYQjw/v+pJFvJg3Hxu6Jl1/9e11t7yw46JjTwgEnV1UKOg4wOETwQ3 OWsmSggidUfvhGrvRvVv65oJB7Q0DeDkTzSK4+7PjyWhBGuN5ShCTWPuF2y9K/hSEpwM dZFhW80Xal0EouedTBOtE8xI+MWoQYWNcFCgg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742705; x=1731347505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AH/I0XxzGK7id4U27Iqu4i8aUtBlEM5rJQ2ItONwAmk=; b=WeRa4BZOJTiKgV5XLNcH5/ZCan+APsarlJuXANrsrc+JtWawic7GRBdVU0rbo0/2qV /8uTsEGmSxCe5dM7sEKfMlM1apEQw8ro5v5dgAntxwMh6a/B5bpqwM9Wn3Nl7PqAMsnX rmcCvGyhOZZ/k9c3cW41mVbBRdw1QtJe/0fp9tS+CnCBNLKSEaOpivoHTwhlwCl27dwh bVeLN1yRIkbpEevmBaUglZsXEzOYyMObhTPdC4El6t3rrTXBdxgKa0GPi28gr/dqpK9Q /dmwhfN9sy3roBBFjGPQ0tzzGECHCCaprw/zYDXExWSDa+aqi99oiO58aNfuMMuReh8F COpA== X-Gm-Message-State: AOJu0YyjXf4OGI0MagxAxBSDYTJgHLq1Lu+n0FCQ874t2eXUe25fjw3h rCisUpBWiPt1EkUV7xKd7nTlX1T0JFUH3x9xsJUhMhAQGCYGJonFc+BwTMA6WoZBLUeipLTTXpg = X-Google-Smtp-Source: AGHT+IEK/dPHSUMGZWrc4zYKsa/Zi5ivk9jBDO9s5fADxtuQKPBdAsRs4a+yJfkAquE3EZCgbA+uOQ== X-Received: by 2002:a05:6602:2cc8:b0:83a:f447:f0b9 with SMTP id ca18e2360f4ac-83b56712446mr2351672339f.9.1730742704642; Mon, 04 Nov 2024 09:51:44 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:43 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Dragan Simic , Ilias Apalodimas , Nam Cao , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tony Dinh Subject: [PATCH v3 17/19] bootstd: Export bootdev_get_from_blk() Date: Mon, 4 Nov 2024 10:51:08 -0700 Message-Id: <20241104175110.1048449-18-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Export this function so it can be used from other files. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to export bootdev_get_from_blk() boot/bootdev-uclass.c | 2 +- include/bootdev.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index a4e1d79ec9b..65a3b89e40c 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -319,7 +319,7 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp) return 0; } -static int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp) +int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp) { struct udevice *parent = dev_get_parent(blk); struct udevice *bootdev; diff --git a/include/bootdev.h b/include/bootdev.h index 991b6229c1c..12c90c4ec1b 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -401,6 +401,15 @@ static int bootdev_setup_for_sibling_blk(struct udevice *blk, */ int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp); +/** + * bootdev_get_from_blk() - Get the bootdev given a block device + * + * @blk: Block device to check + * @bootdebp: Returns the bootdev found, if any + * Return 0 if OK, -ve on error + */ +int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp); + /** * bootdev_unbind_dev() - Unbind a bootdev device * From patchwork Mon Nov 4 17:51:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006435 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=cXVRvcoH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xhzc64ly7z1xxN for ; Tue, 5 Nov 2024 04:53:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E19878903C; Mon, 4 Nov 2024 18:51:51 +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="cXVRvcoH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 38ACF88FE2; Mon, 4 Nov 2024 18:51:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 EFCB388F68 for ; Mon, 4 Nov 2024 18:51:47 +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 ca18e2360f4ac-83abcfb9f39so132023339f.1 for ; Mon, 04 Nov 2024 09:51:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742706; x=1731347506; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V11PeAkD3rL0yeXNXSvSXuXEn57Ip5PSRgTBdCG2u88=; b=cXVRvcoHXN55TngccifxspRmLipYbZ7nKUo8obJPpnh9RFrg6BuNnwQeksMKQ875vy 6c7vVAtq/nflkswtvgGMbHMSZvLF9tpRY+56dDdOjWVLA6QdSxtFvtjKnAHZRtWgO6DE Tb4J6ZYrb4E1J7uUeUcGO2LEaY34G3cchwNWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742706; x=1731347506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V11PeAkD3rL0yeXNXSvSXuXEn57Ip5PSRgTBdCG2u88=; b=neVv5fK+RKXn5dZ8eD8N7V3shm9RIkw9+g7FXGPETctw4J3rGViPM24C1X1YjMNg8S ygVinMt5X8YjXLji0WW77GZSjYn7kNxARCMl08AYHv1BF1fKO8jyofB3nqoEBwTfdUca pzkohc3XSSgdglOOQvm0HqGuaU8oz5TCf4pN6BaKXH63KHsHcSnHwlz2lnZxgnYRklAz boQUriCdbEKyWFbCvVbpKRVsRZK85pHOTI+Z63mzBh1ExAwjRK4QdbRPmMwwtts3NPiO eDvBuG02zrdmZq2KOZuJDLgJ2aHkuJtcX83h6ICh4WSUEq+v0lO/CYonWvY+656UGUwP OuaA== X-Gm-Message-State: AOJu0YzZ+HgonoEHepBbp4V2hROcQ8FHJK4V3bCi5kuniudVWesm3UG9 NaCaZ3XKV90QXTtBe+xMKkM84yjk7lFSZGEM7wqShCsn84tRhPq+hUdnW8jFAopRt7PAVi7EVCA = X-Google-Smtp-Source: AGHT+IEpg3NqaSxAaZXfUcIY1rFFtWKJ0Qdxx43jVcMo5NoYza68M32Ww9xmO2IEZWjHtQQOMVgY8Q== X-Received: by 2002:a6b:6f12:0:b0:835:39a8:e201 with SMTP id ca18e2360f4ac-83b71029776mr961692139f.0.1730742706145; Mon, 04 Nov 2024 09:51:46 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Guillaume La Roque , Heinrich Schuchardt , Mattijs Korpershoek , Nam Cao , Peter Robinson , Quentin Schulz , Shantur Rathore Subject: [PATCH v3 18/19] bootstd: Add the concept of an ad-hoc bootflow Date: Mon, 4 Nov 2024 10:51:09 -0700 Message-Id: <20241104175110.1048449-19-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean The normal situation with bootstd is that a bootflow is created from a bootmeth. In some cases, a script or user-command may cause an image to be loaded. To deal with this, add the concept of an ad-hoc bootflow. This can be used to record information about manually loaded images. Signed-off-by: Simon Glass --- Changes in v3: - Add a new patch supporting ad-hoc bootflows boot/bootstd-uclass.c | 44 +++++++++++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 5 +++-- include/bootflow.h | 3 ++- include/bootstd.h | 19 +++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index 8c0fd4e63c3..9bee73ead58 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -7,6 +7,8 @@ */ #include +#include +#include #include #include #include @@ -161,11 +163,53 @@ int bootstd_get_priv(struct bootstd_priv **stdp) return 0; } +int bootstd_img_add(struct blk_desc *desc, int part, const char *fname, + enum bootflow_img_t type, ulong addr, ulong size) +{ + struct udevice *bootdev = NULL; + struct bootstd_priv *std; + struct bootflow *bflow, bflow_s; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return ret; + + if (desc) { + ret = bootdev_get_from_blk(desc->bdev, &bootdev); + if (ret) + return log_msg_ret("iad", ret); + } + + bflow = alist_getw(&std->bootflows, std->adhoc_bflow, struct bootflow); + if (!bflow) { + bflow = &bflow_s; + + bootflow_init(bflow, bootdev, NULL); + bflow->name = strdup("ad-hoc"); + if (!bflow->name) + return log_msg_ret("ian", -ENOMEM); + } + + if (!bootflow_img_add(bflow, fname, type, addr, size)) + return log_msg_ret("iaf", -ENOMEM); + + if (bflow == &bflow_s) { + ret = bootstd_add_bootflow(bflow); + if (ret < 0) + return log_msg_ret("iab", ret); + std->adhoc_bflow = ret; + } + + return 0; +} + static int bootstd_probe(struct udevice *dev) { struct bootstd_priv *std = dev_get_priv(dev); alist_init_struct(&std->bootflows, struct bootflow); + std->adhoc_bflow = -1; return 0; } diff --git a/cmd/bootflow.c b/cmd/bootflow.c index f88995a478f..5668a0c9b19 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -68,7 +68,8 @@ static void report_bootflow_err(struct bootflow *bflow, int err) static void show_bootflow(int index, struct bootflow *bflow, bool errors) { printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, - bflow->method->name, bootflow_state_get_name(bflow->state), + bflow->method ? bflow->method->name : "(none)", + bootflow_state_get_name(bflow->state), bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) : "(none)", bflow->part, bflow->name, bflow->fname ?: ""); if (errors) @@ -388,7 +389,7 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("Name: %s\n", bflow->name); printf("Device: %s\n", bflow->dev->name); printf("Block dev: %s\n", bflow->blk ? bflow->blk->name : "(none)"); - printf("Method: %s\n", bflow->method->name); + printf("Method: %s\n", bflow->method ? bflow->method->name : "(none)"); printf("State: %s\n", bootflow_state_get_name(bflow->state)); printf("Partition: %d\n", bflow->part); printf("Subdir: %s\n", bflow->subdir ? bflow->subdir : "(none)"); diff --git a/include/bootflow.h b/include/bootflow.h index 480cf8a5af1..d9045bc3dae 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -68,7 +68,8 @@ enum bootflow_flags_t { * @fs_type: Filesystem type (FS_TYPE...) if this is fixed by the media, else 0. * For example, the sandbox host-filesystem bootdev sets this to * FS_TYPE_SANDBOX - * @method: Bootmethod device used to perform the boot and read files + * @method: Bootmethod device used to perform the boot and read files; NULL for + * ad-hoc bootflows * @name: Name of bootflow (allocated) * @state: Current state (enum bootflow_state_t) * @subdir: Subdirectory to fetch files from (with trailing /), or NULL if none diff --git a/include/bootstd.h b/include/bootstd.h index 3398e48e88b..c39058c0787 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -10,10 +10,12 @@ #define __bootstd_h #include +#include #include #include #include +struct blk_desc; struct udevice; /** @@ -33,6 +35,7 @@ struct udevice; * @cur_bootflow: Currently selected bootflow (for commands) * @bootflows: (struct bootflow) Global list of all bootflows across all * bootdevs + * @adhoc_bflow: Index of ad-hoc bootflow in bootflows (-1 if none) * @bootmeth_count: Number of bootmeth devices in @bootmeth_order * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none @@ -47,6 +50,7 @@ struct bootstd_priv { struct udevice *cur_bootdev; struct bootflow *cur_bootflow; struct alist bootflows; + int adhoc_bflow; int bootmeth_count; struct udevice **bootmeth_order; struct udevice *vbe_bootmeth; @@ -151,4 +155,19 @@ int bootstd_add_bootflow(struct bootflow *bflow); */ int bootstd_clear_bootflows_for_bootdev(struct udevice *dev); +/** + * bootstd_img_add() - Add an image to the ad-hoc bootflow + * + * @desc: Block descriptor for the device from which the file was loaded, or + * NULL if not a block device + * @part: Partition number within the block device + * @fname: Filename of loaded file + * @type: File type, IH_TYPE_INVALID if not known + * @addr: Address where the file was loaded + * @size: Size of the file + * Return: 0 if OK, or -ve error code + */ +int bootstd_img_add(struct blk_desc *desc, int fs_type, const char *fname, + enum bootflow_img_t type, ulong addr, ulong size); + #endif From patchwork Mon Nov 4 17:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2006436 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Cz+rUKKT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhzcH0Y7Vz1xxN for ; Tue, 5 Nov 2024 04:54:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CD4B890C5; Mon, 4 Nov 2024 18:51:52 +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="Cz+rUKKT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B544588FE2; Mon, 4 Nov 2024 18:51:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 88AD188FAB for ; Mon, 4 Nov 2024 18:51:49 +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-xd2c.google.com with SMTP id ca18e2360f4ac-83ac817aac3so175813539f.0 for ; Mon, 04 Nov 2024 09:51:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730742708; x=1731347508; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GCkMrcznTuktTaPZ3PhIzrucNAzZFdOC+8tMnfyeBrM=; b=Cz+rUKKTgEaZNtLLuo3rSbUZKMbOzhQNSH5YtnwYMOPH8wXbnr0H8VFzBW6fbn5uGL D+/hT6Y1ez/Py2nznDdpunuvGnSe8CZLmJSQjhuJnoE7QrB2kz4vEXJhOpl5mXKhMqxp VbiB0Qu9tglEzPO2tEf1w2TjPWk/7NjqtShCc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730742708; x=1731347508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GCkMrcznTuktTaPZ3PhIzrucNAzZFdOC+8tMnfyeBrM=; b=iuDyCEoU+Nks+T0mw4bYPJfT0fdcbIa5qclg2EF5TriTYr0fBWZvgOv5Ty2kNrnSz3 b7kxXMJCAl9joWT1FKh/4kjF7MB+X7Cjya4yzyPJlIs5Jpne4PyuWXTjCdKr4yXM/5Yf g8drKOQICpbtZGubI/7yoi6i3gu8OmyrLFXP8+IX3h0pvfzSAoGEVMUyb21bn07/71IN HkEEz8Q3ltSOabpXCVtUqxr6xzB8LDJ1PVbHY32aH1HU41/WQYY1N28t78BDpqxu18q1 KHRaMnYEMvHsr5NIcuTXqcZrf4ahzOxbgcspf5gCHPjm46IS3I6dlD9X6ixSkIctgPrC najQ== X-Gm-Message-State: AOJu0YzPBqtRM122s6T5qu1shKK8r0R9haF4eGoSHlaagBpPAFS/FQx8 aXHcGfdgvnBoKc4jpDAuZoIWyf7/cOGUlu8XXpu34iYuXgb50VObIMF5RsJQictM6Ug3DqTz+8A = X-Google-Smtp-Source: AGHT+IGpGVEdnIxAn+BaW8ScxtgbYlkxMUhqaFisOQS/AXGYxu1QCn8g5jt3eEay1Lm46io8LLsmvQ== X-Received: by 2002:a05:6602:1507:b0:82c:d67d:aa91 with SMTP id ca18e2360f4ac-83b566cc65dmr2473578839f.1.1730742707783; Mon, 04 Nov 2024 09:51:47 -0800 (PST) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4de04977b30sm2005288173.116.2024.11.04.09.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 09:51:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Heinrich Schuchardt , Ilias Apalodimas , Mattijs Korpershoek , Nam Cao , Quentin Schulz , Sean Anderson , Sughosh Ganu Subject: [PATCH v3 19/19] fs: Record loaded files in an ad-hoc bootflow Date: Mon, 4 Nov 2024 10:51:10 -0700 Message-Id: <20241104175110.1048449-20-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104175110.1048449-1-sjg@chromium.org> References: <20241104175110.1048449-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean This makes a start on dealing with images loaded outside the context of bootstd. For now, it just records these images. They can be listed using the 'bootstd images' command. Often, very little is known about these images, but future work could perhaps use the filename or contents to detect the type. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to record loaded files in an ad-hoc bootflow Changes in v2: - Drop patches already applied - Drop patches which add new image types - Update to use a new image-type enum in bootflow.h doc/develop/bootstd/overview.rst | 3 +++ fs/fs.c | 15 +++++++++++++++ test/boot/bootflow.c | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst index e3ce97cc4f5..c46bd7a5a90 100644 --- a/doc/develop/bootstd/overview.rst +++ b/doc/develop/bootstd/overview.rst @@ -486,6 +486,9 @@ be visible. Once a bootflow has been selected, images for those that are not selected can potentially be dropped from the memory map. For now, this is not implemented. +In cases where images are loaded outside the context of standard boot, an ad-hoc +bootflow is used to keep track of these. They is visible with the +``bootstd images`` command (see :doc:`/usage/cmd/bootstd`). .. _BootflowStates: diff --git a/fs/fs.c b/fs/fs.c index 1afa0fbeaed..d56c95c1b26 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -5,6 +5,7 @@ #define LOG_CATEGORY LOGC_CORE +#include #include #include #include @@ -734,12 +735,14 @@ int do_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int fstype) { + struct blk_desc *dev_desc; unsigned long addr; const char *addr_str; const char *filename; loff_t bytes; loff_t pos; loff_t len_read; + int dev_part; int ret; unsigned long time; char *ep; @@ -783,6 +786,10 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], else pos = 0; + /* save globals before they are cleared */ + dev_desc = fs_dev_desc; + dev_part = fs_dev_part; + time = get_timer(0); ret = _fs_read(filename, addr, pos, bytes, 1, &len_read); time = get_timer(time); @@ -806,6 +813,14 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], env_set_hex("fileaddr", addr); env_set_hex("filesize", len_read); + if (IS_ENABLED(CONFIG_BOOTSTD) && + bootstd_img_add(dev_desc, dev_part, filename, + (enum bootflow_img_t)IH_TYPE_INVALID, addr, + len_read)) { + log_err("Failed to record file\n"); + return CMD_RET_FAILURE; + } + return 0; } diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 670b9253f61..8b11378a085 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1322,3 +1322,23 @@ static int bootstd_images(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootstd_images, UTF_CONSOLE); + +/* Check creation of ad-hoc images */ +static int bootstd_adhoc(struct unit_test_state *uts) +{ + ut_assertok(run_command("load mmc 1:1 1000 /extlinux/extlinux.conf", + 0)); + ut_assert_nextlinen("595 bytes read"); + ut_assertok(run_command("bootstd images", 0)); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextline( + " 0 ad-hoc invalid 1000 253 /extlinux/extlinux.conf"); + ut_assert_nextlinen("---"); + ut_assert_nextline("(1 image)"); + + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootstd_adhoc, UTF_CONSOLE);