From: Simon Glass <sjg@chromium.org>
To: Mayuresh Chitale <mchitale@ventanamicro.com>
Cc: Bin Meng <bmeng.cn@gmail.com>,
u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
Rick Chen <rick@andestech.com>, Leo <ycliang@andestech.com>
Subject: Re: [PATCH v3 2/5] spl: blk: Support loading images from fs
Date: Thu, 4 May 2023 18:41:08 -0600 [thread overview]
Message-ID: <CAPnjgZ1pOtzPFdmRpP27y64JtfhV2v6X7K3X2SV_HgDE75uuMA@mail.gmail.com> (raw)
In-Reply-To: <20230504095327.2791676-3-mchitale@ventanamicro.com>
Hi Mayuresh,
On Thu, 4 May 2023 at 03:53, Mayuresh Chitale <mchitale@ventanamicro.com> wrote:
>
> Add a generic API to support loading of SPL payload from EXT or FAT
> filesystem on a given partition of a block device.
>
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> ---
> common/spl/Makefile | 1 +
> common/spl/spl_blk_fs.c | 54 +++++++++++++++++++++++++++++++++++++++++
> drivers/block/Kconfig | 7 ++++++
> include/spl.h | 3 +++
> 4 files changed, 65 insertions(+)
> create mode 100644 common/spl/spl_blk_fs.c
>
> diff --git a/common/spl/Makefile b/common/spl/Makefile
> index 13db3df993..5210ad0248 100644
> --- a/common/spl/Makefile
> +++ b/common/spl/Makefile
> @@ -10,6 +10,7 @@ ifdef CONFIG_SPL_BUILD
> obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
> obj-$(CONFIG_$(SPL_TPL_)BOOTROM_SUPPORT) += spl_bootrom.o
> obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += spl_fit.o
> +obj-$(CONFIG_$(SPL_TPL_)BLK_FS) += spl_blk_fs.o
> obj-$(CONFIG_$(SPL_TPL_)LEGACY_IMAGE_FORMAT) += spl_legacy.o
> obj-$(CONFIG_$(SPL_TPL_)NOR_SUPPORT) += spl_nor.o
> obj-$(CONFIG_$(SPL_TPL_)XIP_SUPPORT) += spl_xip.o
> diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
> new file mode 100644
> index 0000000000..fb2e8bbea7
> --- /dev/null
> +++ b/common/spl/spl_blk_fs.c
> @@ -0,0 +1,54 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2023
> + * Ventana Micro Systems Inc.
> + *
> + * Derived work from spl_sata.c
> + */
> +
> +#include <common.h>
> +#include <spl.h>
> +
> +int spl_blk_load_image(struct spl_image_info *spl_image,
> + struct spl_boot_device *bootdev,
> + enum uclass_id uclass_id, int devnum)
> +{
> + int ret = -ENOSYS, part;
> + struct blk_desc *blk_desc;
> +
> + blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
> + if (!blk_desc)
> + return ret;
> +
> + blk_show_device(uclass_id, devnum);
> +
> + if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
Can you use the fs.h layer so it can work with any FS?
> + switch (uclass_id) {
> + case UCLASS_NVME:
> + part = CONFIG_SYS_NVME_EXT_BOOT_PARTITION;
> + break;
> + default:
> + return ret;
> + }
> + ret = spl_load_image_ext(spl_image, bootdev, blk_desc, part,
> + CONFIG_SPL_PAYLOAD);
> + if (!ret)
> + return ret;
> + }
> +
> + if (IS_ENABLED(CONFIG_SPL_FS_FAT)) {
> + switch (uclass_id) {
> + case UCLASS_NVME:
> + part = CONFIG_SYS_NVME_FAT_BOOT_PARTITION;
> + break;
> + default:
> + return ret;
> + }
> + ret = spl_load_image_fat(spl_image, bootdev, blk_desc, part,
> + CONFIG_SPL_PAYLOAD);
> + if (!ret)
> + return ret;
> + }
> +
> + return ret;
> +}
> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> index 5a1aeb3d2b..6baaa6f071 100644
> --- a/drivers/block/Kconfig
> +++ b/drivers/block/Kconfig
> @@ -107,6 +107,13 @@ config EFI_MEDIA
>
> For sandbox there is a test driver.
>
> +config SPL_BLK_FS
> + bool "Load images from filesystems on block devices"
> + depends on SPL_BLK
> + help
> + Use generic support to load images from fat/ext filesystems on
> + different types of block devices such as NVMe.
> +
> if EFI_MEDIA
>
> config EFI_MEDIA_SANDBOX
> diff --git a/include/spl.h b/include/spl.h
> index 7e0f5ac63b..4546648394 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -672,6 +672,9 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
> int spl_load_image_ext_os(struct spl_image_info *spl_image,
> struct spl_boot_device *bootdev,
> struct blk_desc *block_dev, int partition);
> +int spl_blk_load_image(struct spl_image_info *spl_image,
> + struct spl_boot_device *bootdev,
> + enum uclass_id uclass_id, int devnum);
>
> /**
> * spl_early_init() - Set up device tree and driver model in SPL if enabled
> --
> 2.34.1
>
Regards,
Simon
next prev parent reply other threads:[~2023-05-05 0:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 9:53 [PATCH v3 0/5] SPL NVMe support Mayuresh Chitale
2023-05-04 9:53 ` [PATCH v3 1/5] spl: Add Kconfig options for NVME Mayuresh Chitale
2023-05-05 0:41 ` Simon Glass
2023-05-04 9:53 ` [PATCH v3 2/5] spl: blk: Support loading images from fs Mayuresh Chitale
2023-05-05 0:41 ` Simon Glass [this message]
2023-06-03 8:19 ` Mayuresh Chitale
2023-05-04 9:53 ` [PATCH v3 3/5] nvme: pci: Enable for SPL Mayuresh Chitale
2023-05-05 0:41 ` Simon Glass
2023-06-03 8:19 ` Mayuresh Chitale
2023-05-04 9:53 ` [PATCH v3 4/5] spl: Support loading a FIT from ext FS Mayuresh Chitale
2023-05-05 0:40 ` Simon Glass
2023-06-03 8:21 ` Mayuresh Chitale
2023-05-17 14:41 ` Tom Rini
2023-05-17 14:58 ` Heinrich Schuchardt
2023-06-03 8:22 ` Mayuresh Chitale
2023-05-04 9:53 ` [PATCH v3 5/5] common: spl: Add spl NVMe boot support Mayuresh Chitale
2023-05-05 0:40 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPnjgZ1pOtzPFdmRpP27y64JtfhV2v6X7K3X2SV_HgDE75uuMA@mail.gmail.com \
--to=sjg@chromium.org \
--cc=bmeng.cn@gmail.com \
--cc=mchitale@ventanamicro.com \
--cc=rick@andestech.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).