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 37870C352A1 for ; Wed, 7 Dec 2022 09:06:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9CC6856FE; Wed, 7 Dec 2022 09:57:02 +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="Bshm/aJK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A7894856DB; Wed, 7 Dec 2022 09:56:56 +0100 (CET) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 BE401856DB for ; Wed, 7 Dec 2022 09:56:53 +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-pf1-x433.google.com with SMTP id 130so16946803pfu.8 for ; Wed, 07 Dec 2022 00:56:53 -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=9MnNV6x3LuzMgLSWoxp9XJLEWaApaH/yRDo6iw7HDLA=; b=Bshm/aJKjw/xTgyQX+/au4YP+Za2XeAwPEauj2WYsVp9bbDYqQMWZuvhnvpHZSv1Bi jrgMdGlrN7iogQKf/oWXxY7ct+p03UZ/vrdsTmJibielTl/F1YzgzjDRbs/B8K0Gtb5P wf6V5qXzdGeule0IJZbPajhFUP0dP4x+iCLe8= 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=9MnNV6x3LuzMgLSWoxp9XJLEWaApaH/yRDo6iw7HDLA=; b=Wl7kNkMhZl0o7Zqy1F8EOBkAsQL2oTR8J/YLAaEEulU6ImI8HlIiIIQLM1xsF1y3QW j26eOdlyAhkMqXg490QLEPi+yMxZobwJle60CyII0xg2ei6MlYFixK7PkARJ4MVSsoET z5KFObLSNStCf5q32ArEYZesf3orhvBb9NHOaWxsbVmcFa9R2OiTULs04kIUrjIwB5ls py5n3jlwjIkZw9rLQeGVpptmp1OOx7/yUHq6kuRC9QbAMujzqC1PteqBNTr/so2aI82P t64YBIzX9Wsw6JJPp2TzYeQlRX/3EGU6whzx7UoKGqw59ikry+2TiIGZMS6AHhwGNkL2 wWNg== X-Gm-Message-State: ANoB5plKK7ncPMI4A88MD3ReTkH51FN/JSl04BcZjDCUgyKGl4M9tToz jQIQDBxk9kw7O1dkTN3nQbidr/nHUB9b4NYO X-Google-Smtp-Source: AA0mqf6l6UkyNW/k6srFx3c6RygQkz6ESLeCWBiiz0DJyvsX4ZTQsI2JrU1NwLEBU8ZSbZTzxYeKwQ== X-Received: by 2002:a62:1b05:0:b0:576:91fa:8ed0 with SMTP id b5-20020a621b05000000b0057691fa8ed0mr20063342pfb.15.1670403411907; Wed, 07 Dec 2022 00:56:51 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 52/71] bootstd: Add a new bootmeth method to set the bootflow Date: Wed, 7 Dec 2022 21:51:18 +1300 Message-Id: <20221207085137.445249-53-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 25552dd96f6..e8eb650efd0 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 ba9e3667e52..c28962773f0 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.rc0.267.gcb52ba06e7-goog