Hi Simon,
On Fri, May 5, 2023 at 6:11 AM Simon Glass <s...@chromium.org> wrote: > > Hi Mayuresh, > > On Thu, 4 May 2023 at 03:53, Mayuresh Chitale <mchit...@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 <mchit...@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? Ok > > > > + 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