public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: Bin Meng <bmeng.cn@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: Mayuresh Chitale <mchitale@ventanamicro.com>,
	u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Rick Chen <rick@andestech.com>, Leo <ycliang@andestech.com>
Subject: [PATCH v2 3/4] spl: Support loading a FIT from ext FS
Date: Tue,  2 May 2023 21:49:01 +0530	[thread overview]
Message-ID: <20230502161902.1339861-4-mchitale@ventanamicro.com> (raw)
In-Reply-To: <20230502161902.1339861-1-mchitale@ventanamicro.com>

Detect a FIT when loading from an ext File system and handle it using
the FIT SPL support.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 common/spl/spl_ext.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 2bf3434439..8593aed069 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -8,6 +8,26 @@
 #include <ext4fs.h>
 #include <errno.h>
 #include <image.h>
+#include <linux/libfdt.h>
+
+static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,
+			  ulong size, void *buf)
+{
+	loff_t filelen = (loff_t)load->priv, actlen;
+	char *filename = (char *)load->filename;
+	int ret;
+
+	ret = ext4fs_read(buf, file_offset, filelen, &actlen);
+	if (ret < 0) {
+		if (IS_ENABLED(CONFIG_SPL_LIBCOMMON_SUPPORT)) {
+			printf("%s: error reading image %s, err - %d\n",
+			       __func__, filename, ret);
+		}
+		return ret;
+	}
+
+	return actlen;
+}
 
 int spl_load_image_ext(struct spl_image_info *spl_image,
 		       struct spl_boot_device *bootdev,
@@ -47,6 +67,19 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 		goto end;
 	}
 
+	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+	    image_get_magic(header) == FDT_MAGIC) {
+		struct spl_load_info load;
+
+		debug("Found FIT\n");
+		load.read = spl_fit_read;
+		load.bl_len = 1;
+		load.filename = (void *)filename;
+		load.priv = (void *)filelen;
+
+		return spl_load_simple_fit(spl_image, &load, 0, header);
+	}
+
 	err = spl_parse_image_header(spl_image, bootdev, header);
 	if (err < 0) {
 		puts("spl: ext: failed to parse image header\n");
-- 
2.34.1


  parent reply	other threads:[~2023-05-02 16:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
2023-05-02 16:18 ` [PATCH v2 1/4] spl: Add Kconfig options for NVME Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 2/4] nvme: pci: Enable for SPL Mayuresh Chitale
2023-05-03  1:28   ` Simon Glass
2023-05-04  8:27     ` Mayuresh Chitale
2023-05-02 16:19 ` Mayuresh Chitale [this message]
2023-05-02 16:19 ` [PATCH v2 4/4] common: spl: Add spl NVMe boot support Mayuresh Chitale
2023-05-03  1:28   ` Simon Glass
2023-05-04  8:28     ` Mayuresh Chitale

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=20230502161902.1339861-4-mchitale@ventanamicro.com \
    --to=mchitale@ventanamicro.com \
    --cc=bmeng.cn@gmail.com \
    --cc=rick@andestech.com \
    --cc=sjg@chromium.org \
    --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