summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/Kconfig2
-rw-r--r--common/spl/spl_ext.c64
-rw-r--r--common/spl/spl_fat.c47
-rw-r--r--common/spl/spl_fit.c2
-rw-r--r--common/spl/spl_mmc.c20
-rw-r--r--common/spl/spl_sata.c8
6 files changed, 75 insertions, 68 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index f34b96efc02..cb7b4179384 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -176,7 +176,7 @@ config SPL_SYS_STACK_F_CHECK_BYTE
Constant used to check the stack
config SPL_SYS_REPORT_STACK_F_USAGE
- depends on SPL_SIZE_LIMIT_PROVIDE_STACK != 0
+ depends on SPL_SIZE_LIMIT_PROVIDE_STACK > 0
bool "Check and report stack usage in SPL before relocation"
help
If this option is enabled, the initial SPL stack is filled with 0xaa
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 7e0274a3058..c66ba03feb2 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -47,9 +47,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
err = ext4fs_mount();
if (!err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: ext4fs mount err - %d\n", __func__, err);
-#endif
return -1;
}
@@ -63,11 +61,9 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
err = spl_load(spl_image, bootdev, &load, filelen, 0);
end:
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
if (err < 0)
printf("%s: error reading image %s, err - %d\n",
__func__, filename, err);
-#endif
return err < 0;
}
@@ -91,60 +87,68 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
err = ext4fs_mount();
if (!err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: ext4fs mount err - %d\n", __func__, err);
-#endif
return -1;
}
-#if defined(CONFIG_SPL_ENV_SUPPORT)
- file = env_get("falcon_args_file");
+
+ if (!CONFIG_IS_ENABLED(ENV_SUPPORT))
+ goto defaults;
+
+ file = env_get("falcon_image_file");
if (file) {
- err = ext4fs_open(file, &filelen);
- if (err < 0) {
- puts("spl: ext4fs_open failed\n");
- goto defaults;
- }
- err = ext4fs_read((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0, filelen, &actlen);
- if (err < 0) {
- printf("spl: error reading image %s, err - %d, falling back to default\n",
- file, err);
+ err = spl_load_image_ext(spl_image, bootdev, block_dev,
+ partition, file);
+ if (err != 0) {
+ puts("spl: falling back to default\n");
goto defaults;
}
- file = env_get("falcon_image_file");
+
+ ext4fs_set_blk_dev(block_dev, &part_info);
+ ext4fs_mount();
+ file = env_get("falcon_args_file");
if (file) {
- err = spl_load_image_ext(spl_image, bootdev, block_dev,
- partition, file);
- if (err != 0) {
- puts("spl: falling back to default\n");
+ err = ext4fs_open(file, &filelen);
+ if (err < 0) {
+ puts("spl: ext4fs_open failed\n");
+ goto defaults;
+ }
+ err = ext4fs_read((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR,
+ 0, filelen, &actlen);
+ if (err < 0) {
+ printf("spl: error reading args %s, err - %d, falling back to default\n",
+ file, err);
goto defaults;
}
-
return 0;
} else {
- puts("spl: falcon_image_file not set in environment, falling back to default\n");
+ puts("spl: falcon_args_file not set in environment, falling back to default\n");
}
} else {
- puts("spl: falcon_args_file not set in environment, falling back to default\n");
+ puts("spl: falcon_image_file not set in environment, falling back to default\n");
}
defaults:
-#endif
+ err = spl_load_image_ext(spl_image, bootdev, block_dev, partition,
+ CONFIG_SPL_FS_LOAD_KERNEL_NAME);
+
+ if (err)
+ return err;
+
+ ext4fs_set_blk_dev(block_dev, &part_info);
+ ext4fs_mount();
err = ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME, &filelen);
if (err < 0)
puts("spl: ext4fs_open failed\n");
err = ext4fs_read((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0, filelen, &actlen);
if (err < 0) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: error reading image %s, err - %d\n",
__func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
-#endif
return -1;
}
- return spl_load_image_ext(spl_image, bootdev, block_dev, partition,
- CONFIG_SPL_FS_LOAD_KERNEL_NAME);
+ return 0;
}
#else
int spl_load_image_ext_os(struct spl_image_info *spl_image,
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 8b7cafa7291..dc52bd13cec 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -34,9 +34,7 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
err = fat_register_device(block_dev, partition);
if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: fat register err - %d\n", __func__, err);
-#endif
return err;
}
@@ -98,11 +96,9 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
err = spl_load(spl_image, bootdev, &load, size, 0);
end:
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
if (err < 0)
printf("%s: error reading image %s, err - %d\n",
__func__, filename, err);
-#endif
return err;
}
@@ -119,45 +115,50 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
if (err)
return err;
-#if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
- file = env_get("falcon_args_file");
+ if (!CONFIG_IS_ENABLED(ENV_SUPPORT))
+ goto defaults;
+
+ file = env_get("falcon_image_file");
if (file) {
- err = file_fat_read(file, (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0);
- if (err <= 0) {
- printf("spl: error reading image %s, err - %d, falling back to default\n",
- file, err);
+ err = spl_load_image_fat(spl_image, bootdev, block_dev,
+ partition, file);
+ if (err != 0) {
+ puts("spl: falling back to default\n");
goto defaults;
}
- file = env_get("falcon_image_file");
+
+ file = env_get("falcon_args_file");
if (file) {
- err = spl_load_image_fat(spl_image, bootdev, block_dev,
- partition, file);
- if (err != 0) {
- puts("spl: falling back to default\n");
+ err = file_fat_read(
+ file, (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0);
+ if (err <= 0) {
+ printf("spl: error reading args %s, err - %d, falling back to default\n",
+ file, err);
goto defaults;
}
-
return 0;
} else
- puts("spl: falcon_image_file not set in environment, falling back to default\n");
+ puts("spl: falcon_args_file not set in environment, falling back to default\n");
} else
- puts("spl: falcon_args_file not set in environment, falling back to default\n");
+ puts("spl: falcon_image_file not set in environment, falling back to default\n");
defaults:
-#endif
+
+ err = spl_load_image_fat(spl_image, bootdev, block_dev, partition,
+ CONFIG_SPL_FS_LOAD_KERNEL_NAME);
+
+ if (err)
+ return err;
err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME,
(void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0);
if (err <= 0) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: error reading image %s, err - %d\n",
__func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
-#endif
return -1;
}
- return spl_load_image_fat(spl_image, bootdev, block_dev, partition,
- CONFIG_SPL_FS_LOAD_KERNEL_NAME);
+ return 0;
}
#else
int spl_load_image_fat_os(struct spl_image_info *spl_image,
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 25f3c822a49..746c3d2fa28 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -353,7 +353,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
}
length = loadEnd - CONFIG_SYS_LOAD_ADDR;
} else {
- memcpy(load_ptr, src, length);
+ memmove(load_ptr, src, length);
}
if (image_info) {
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index d06f9f0dee6..cd56cf71055 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -152,6 +152,16 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
{
int ret;
+ ret = mmc_load_image_raw_sector(spl_image, bootdev, mmc,
+ CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
+ if (ret)
+ return ret;
+
+ if (spl_image->os != IH_OS_LINUX && spl_image->os != IH_OS_TEE) {
+ puts("Expected image is not found. Trying to start U-Boot\n");
+ return -ENOENT;
+ }
+
#if defined(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)
unsigned long count;
@@ -165,16 +175,6 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
}
#endif /* CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR */
- ret = mmc_load_image_raw_sector(spl_image, bootdev, mmc,
- CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
- if (ret)
- return ret;
-
- if (spl_image->os != IH_OS_LINUX && spl_image->os != IH_OS_TEE) {
- puts("Expected image is not found. Trying to start U-Boot\n");
- return -ENOENT;
- }
-
return 0;
}
#else
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 67fc620d9be..09f94e662fc 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -14,10 +14,12 @@
#include <errno.h>
#include <fat.h>
#include <image.h>
+#include <linux/compiler.h>
-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)
+static int __maybe_unused 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 legacy_img_hdr *header;
unsigned long count;