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>
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index e1a7d25..d550da2 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -17,7 +17,9 @@
#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;
@@ -26,7 +28,7 @@
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;
@@ -77,6 +79,7 @@
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;
@@ -116,7 +119,7 @@
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:
@@ -181,6 +184,7 @@
#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)
{
@@ -211,15 +215,16 @@
}
#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;
@@ -239,7 +244,7 @@
}
#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;
@@ -257,6 +262,7 @@
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;
@@ -264,20 +270,22 @@
#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)
@@ -286,13 +294,13 @@
#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)
@@ -307,7 +315,9 @@
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;
@@ -410,7 +420,7 @@
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;
}
@@ -418,13 +428,14 @@
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;
@@ -433,7 +444,7 @@
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;