SPL: Add struct spl_boot_device parameter into spl_parse_board_header()

Add parameter spl_boot_device to spl_parse_board_header(), which allows
the implementations to see from which device we are booting and do
boot-device-specific checks of the image header.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:
Pali Rohár 2022-01-14 14:31:38 +01:00 committed by Stefan Roese
parent 66f874855c
commit 2e0429bcc1
22 changed files with 95 additions and 60 deletions

View File

@ -100,6 +100,7 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
#endif #endif
int spl_parse_board_header(struct spl_image_info *spl_image, 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 void *image_header, size_t size)
{ {
const struct kwbimage_main_hdr_v1 *mhdr = image_header; const struct kwbimage_main_hdr_v1 *mhdr = image_header;

View File

@ -348,7 +348,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
ret = spl_load_simple_fit(spl_image, &load, ret = spl_load_simple_fit(spl_image, &load,
load_offset, header); load_offset, header);
} else { } else {
ret = spl_parse_image_header(spl_image, header); ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret) if (ret)
return ret; return ret;

View File

@ -312,6 +312,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
#endif #endif
__weak int spl_parse_board_header(struct spl_image_info *spl_image, __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) const void *image_header, size_t size)
{ {
return -EINVAL; return -EINVAL;
@ -326,6 +327,7 @@ __weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
} }
int spl_parse_image_header(struct spl_image_info *spl_image, int spl_parse_image_header(struct spl_image_info *spl_image,
const struct spl_boot_device *bootdev,
const struct image_header *header) const struct image_header *header)
{ {
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) #if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
@ -369,7 +371,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
} }
#endif #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; return 0;
#ifdef CONFIG_SPL_RAW_IMAGE_SUPPORT #ifdef CONFIG_SPL_RAW_IMAGE_SUPPORT

View File

@ -10,6 +10,7 @@
#include <image.h> #include <image.h>
int spl_load_image_ext(struct spl_image_info *spl_image, int spl_load_image_ext(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition, struct blk_desc *block_dev, int partition,
const char *filename) const char *filename)
{ {
@ -46,7 +47,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
goto end; goto end;
} }
err = spl_parse_image_header(spl_image, header); err = spl_parse_image_header(spl_image, bootdev, header);
if (err < 0) { if (err < 0) {
puts("spl: ext: failed to parse image header\n"); puts("spl: ext: failed to parse image header\n");
goto end; goto end;
@ -66,6 +67,7 @@ end:
#if CONFIG_IS_ENABLED(OS_BOOT) #if CONFIG_IS_ENABLED(OS_BOOT)
int spl_load_image_ext_os(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) struct blk_desc *block_dev, int partition)
{ {
int err; int err;
@ -103,7 +105,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
} }
file = env_get("falcon_image_file"); file = env_get("falcon_image_file");
if (file) { if (file) {
err = spl_load_image_ext(spl_image, block_dev, err = spl_load_image_ext(spl_image, bootdev, block_dev,
partition, file); partition, file);
if (err != 0) { if (err != 0) {
puts("spl: falling back to default\n"); puts("spl: falling back to default\n");
@ -134,11 +136,12 @@ defaults:
return -1; 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); CONFIG_SPL_FS_LOAD_KERNEL_NAME);
} }
#else #else
int spl_load_image_ext_os(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) struct blk_desc *block_dev, int partition)
{ {
return -ENOSYS; return -ENOSYS;

View File

@ -55,6 +55,7 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,
} }
int spl_load_image_fat(struct spl_image_info *spl_image, int spl_load_image_fat(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition, struct blk_desc *block_dev, int partition,
const char *filename) const char *filename)
{ {
@ -76,7 +77,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0); err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
if (err <= 0) if (err <= 0)
goto end; goto end;
err = spl_parse_image_header(spl_image, err = spl_parse_image_header(spl_image, bootdev,
(struct image_header *)CONFIG_SYS_LOAD_ADDR); (struct image_header *)CONFIG_SYS_LOAD_ADDR);
if (err == -EAGAIN) if (err == -EAGAIN)
return err; return err;
@ -94,7 +95,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
return spl_load_simple_fit(spl_image, &load, 0, header); return spl_load_simple_fit(spl_image, &load, 0, header);
} else { } else {
err = spl_parse_image_header(spl_image, header); err = spl_parse_image_header(spl_image, bootdev, header);
if (err) if (err)
goto end; goto end;
@ -114,6 +115,7 @@ end:
#if CONFIG_IS_ENABLED(OS_BOOT) #if CONFIG_IS_ENABLED(OS_BOOT)
int spl_load_image_fat_os(struct spl_image_info *spl_image, int spl_load_image_fat_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition) struct blk_desc *block_dev, int partition)
{ {
int err; int err;
@ -134,7 +136,7 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
} }
file = env_get("falcon_image_file"); file = env_get("falcon_image_file");
if (file) { if (file) {
err = spl_load_image_fat(spl_image, block_dev, err = spl_load_image_fat(spl_image, bootdev, block_dev,
partition, file); partition, file);
if (err != 0) { if (err != 0) {
puts("spl: falling back to default\n"); puts("spl: falling back to default\n");
@ -160,11 +162,12 @@ defaults:
return -1; 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); CONFIG_SPL_FS_LOAD_KERNEL_NAME);
} }
#else #else
int spl_load_image_fat_os(struct spl_image_info *spl_image, int spl_load_image_fat_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition) struct blk_desc *block_dev, int partition)
{ {
return -ENOSYS; return -ENOSYS;

View File

@ -76,6 +76,7 @@ static inline int spl_image_get_comp(const struct image_header *hdr)
} }
int spl_load_legacy_img(struct spl_image_info *spl_image, int spl_load_legacy_img(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct spl_load_info *load, ulong header) struct spl_load_info *load, ulong header)
{ {
__maybe_unused SizeT lzma_len; __maybe_unused SizeT lzma_len;
@ -87,7 +88,7 @@ int spl_load_legacy_img(struct spl_image_info *spl_image,
/* Read header into local struct */ /* Read header into local struct */
load->read(load, header, sizeof(hdr), &hdr); 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) if (ret)
return ret; return ret;

View File

@ -17,7 +17,9 @@
#include <mmc.h> #include <mmc.h>
#include <image.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) ulong sector, struct image_header *header)
{ {
u32 image_offset_sectors; u32 image_offset_sectors;
@ -26,7 +28,7 @@ static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
u32 image_offset; u32 image_offset;
int ret; int ret;
ret = spl_parse_image_header(spl_image, header); ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret) if (ret)
return ret; return ret;
@ -77,6 +79,7 @@ static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part)
static __maybe_unused static __maybe_unused
int mmc_load_image_raw_sector(struct spl_image_info *spl_image, int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct mmc *mmc, unsigned long sector) struct mmc *mmc, unsigned long sector)
{ {
unsigned long count; unsigned long count;
@ -116,7 +119,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
ret = spl_load_imx_container(spl_image, &load, sector); ret = spl_load_imx_container(spl_image, &load, sector);
} else { } else {
ret = mmc_load_legacy(spl_image, mmc, sector, header); ret = mmc_load_legacy(spl_image, bootdev, mmc, sector, header);
} }
end: end:
@ -181,6 +184,7 @@ static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct mmc *mmc, int partition, struct mmc *mmc, int partition,
unsigned long sector) unsigned long sector)
{ {
@ -211,15 +215,16 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
} }
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_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 #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
} }
#endif #endif
#if CONFIG_IS_ENABLED(OS_BOOT) #if CONFIG_IS_ENABLED(OS_BOOT)
static int mmc_load_image_raw_os(struct spl_image_info *spl_image, static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct mmc *mmc) struct mmc *mmc)
{ {
int ret; int ret;
@ -239,7 +244,7 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
} }
#endif /* CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR */ #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); CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
if (ret) if (ret)
return ret; return ret;
@ -257,6 +262,7 @@ int spl_start_uboot(void)
return 1; return 1;
} }
static int mmc_load_image_raw_os(struct spl_image_info *spl_image, static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct mmc *mmc) struct mmc *mmc)
{ {
return -ENOSYS; return -ENOSYS;
@ -264,20 +270,22 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
#endif #endif
#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION #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) const char *filename)
{ {
int err = -ENOSYS; int err = -ENOSYS;
#ifdef CONFIG_SPL_FS_FAT #ifdef CONFIG_SPL_FS_FAT
if (!spl_start_uboot()) { 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); CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err) if (!err)
return err; return err;
} }
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME #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, CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
filename); filename);
if (!err) if (!err)
@ -286,13 +294,13 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc,
#endif #endif
#ifdef CONFIG_SPL_FS_EXT4 #ifdef CONFIG_SPL_FS_EXT4
if (!spl_start_uboot()) { 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); CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err) if (!err)
return err; return err;
} }
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME #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, CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
filename); filename);
if (!err) if (!err)
@ -307,7 +315,9 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc,
return err; return err;
} }
#else #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) const char *filename)
{ {
return -ENOSYS; return -ENOSYS;
@ -410,7 +420,7 @@ int spl_mmc_load(struct spl_image_info *spl_image,
debug("spl: mmc boot mode: raw\n"); debug("spl: mmc boot mode: raw\n");
if (!spl_start_uboot()) { 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) if (!err)
return err; return err;
} }
@ -418,13 +428,14 @@ int spl_mmc_load(struct spl_image_info *spl_image,
raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect); raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect);
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION #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); raw_sect);
if (!err) if (!err)
return err; return err;
#endif #endif
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #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)); raw_sect + spl_mmc_raw_uboot_offset(part));
if (!err) if (!err)
return err; return err;
@ -433,7 +444,7 @@ int spl_mmc_load(struct spl_image_info *spl_image,
case MMCSD_MODE_FS: case MMCSD_MODE_FS:
debug("spl: mmc boot mode: fs\n"); 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) if (!err)
return err; return err;

View File

@ -65,6 +65,7 @@ struct mtd_info * __weak nand_get_mtd(void)
} }
static int spl_nand_load_element(struct spl_image_info *spl_image, static int spl_nand_load_element(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
int offset, struct image_header *header) int offset, struct image_header *header)
{ {
struct mtd_info *mtd = nand_get_mtd(); struct mtd_info *mtd = nand_get_mtd();
@ -96,7 +97,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
load.read = spl_nand_fit_read; load.read = spl_nand_fit_read;
return spl_load_imx_container(spl_image, &load, offset / bl_len); return spl_load_imx_container(spl_image, &load, offset / bl_len);
} else { } else {
err = spl_parse_image_header(spl_image, header); err = spl_parse_image_header(spl_image, bootdev, header);
if (err) if (err)
return err; return err;
return nand_spl_load_image(offset, spl_image->size, return nand_spl_load_image(offset, spl_image->size,
@ -145,7 +146,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
/* load linux */ /* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
sizeof(*header), (void *)header); sizeof(*header), (void *)header);
err = spl_parse_image_header(spl_image, header); err = spl_parse_image_header(spl_image, bootdev, header);
if (err) if (err)
return err; return err;
if (header->ih_os == IH_OS_LINUX) { if (header->ih_os == IH_OS_LINUX) {
@ -165,18 +166,18 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
} }
#endif #endif
#ifdef CONFIG_NAND_ENV_DST #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 #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
#endif #endif
/* Load u-boot */ /* 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); header);
#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND #ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND #if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
if (err) if (err)
err = spl_nand_load_element(spl_image, err = spl_nand_load_element(spl_image, bootdev,
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND, CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
header); header);
#endif #endif

View File

@ -58,7 +58,7 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
} else { } else {
debug("Legacy image\n"); debug("Legacy image\n");
rv = spl_parse_image_header(spl_image, header); rv = spl_parse_image_header(spl_image, bootdev, header);
if (rv) if (rv)
return rv; return rv;

View File

@ -66,7 +66,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
/* happy - was a Linux */ /* happy - was a Linux */
int ret; int ret;
ret = spl_parse_image_header(spl_image, header); ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret) if (ret)
return ret; return ret;
@ -113,7 +113,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_SUPPORT)) { if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_SUPPORT)) {
load.bl_len = 1; load.bl_len = 1;
load.read = spl_nor_load_read; 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()); spl_nor_get_uboot_base());
} }

View File

@ -27,7 +27,7 @@ static int spl_onenand_load_image(struct spl_image_info *spl_image,
/* Load u-boot */ /* Load u-boot */
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header); 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) if (ret)
return ret; return ret;
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,

View File

@ -70,7 +70,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
} }
header = (struct image_header *)map_sysmem(u_boot_pos, 0); 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; return 0;

View File

@ -31,6 +31,7 @@
#endif #endif
static int spl_sata_load_image_raw(struct spl_image_info *spl_image, 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 blk_desc *stor_dev, unsigned long sector)
{ {
struct image_header *header; struct image_header *header;
@ -45,7 +46,7 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
if (count == 0) if (count == 0)
return -EIO; return -EIO;
ret = spl_parse_image_header(spl_image, header); ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret) if (ret)
return ret; return ret;
@ -90,18 +91,18 @@ static int spl_sata_load_image(struct spl_image_info *spl_image,
#if CONFIG_IS_ENABLED(OS_BOOT) #if CONFIG_IS_ENABLED(OS_BOOT)
if (spl_start_uboot() || 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)) CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
#endif #endif
{ {
err = -ENOSYS; err = -ENOSYS;
if (IS_ENABLED(CONFIG_SPL_FS_FAT)) { 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_SYS_SATA_FAT_BOOT_PARTITION,
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
} else if (IS_ENABLED(CONFIG_SPL_SATA_RAW_U_BOOT_USE_SECTOR)) { } 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); CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR);
} }
} }

View File

@ -39,7 +39,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
* or it loads a FIT image and returns it to be handled by the SPL * or it loads a FIT image and returns it to be handled by the SPL
* code. * code.
*/ */
ret = spl_sdp_handle(controller_index, spl_image); ret = spl_sdp_handle(controller_index, spl_image, bootdev);
debug("SDP ended\n"); debug("SDP ended\n");
usb_gadget_release(controller_index); usb_gadget_release(controller_index);

View File

@ -24,6 +24,7 @@
* the kernel and then device tree. * the kernel and then device tree.
*/ */
static int spi_load_image_os(struct spl_image_info *spl_image, static int spi_load_image_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct spi_flash *flash, struct spi_flash *flash,
struct image_header *header) struct image_header *header)
{ {
@ -36,7 +37,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
if (image_get_magic(header) != IH_MAGIC) if (image_get_magic(header) != IH_MAGIC)
return -1; return -1;
err = spl_parse_image_header(spl_image, header); err = spl_parse_image_header(spl_image, bootdev, header);
if (err) if (err)
return err; return err;
@ -108,7 +109,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
} }
#if CONFIG_IS_ENABLED(OS_BOOT) #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 #endif
{ {
/* Load u-boot, mkimage header is 64 bytes. */ /* Load u-boot, mkimage header is 64 bytes. */
@ -127,7 +128,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
(void *)CONFIG_SYS_LOAD_ADDR); (void *)CONFIG_SYS_LOAD_ADDR);
if (err) if (err)
return 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); (struct image_header *)CONFIG_SYS_LOAD_ADDR);
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) { image_get_magic(header) == FDT_MAGIC) {
@ -154,7 +155,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
err = spl_load_imx_container(spl_image, &load, err = spl_load_imx_container(spl_image, &load,
payload_offs); payload_offs);
} else { } else {
err = spl_parse_image_header(spl_image, header); err = spl_parse_image_header(spl_image, bootdev, header);
if (err) if (err)
return err; return err;
err = spi_flash_read(flash, payload_offs + spl_image->offset, err = spi_flash_read(flash, payload_offs + spl_image->offset,

View File

@ -55,7 +55,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
ret = ubispl_load_volumes(&info, volumes, 2); ret = ubispl_load_volumes(&info, volumes, 2);
if (!ret) { if (!ret) {
header = (struct image_header *)volumes[0].load_addr; 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"); puts("Linux loaded.\n");
goto out; goto out;
} }
@ -75,7 +75,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
ret = ubispl_load_volumes(&info, volumes, 1); ret = ubispl_load_volumes(&info, volumes, 1);
if (!ret) if (!ret)
spl_parse_image_header(spl_image, header); spl_parse_image_header(spl_image, bootdev, header);
out: out:
#ifdef CONFIG_SPL_NAND_SUPPORT #ifdef CONFIG_SPL_NAND_SUPPORT
if (bootdev->boot_device == BOOT_DEVICE_NAND) if (bootdev->boot_device == BOOT_DEVICE_NAND)

View File

@ -49,10 +49,10 @@ int spl_usb_load(struct spl_image_info *spl_image,
#if CONFIG_IS_ENABLED(OS_BOOT) #if CONFIG_IS_ENABLED(OS_BOOT)
if (spl_start_uboot() || 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 #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) { if (err) {

View File

@ -24,7 +24,7 @@ static int spl_xip(struct spl_image_info *spl_image,
return 0; return 0;
} }
#endif #endif
return(spl_parse_image_header(spl_image, (const struct image_header *) return(spl_parse_image_header(spl_image, bootdev,
CONFIG_SYS_UBOOT_BASE)); (const struct image_header *)CONFIG_SYS_UBOOT_BASE));
} }
SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip); SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip);

View File

@ -112,7 +112,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
addr += res; addr += res;
} }
ret = spl_parse_image_header(spl_image, ih); ret = spl_parse_image_header(spl_image, bootdev, ih);
if (ret) if (ret)
return ret; return ret;
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
@ -135,7 +135,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
size += res; size += res;
} else { } else {
ih = (struct image_header *)buf; ih = (struct image_header *)buf;
ret = spl_parse_image_header(spl_image, ih); ret = spl_parse_image_header(spl_image, bootdev, ih);
if (ret) if (ret)
goto end_stream; goto end_stream;
#ifdef CONFIG_SPL_GZIP #ifdef CONFIG_SPL_GZIP

View File

@ -773,7 +773,8 @@ static ulong search_container_header(ulong p, int size)
} }
#endif #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; u8 *data = sdp_func->in_req->buf;
u32 status; u32 status;
@ -862,7 +863,8 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image)
/* In SPL, allow jumps to U-Boot images */ /* In SPL, allow jumps to U-Boot images */
struct spl_image_info spl_image = {}; 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); jump_to_image_no_args(&spl_image);
#else #else
/* In U-Boot, allow jumps to scripts */ /* In U-Boot, allow jumps to scripts */
@ -910,7 +912,8 @@ static void sdp_handle_out_ep(void)
#ifndef CONFIG_SPL_BUILD #ifndef CONFIG_SPL_BUILD
int sdp_handle(int controller_index) int sdp_handle(int controller_index)
#else #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 #endif
{ {
int flag = 0; int flag = 0;
@ -928,9 +931,9 @@ int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image)
usb_gadget_handle_interrupts(controller_index); usb_gadget_handle_interrupts(controller_index);
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_BUILD
flag = sdp_handle_in_ep(spl_image); flag = sdp_handle_in_ep(spl_image, bootdev);
#else #else
flag = sdp_handle_in_ep(NULL); flag = sdp_handle_in_ep(NULL, NULL);
#endif #endif
if (sdp_func->ep_int_enable) if (sdp_func->ep_int_enable)
sdp_handle_out_ep(); sdp_handle_out_ep();

View File

@ -14,7 +14,8 @@ int sdp_init(int controller_index);
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_BUILD
#include <spl.h> #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 #else
int sdp_handle(int controller_index); int sdp_handle(int controller_index);
#endif #endif

View File

@ -29,6 +29,7 @@ struct image_header;
struct blk_desc; struct blk_desc;
struct image_header; struct image_header;
struct spl_boot_device;
/* /*
* u_boot_first_phase() - check if this is the first U-Boot phase * u_boot_first_phase() - check if this is the first U-Boot phase
@ -340,6 +341,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
* Returns 0 on success. * Returns 0 on success.
*/ */
int spl_load_legacy_img(struct spl_image_info *spl_image, int spl_load_legacy_img(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct spl_load_info *load, ulong header); struct spl_load_info *load, ulong header);
/** /**
@ -438,6 +440,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image);
* @return 0 if a header was correctly parsed, -ve on error * @return 0 if a header was correctly parsed, -ve on error
*/ */
int spl_parse_image_header(struct spl_image_info *spl_image, int spl_parse_image_header(struct spl_image_info *spl_image,
const struct spl_boot_device *bootdev,
const struct image_header *header); const struct image_header *header);
void spl_board_prepare_for_linux(void); void spl_board_prepare_for_linux(void);
@ -574,18 +577,22 @@ static inline const char *spl_loader_name(const struct spl_image_loader *loader)
/* SPL FAT image functions */ /* SPL FAT image functions */
int spl_load_image_fat(struct spl_image_info *spl_image, int spl_load_image_fat(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition, struct blk_desc *block_dev, int partition,
const char *filename); const char *filename);
int spl_load_image_fat_os(struct spl_image_info *spl_image, int spl_load_image_fat_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition); struct blk_desc *block_dev, int partition);
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image); void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
/* SPL EXT image functions */ /* SPL EXT image functions */
int spl_load_image_ext(struct spl_image_info *spl_image, int spl_load_image_ext(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *block_dev, int partition, struct blk_desc *block_dev, int partition,
const char *filename); const char *filename);
int spl_load_image_ext_os(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); struct blk_desc *block_dev, int partition);
/** /**