From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F37D5C54EBC for ; Sun, 8 Jan 2023 03:04:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A51FE8564B; Sun, 8 Jan 2023 04:03:59 +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="oE7JKc+s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6F61384F72; Sun, 8 Jan 2023 04:03:53 +0100 (CET) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 820B585683 for ; Sun, 8 Jan 2023 03: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=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id c20so3284637ilj.10 for ; Sat, 07 Jan 2023 18:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=qiMwo98g8+RwMHdp1f/+qOULq18yaKMtOufk7SYF+Po=; b=oE7JKc+smxo49j1N0QSJfSvSV5BjSckqiG758DZ6kyz8oNz59x7dVhhXwq0V1ewVgq 0IrLX7TdgMRaNAVhEtAZBL/xCF3Gk/XuXVlZh7pXX6YuaiGaxYLOaV07HEVWBKV0xuQf yVySiZlGaadQgKfFtMFMGC50vAUvCh5ahle3o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=qiMwo98g8+RwMHdp1f/+qOULq18yaKMtOufk7SYF+Po=; b=rxxnjNoTtbxY7TmCfndoJ3NDGiOOxtjMLrWunkWBSuJ84ONhrX9ZrBHWddfuBqNa+V lYQTQTfDw1Bii4y4f7njAaHgR3koJs5MAVPDpDgH8DWs8TJDebHRUAcN+1+VSkTQF3JN 5etX5CnKQYAJtMsxdN04hVhnQb2foNxAReeXLkveTD1slEUbBpnLB/Km6vtNMuARU1mB a2hDz33E3EuvByzGSXmfXR4bIFtC/QIVstbSpW3QusJczVe07NghzHCwiMYc16DF4NiZ eZolanhVmtK8byKWqHJh5fn0+DMfOtLKSK3IbWiUcOgEDZpsvRTlpKWnk3BQ66ajCURa BCSA== X-Gm-Message-State: AFqh2kqxbuSOZyUt6KQoGe4PEZpABP2bNM1xWVnB22AyWk791Et24x8e jkx1hTdAb5tEeBPtJfw7GUqCPUAsxMJM5BmE X-Google-Smtp-Source: AMrXdXuF+IaXFhnNnIZqZ9U2dJFlchrC8I3oNI9DYB5Yop6aEJihS0ekWQUsCle/rRpQnO3a/SF5kg== X-Received: by 2002:a92:c902:0:b0:303:3513:d072 with SMTP id t2-20020a92c902000000b003033513d072mr51098689ilp.0.1673146292051; Sat, 07 Jan 2023 18:51:32 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 52/71] bootstd: Add a new bootmeth method to set the bootflow Date: Sat, 7 Jan 2023 19:50:28 -0700 Message-Id: <20230108025047.522240-53-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Normally the bootmeth driver reads the bootflow from the bootdev, since it knows the correct way to do it. However it is easier for some bootdevs to handle this themselves. For example, reading from SPI flash is quite different from other devices. Add a way for the bootdev to pass a bootflow to the bootmeth, so that this can be supported. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth-uclass.c | 11 +++++++++++ include/bootmeth.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 4c3529d1555..2aee1e0f0c5 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -50,6 +50,17 @@ int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow) return ops->read_bootflow(dev, bflow); } +int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow, + char *buf, int size) +{ + const struct bootmeth_ops *ops = bootmeth_get_ops(dev); + + if (!ops->set_bootflow) + return -ENOSYS; + + return ops->set_bootflow(dev, bflow, buf, size); +} + int bootmeth_boot(struct udevice *dev, struct bootflow *bflow) { const struct bootmeth_ops *ops = bootmeth_get_ops(dev); diff --git a/include/bootmeth.h b/include/bootmeth.h index bdce301e925..b12dfd42c90 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -87,6 +87,22 @@ struct bootmeth_ops { */ int (*read_bootflow)(struct udevice *dev, struct bootflow *bflow); + /** + * set_bootflow() - set the bootflow for a device + * + * This provides a bootflow file to the bootmeth, to see if it is valid. + * If it is, the bootflow is set up accordingly. + * + * @dev: Bootmethod device to use + * @bflow: On entry, provides bootdev. + * Returns updated bootflow if found + * @buf: Buffer containing the possible bootflow file + * @size: Size of file + * Return: 0 if OK, -ve on error + */ + int (*set_bootflow)(struct udevice *dev, struct bootflow *bflow, + char *buf, int size); + /** * read_file() - read a file needed for a bootflow * @@ -173,6 +189,23 @@ int bootmeth_check(struct udevice *dev, struct bootflow_iter *iter); */ int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow); +/** + * bootmeth_set_bootflow() - set the bootflow for a device + * + * This provides a bootflow file to the bootmeth, to see if it is valid. + * If it is, the bootflow is set up accordingly. + * + * @dev: Bootmethod device to use + * @bflow: On entry, provides bootdev. + * Returns updated bootflow if found + * @buf: Buffer containing the possible bootflow file (must be allocated + * by caller to @size + 1 bytes) + * @size: Size of file + * Return: 0 if OK, -ve on error + */ +int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow, + char *buf, int size); + /** * bootmeth_read_file() - read a file needed for a bootflow * -- 2.39.0.314.g84b9a713c41-goog