#endif
int spl_parse_board_header(struct spl_image_info *spl_image,
+ const struct spl_boot_device *bootdev,
const void *image_header, size_t size)
{
const struct kwbimage_main_hdr_v1 *mhdr = image_header;
ret = spl_load_simple_fit(spl_image, &load,
load_offset, header);
} else {
- ret = spl_parse_image_header(spl_image, header);
+ ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret)
return ret;
#endif
__weak int spl_parse_board_header(struct spl_image_info *spl_image,
+ const struct spl_boot_device *bootdev,
const void *image_header, size_t size)
{
return -EINVAL;
}
int spl_parse_image_header(struct spl_image_info *spl_image,
+ const struct spl_boot_device *bootdev,
const struct image_header *header)
{
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
}
#endif
- if (!spl_parse_board_header(spl_image, (const void *)header, sizeof(*header)))
+ if (!spl_parse_board_header(spl_image, bootdev, (const void *)header, sizeof(*header)))
return 0;
#ifdef CONFIG_SPL_RAW_IMAGE_SUPPORT
#include <image.h>
int spl_load_image_ext(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition,
const char *filename)
{
goto end;
}
- err = spl_parse_image_header(spl_image, header);
+ err = spl_parse_image_header(spl_image, bootdev, header);
if (err < 0) {
puts("spl: ext: failed to parse image header\n");
goto end;
#if CONFIG_IS_ENABLED(OS_BOOT)
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 err;
}
file = env_get("falcon_image_file");
if (file) {
- err = spl_load_image_ext(spl_image, block_dev,
+ err = spl_load_image_ext(spl_image, bootdev, block_dev,
partition, file);
if (err != 0) {
puts("spl: falling back to default\n");
return -1;
}
- return spl_load_image_ext(spl_image, block_dev, partition,
+ return spl_load_image_ext(spl_image, bootdev, block_dev, partition,
CONFIG_SPL_FS_LOAD_KERNEL_NAME);
}
#else
int spl_load_image_ext_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition)
{
return -ENOSYS;
}
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)
{
err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
if (err <= 0)
goto end;
- err = spl_parse_image_header(spl_image,
+ err = spl_parse_image_header(spl_image, bootdev,
(struct image_header *)CONFIG_SYS_LOAD_ADDR);
if (err == -EAGAIN)
return err;
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;
#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;
}
int spl_load_legacy_img(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct spl_load_info *load, ulong header)
{
__maybe_unused SizeT lzma_len;
/* Read header into local struct */
load->read(load, header, sizeof(hdr), &hdr);
- ret = spl_parse_image_header(spl_image, &hdr);
+ ret = spl_parse_image_header(spl_image, bootdev, &hdr);
if (ret)
return ret;
#include <mmc.h>
#include <image.h>
-static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
+static int mmc_load_legacy(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
+ struct mmc *mmc,
ulong sector, struct image_header *header)
{
u32 image_offset_sectors;
u32 image_offset;
int ret;
- ret = spl_parse_image_header(spl_image, header);
+ ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret)
return ret;
static __maybe_unused
int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct mmc *mmc, unsigned long sector)
{
unsigned long count;
ret = spl_load_imx_container(spl_image, &load, sector);
} else {
- ret = mmc_load_legacy(spl_image, mmc, sector, header);
+ ret = mmc_load_legacy(spl_image, bootdev, mmc, sector, header);
}
end:
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct mmc *mmc, int partition,
unsigned long sector)
{
}
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
- return mmc_load_image_raw_sector(spl_image, mmc, info.start + sector);
+ return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start + sector);
#else
- return mmc_load_image_raw_sector(spl_image, mmc, info.start);
+ return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start);
#endif
}
#endif
#if CONFIG_IS_ENABLED(OS_BOOT)
static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct mmc *mmc)
{
int ret;
}
#endif /* CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR */
- ret = mmc_load_image_raw_sector(spl_image, mmc,
+ ret = mmc_load_image_raw_sector(spl_image, bootdev, mmc,
CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
if (ret)
return ret;
return 1;
}
static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct mmc *mmc)
{
return -ENOSYS;
#endif
#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
-static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc,
+static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
+ struct mmc *mmc,
const char *filename)
{
int err = -ENOSYS;
#ifdef CONFIG_SPL_FS_FAT
if (!spl_start_uboot()) {
- err = spl_load_image_fat_os(spl_image, mmc_get_blk_desc(mmc),
+ err = spl_load_image_fat_os(spl_image, bootdev, mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err)
return err;
}
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
- err = spl_load_image_fat(spl_image, mmc_get_blk_desc(mmc),
+ err = spl_load_image_fat(spl_image, bootdev, mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
filename);
if (!err)
#endif
#ifdef CONFIG_SPL_FS_EXT4
if (!spl_start_uboot()) {
- err = spl_load_image_ext_os(spl_image, mmc_get_blk_desc(mmc),
+ err = spl_load_image_ext_os(spl_image, bootdev, mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err)
return err;
}
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
- err = spl_load_image_ext(spl_image, mmc_get_blk_desc(mmc),
+ err = spl_load_image_ext(spl_image, bootdev, mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
filename);
if (!err)
return err;
}
#else
-static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc,
+static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
+ struct mmc *mmc,
const char *filename)
{
return -ENOSYS;
debug("spl: mmc boot mode: raw\n");
if (!spl_start_uboot()) {
- err = mmc_load_image_raw_os(spl_image, mmc);
+ err = mmc_load_image_raw_os(spl_image, bootdev, mmc);
if (!err)
return err;
}
raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect);
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
- err = mmc_load_image_raw_partition(spl_image, mmc, raw_part,
+ err = mmc_load_image_raw_partition(spl_image, bootdev,
+ mmc, raw_part,
raw_sect);
if (!err)
return err;
#endif
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
- err = mmc_load_image_raw_sector(spl_image, mmc,
+ err = mmc_load_image_raw_sector(spl_image, bootdev, mmc,
raw_sect + spl_mmc_raw_uboot_offset(part));
if (!err)
return err;
case MMCSD_MODE_FS:
debug("spl: mmc boot mode: fs\n");
- err = spl_mmc_do_fs_boot(spl_image, mmc, filename);
+ err = spl_mmc_do_fs_boot(spl_image, bootdev, mmc, filename);
if (!err)
return err;
}
static int spl_nand_load_element(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
int offset, struct image_header *header)
{
struct mtd_info *mtd = nand_get_mtd();
load.read = spl_nand_fit_read;
return spl_load_imx_container(spl_image, &load, offset / bl_len);
} else {
- err = spl_parse_image_header(spl_image, header);
+ err = spl_parse_image_header(spl_image, bootdev, header);
if (err)
return err;
return nand_spl_load_image(offset, spl_image->size,
/* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
sizeof(*header), (void *)header);
- err = spl_parse_image_header(spl_image, header);
+ err = spl_parse_image_header(spl_image, bootdev, header);
if (err)
return err;
if (header->ih_os == IH_OS_LINUX) {
}
#endif
#ifdef CONFIG_NAND_ENV_DST
- spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET, header);
+ spl_nand_load_element(spl_image, bootdev, CONFIG_ENV_OFFSET, header);
#ifdef CONFIG_ENV_OFFSET_REDUND
- spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET_REDUND, header);
+ spl_nand_load_element(spl_image, bootdev, CONFIG_ENV_OFFSET_REDUND, header);
#endif
#endif
/* Load u-boot */
- err = spl_nand_load_element(spl_image, spl_nand_get_uboot_raw_page(),
+ err = spl_nand_load_element(spl_image, bootdev, spl_nand_get_uboot_raw_page(),
header);
#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
if (err)
- err = spl_nand_load_element(spl_image,
+ err = spl_nand_load_element(spl_image, bootdev,
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
header);
#endif
} else {
debug("Legacy image\n");
- rv = spl_parse_image_header(spl_image, header);
+ rv = spl_parse_image_header(spl_image, bootdev, header);
if (rv)
return rv;
/* happy - was a Linux */
int ret;
- ret = spl_parse_image_header(spl_image, header);
+ ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret)
return ret;
if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_SUPPORT)) {
load.bl_len = 1;
load.read = spl_nor_load_read;
- return spl_load_legacy_img(spl_image, &load,
+ return spl_load_legacy_img(spl_image, bootdev, &load,
spl_nor_get_uboot_base());
}
/* Load u-boot */
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
- ret = spl_parse_image_header(spl_image, header);
+ ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret)
return ret;
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
}
header = (struct image_header *)map_sysmem(u_boot_pos, 0);
- spl_parse_image_header(spl_image, header);
+ spl_parse_image_header(spl_image, bootdev, header);
}
return 0;
#endif
static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *stor_dev, unsigned long sector)
{
struct image_header *header;
if (count == 0)
return -EIO;
- ret = spl_parse_image_header(spl_image, header);
+ ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret)
return ret;
#if CONFIG_IS_ENABLED(OS_BOOT)
if (spl_start_uboot() ||
- spl_load_image_fat_os(spl_image, stor_dev,
+ spl_load_image_fat_os(spl_image, bootdev, stor_dev,
CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
#endif
{
err = -ENOSYS;
if (IS_ENABLED(CONFIG_SPL_FS_FAT)) {
- err = spl_load_image_fat(spl_image, stor_dev,
+ err = spl_load_image_fat(spl_image, bootdev, stor_dev,
CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
} else if (IS_ENABLED(CONFIG_SPL_SATA_RAW_U_BOOT_USE_SECTOR)) {
- err = spl_sata_load_image_raw(spl_image, stor_dev,
+ err = spl_sata_load_image_raw(spl_image, bootdev, stor_dev,
CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR);
}
}
* or it loads a FIT image and returns it to be handled by the SPL
* code.
*/
- ret = spl_sdp_handle(controller_index, spl_image);
+ ret = spl_sdp_handle(controller_index, spl_image, bootdev);
debug("SDP ended\n");
usb_gadget_release(controller_index);
* the kernel and then device tree.
*/
static int spi_load_image_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct spi_flash *flash,
struct image_header *header)
{
if (image_get_magic(header) != IH_MAGIC)
return -1;
- err = spl_parse_image_header(spl_image, header);
+ err = spl_parse_image_header(spl_image, bootdev, header);
if (err)
return err;
}
#if CONFIG_IS_ENABLED(OS_BOOT)
- if (spl_start_uboot() || spi_load_image_os(spl_image, flash, header))
+ if (spl_start_uboot() || spi_load_image_os(spl_image, bootdev, flash, header))
#endif
{
/* Load u-boot, mkimage header is 64 bytes. */
(void *)CONFIG_SYS_LOAD_ADDR);
if (err)
return err;
- err = spl_parse_image_header(spl_image,
+ err = spl_parse_image_header(spl_image, bootdev,
(struct image_header *)CONFIG_SYS_LOAD_ADDR);
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
err = spl_load_imx_container(spl_image, &load,
payload_offs);
} else {
- err = spl_parse_image_header(spl_image, header);
+ err = spl_parse_image_header(spl_image, bootdev, header);
if (err)
return err;
err = spi_flash_read(flash, payload_offs + spl_image->offset,
ret = ubispl_load_volumes(&info, volumes, 2);
if (!ret) {
header = (struct image_header *)volumes[0].load_addr;
- spl_parse_image_header(spl_image, header);
+ spl_parse_image_header(spl_image, bootdev, header);
puts("Linux loaded.\n");
goto out;
}
ret = ubispl_load_volumes(&info, volumes, 1);
if (!ret)
- spl_parse_image_header(spl_image, header);
+ spl_parse_image_header(spl_image, bootdev, header);
out:
#ifdef CONFIG_SPL_NAND_SUPPORT
if (bootdev->boot_device == BOOT_DEVICE_NAND)
#if CONFIG_IS_ENABLED(OS_BOOT)
if (spl_start_uboot() ||
- spl_load_image_fat_os(spl_image, stor_dev, partition))
+ spl_load_image_fat_os(spl_image, bootdev, stor_dev, partition))
#endif
{
- err = spl_load_image_fat(spl_image, stor_dev, partition, filename);
+ err = spl_load_image_fat(spl_image, bootdev, stor_dev, partition, filename);
}
if (err) {
return 0;
}
#endif
- return(spl_parse_image_header(spl_image, (const struct image_header *)
- CONFIG_SYS_UBOOT_BASE));
+ return(spl_parse_image_header(spl_image, bootdev,
+ (const struct image_header *)CONFIG_SYS_UBOOT_BASE));
}
SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip);
addr += res;
}
- ret = spl_parse_image_header(spl_image, ih);
+ ret = spl_parse_image_header(spl_image, bootdev, ih);
if (ret)
return ret;
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
size += res;
} else {
ih = (struct image_header *)buf;
- ret = spl_parse_image_header(spl_image, ih);
+ ret = spl_parse_image_header(spl_image, bootdev, ih);
if (ret)
goto end_stream;
#ifdef CONFIG_SPL_GZIP
}
#endif
-static int sdp_handle_in_ep(struct spl_image_info *spl_image)
+static int sdp_handle_in_ep(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
{
u8 *data = sdp_func->in_req->buf;
u32 status;
/* In SPL, allow jumps to U-Boot images */
struct spl_image_info spl_image = {};
- spl_parse_image_header(&spl_image, header);
+ struct spl_boot_device bootdev = {};
+ spl_parse_image_header(&spl_image, &bootdev, header);
jump_to_image_no_args(&spl_image);
#else
/* In U-Boot, allow jumps to scripts */
#ifndef CONFIG_SPL_BUILD
int sdp_handle(int controller_index)
#else
-int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image)
+int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
#endif
{
int flag = 0;
usb_gadget_handle_interrupts(controller_index);
#ifdef CONFIG_SPL_BUILD
- flag = sdp_handle_in_ep(spl_image);
+ flag = sdp_handle_in_ep(spl_image, bootdev);
#else
- flag = sdp_handle_in_ep(NULL);
+ flag = sdp_handle_in_ep(NULL, NULL);
#endif
if (sdp_func->ep_int_enable)
sdp_handle_out_ep();
#ifdef CONFIG_SPL_BUILD
#include <spl.h>
-int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image);
+int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev);
#else
int sdp_handle(int controller_index);
#endif
struct blk_desc;
struct image_header;
+struct spl_boot_device;
/*
* u_boot_first_phase() - check if this is the first U-Boot phase
* Returns 0 on success.
*/
int spl_load_legacy_img(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct spl_load_info *load, ulong header);
/**
* @return 0 if a header was correctly parsed, -ve on error
*/
int spl_parse_image_header(struct spl_image_info *spl_image,
+ const struct spl_boot_device *bootdev,
const struct image_header *header);
void spl_board_prepare_for_linux(void);
/* SPL FAT image functions */
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);
int spl_load_image_fat_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition);
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
/* SPL EXT image functions */
int spl_load_image_ext(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition,
const char *filename);
int spl_load_image_ext_os(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition);
/**