mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 13:56:20 +00:00
spl: Convert nor to spl_load
This converts the nor load method to use spl_load. As a result it also adds support for LOAD_FIT_FULL. Since this is the last caller of spl_load_legacy_img, it has been removed. We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NOR_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
2e5476b5a7
commit
cbe86576cb
4 changed files with 10 additions and 94 deletions
|
@ -118,64 +118,3 @@ int spl_load_legacy_lzma(struct spl_image_info *spl_image,
|
||||||
spl_image->size = lzma_len;
|
spl_image->size = lzma_len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This function is added explicitly to avoid code size increase, when
|
|
||||||
* no compression method is enabled. The compiler will optimize the
|
|
||||||
* following switch/case statement in spl_load_legacy_img() away due to
|
|
||||||
* Dead Code Elimination.
|
|
||||||
*/
|
|
||||||
static inline int spl_image_get_comp(const struct legacy_img_hdr *hdr)
|
|
||||||
{
|
|
||||||
if (IS_ENABLED(CONFIG_SPL_LZMA))
|
|
||||||
return image_get_comp(hdr);
|
|
||||||
|
|
||||||
return IH_COMP_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int spl_load_legacy_img(struct spl_image_info *spl_image,
|
|
||||||
struct spl_boot_device *bootdev,
|
|
||||||
struct spl_load_info *load, ulong offset,
|
|
||||||
struct legacy_img_hdr *hdr)
|
|
||||||
{
|
|
||||||
ulong dataptr;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the payload is compressed, the decompressed data should be
|
|
||||||
* directly write to its load address.
|
|
||||||
*/
|
|
||||||
if (spl_image_get_comp(hdr) != IH_COMP_NONE)
|
|
||||||
spl_image->flags |= SPL_COPY_PAYLOAD_ONLY;
|
|
||||||
|
|
||||||
ret = spl_parse_image_header(spl_image, bootdev, hdr);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* Read image */
|
|
||||||
switch (spl_image_get_comp(hdr)) {
|
|
||||||
case IH_COMP_NONE:
|
|
||||||
dataptr = offset;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Image header will be skipped only if SPL_COPY_PAYLOAD_ONLY
|
|
||||||
* is set
|
|
||||||
*/
|
|
||||||
if (spl_image->flags & SPL_COPY_PAYLOAD_ONLY)
|
|
||||||
dataptr += sizeof(*hdr);
|
|
||||||
|
|
||||||
load->read(load, dataptr, spl_image->size,
|
|
||||||
map_sysmem(spl_image->load_addr, spl_image->size));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IH_COMP_LZMA:
|
|
||||||
return spl_load_legacy_lzma(spl_image, load, offset);
|
|
||||||
|
|
||||||
default:
|
|
||||||
debug("Compression method %s is not supported\n",
|
|
||||||
genimg_get_comp_short_name(image_get_comp(hdr)));
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <imx_container.h>
|
#include <imx_container.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <mapmem.h>
|
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
|
#include <spl_load.h>
|
||||||
|
|
||||||
static ulong spl_nor_load_read(struct spl_load_info *load, ulong sector,
|
static ulong spl_nor_load_read(struct spl_load_info *load, ulong sector,
|
||||||
ulong count, void *buf)
|
ulong count, void *buf)
|
||||||
|
@ -28,8 +28,7 @@ unsigned long __weak spl_nor_get_uboot_base(void)
|
||||||
static int spl_nor_load_image(struct spl_image_info *spl_image,
|
static int spl_nor_load_image(struct spl_image_info *spl_image,
|
||||||
struct spl_boot_device *bootdev)
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
struct legacy_img_hdr *header;
|
struct spl_load_info load;
|
||||||
__maybe_unused struct spl_load_info load;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loading of the payload to SDRAM is done with skipping of
|
* Loading of the payload to SDRAM is done with skipping of
|
||||||
|
@ -43,7 +42,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
|
||||||
* Load Linux from its location in NOR flash to its defined
|
* Load Linux from its location in NOR flash to its defined
|
||||||
* location in SDRAM
|
* location in SDRAM
|
||||||
*/
|
*/
|
||||||
header = (void *)CONFIG_SYS_OS_BASE;
|
const struct legacy_img_hdr *header =
|
||||||
|
(const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE;
|
||||||
#ifdef CONFIG_SPL_LOAD_FIT
|
#ifdef CONFIG_SPL_LOAD_FIT
|
||||||
if (image_get_magic(header) == FDT_MAGIC) {
|
if (image_get_magic(header) == FDT_MAGIC) {
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -93,34 +93,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
|
||||||
* Load real U-Boot from its location in NOR flash to its
|
* Load real U-Boot from its location in NOR flash to its
|
||||||
* defined location in SDRAM
|
* defined location in SDRAM
|
||||||
*/
|
*/
|
||||||
header = map_sysmem(spl_nor_get_uboot_base(), sizeof(*header));
|
|
||||||
#ifdef CONFIG_SPL_LOAD_FIT
|
|
||||||
if (image_get_magic(header) == FDT_MAGIC) {
|
|
||||||
debug("Found FIT format U-Boot\n");
|
|
||||||
spl_set_bl_len(&load, 1);
|
spl_set_bl_len(&load, 1);
|
||||||
load.read = spl_nor_load_read;
|
load.read = spl_nor_load_read;
|
||||||
return spl_load_simple_fit(spl_image, &load,
|
return spl_load(spl_image, bootdev, &load, 0, spl_nor_get_uboot_base());
|
||||||
spl_nor_get_uboot_base(),
|
|
||||||
(void *)header);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
|
|
||||||
valid_container_hdr((void *)header)) {
|
|
||||||
spl_set_bl_len(&load, 1);
|
|
||||||
load.read = spl_nor_load_read;
|
|
||||||
return spl_load_imx_container(spl_image, &load,
|
|
||||||
spl_nor_get_uboot_base());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Legacy image handling */
|
|
||||||
if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT)) {
|
|
||||||
spl_set_bl_len(&load, 1);
|
|
||||||
load.read = spl_nor_load_read;
|
|
||||||
return spl_load_legacy_img(spl_image, bootdev, &load,
|
|
||||||
spl_nor_get_uboot_base(),
|
|
||||||
header);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image);
|
SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image);
|
||||||
|
|
|
@ -100,6 +100,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,
|
||||||
IS_ENABLED(CONFIG_SPL_SYS_MMCSD_RAW_MODE) + \
|
IS_ENABLED(CONFIG_SPL_SYS_MMCSD_RAW_MODE) + \
|
||||||
(IS_ENABLED(CONFIG_SPL_NAND_SUPPORT) && !IS_ENABLED(CONFIG_SPL_UBI)) + \
|
(IS_ENABLED(CONFIG_SPL_NAND_SUPPORT) && !IS_ENABLED(CONFIG_SPL_UBI)) + \
|
||||||
IS_ENABLED(CONFIG_SPL_NET) + \
|
IS_ENABLED(CONFIG_SPL_NET) + \
|
||||||
|
IS_ENABLED(CONFIG_SPL_NOR_SUPPORT) + \
|
||||||
0
|
0
|
||||||
|
|
||||||
#if SPL_LOAD_USERS > 1
|
#if SPL_LOAD_USERS > 1
|
||||||
|
|
|
@ -36,4 +36,6 @@ SPL_IMG_TEST(spl_test_nor, LEGACY, 0);
|
||||||
SPL_IMG_TEST(spl_test_nor, LEGACY_LZMA, 0);
|
SPL_IMG_TEST(spl_test_nor, LEGACY_LZMA, 0);
|
||||||
SPL_IMG_TEST(spl_test_nor, IMX8, 0);
|
SPL_IMG_TEST(spl_test_nor, IMX8, 0);
|
||||||
SPL_IMG_TEST(spl_test_nor, FIT_INTERNAL, 0);
|
SPL_IMG_TEST(spl_test_nor, FIT_INTERNAL, 0);
|
||||||
|
#if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)
|
||||||
SPL_IMG_TEST(spl_test_nor, FIT_EXTERNAL, 0);
|
SPL_IMG_TEST(spl_test_nor, FIT_EXTERNAL, 0);
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue