summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorFrancesco Valla <[email protected]>2026-06-04 22:41:40 +0200
committerTom Rini <[email protected]>2026-06-17 14:16:41 -0600
commite41a770f3800f9c0d2f74fedc04eea09a29a3776 (patch)
tree08d3b3586c1be8f9bbabbc06e025b62d1b2998e9 /arch
parent99b9223948a4361daff09bc973c2d283e48d8bd6 (diff)
test: spl: add unit test for the "full" FIT loader
Following what is already done for the "simple" FIT loader, add a unit test for the "full" loader. Signed-off-by: Francesco Valla <[email protected]>
Diffstat (limited to 'arch')
-rw-r--r--arch/sandbox/cpu/spl.c37
-rw-r--r--arch/sandbox/include/asm/spl.h14
2 files changed, 51 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 7ee4975523e..1668b58d3fb 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -265,6 +265,43 @@ int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image)
return 0;
}
+int sandbox_spl_load_fit_full(char *fname, int maxlen,
+ struct spl_image_info *image)
+{
+ struct legacy_img_hdr *header;
+ long long size;
+ int ret;
+ int fd;
+
+ ret = sandbox_find_next_phase(fname, maxlen, true);
+ if (ret) {
+ printf("%s not found, error %d\n", fname, ret);
+ return log_msg_ret("nph", ret);
+ }
+
+ log_debug("reading from %s\n", fname);
+ fd = os_open(fname, OS_O_RDONLY);
+ if (fd < 0) {
+ printf("Failed to open '%s'\n", fname);
+ return log_msg_ret("ope", -errno);
+ }
+
+ if (os_get_filesize(fname, &size))
+ return log_msg_ret("fis", -ENOENT);
+
+ header = spl_get_load_buffer(0, size);
+
+ if (os_read(fd, header, size) != size)
+ return log_msg_ret("rea", -EIO);
+ os_close(fd);
+
+ ret = spl_load_fit_image(image, header);
+ if (ret)
+ return log_msg_ret("slf", ret);
+
+ return 0;
+}
+
static int upl_load_from_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
diff --git a/arch/sandbox/include/asm/spl.h b/arch/sandbox/include/asm/spl.h
index d824b2123a2..49a613ba92d 100644
--- a/arch/sandbox/include/asm/spl.h
+++ b/arch/sandbox/include/asm/spl.h
@@ -46,4 +46,18 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool use_img);
*/
int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image);
+/**
+ * sandbox_spl_load_fit_full() - Load the next phase from a FIT with the "full" loader
+ *
+ * Loads a FIT containing the next phase and sets it up for booting, using the
+ * "full" FIT loader
+ *
+ * @fname: Returns filename loaded
+ * @maxlen: Maximum length for @fname including \0
+ * @image: Place to put SPL-image information
+ * Return: 0 if OK, -ve on error
+ */
+int sandbox_spl_load_fit_full(char *fname, int maxlen,
+ struct spl_image_info *image);
+
#endif