+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2014
* Texas Instruments, <www.ti.com>
*
* Dan Murphy <dmurphy@ti.com>
*
- * SPDX-License-Identifier: GPL-2.0+
- *
* FAT Image Functions copied from spl_mmc.c
*/
#include <common.h>
+#include <env.h>
+#include <log.h>
#include <spl.h>
#include <asm/u-boot.h>
#include <fat.h>
#include <errno.h>
#include <image.h>
-#include <libfdt.h>
+#include <linux/libfdt.h>
static int fat_registered;
}
int spl_load_image_fat(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition,
const char *filename)
{
if (err)
goto end;
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
- sizeof(struct image_header));
+ header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
err = file_fat_read(filename, header, sizeof(struct image_header));
if (err <= 0)
goto end;
- if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
+ image_get_magic(header) == FDT_MAGIC) {
+ err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
+ if (err <= 0)
+ goto end;
+ err = spl_parse_image_header(spl_image, bootdev,
+ (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+ if (err == -EAGAIN)
+ return err;
+ if (err == 0)
+ err = 1;
+ } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
struct spl_load_info load;
return spl_load_simple_fit(spl_image, &load, 0, header);
} else {
- err = spl_parse_image_header(spl_image, header);
+ err = spl_parse_image_header(spl_image, bootdev, header);
if (err)
goto end;
return (err <= 0);
}
-#ifdef CONFIG_SPL_OS_BOOT
+#if CONFIG_IS_ENABLED(OS_BOOT)
int spl_load_image_fat_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition)
{
int err;
}
file = env_get("falcon_image_file");
if (file) {
- err = spl_load_image_fat(spl_image, block_dev,
+ err = spl_load_image_fat(spl_image, bootdev, block_dev,
partition, file);
if (err != 0) {
puts("spl: falling back to default\n");
return -1;
}
- return spl_load_image_fat(spl_image, block_dev, partition,
+ return spl_load_image_fat(spl_image, bootdev, block_dev, partition,
CONFIG_SPL_FS_LOAD_KERNEL_NAME);
}
#else
int spl_load_image_fat_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition)
{
return -ENOSYS;