From 957222d7c6d442056246b2c55b5b32e110e22fa5 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Fri, 27 Mar 2020 18:03:48 +0800 Subject: [PATCH] common: image: support IMAGE_PARAM_INVAL as placeholder address flag User maybe not want to set a fixed address, leave it to U-Boot. This is a compatible method for different board and platforms. Signed-off-by: Joseph Chen Change-Id: I01accbc0f116856276610bfaea8de2f7e1275bb0 --- common/image.c | 20 ++++++++++++++++++++ include/image.h | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/common/image.c b/common/image.c index 3d159945d3..4134ac80d7 100644 --- a/common/image.c +++ b/common/image.c @@ -192,6 +192,26 @@ static const struct table_info table_info[IH_COUNT] = { /*****************************************************************************/ /* Legacy format routines */ /*****************************************************************************/ +#ifndef USE_HOSTCC +#ifndef CONFIG_SPL_BUILD +uint32_t image_get_load(const image_header_t *hdr) +{ + uint32_t load = uimage_to_cpu(hdr->ih_load); + + return (load == IMAGE_PARAM_INVAL) ? + env_get_ulong("kernel_addr_r", 16, 0) : load; +} + +uint32_t image_get_ep(const image_header_t *hdr) +{ + uint32_t ep = uimage_to_cpu(hdr->ih_ep); + + return (ep == IMAGE_PARAM_INVAL) ? + env_get_ulong("kernel_addr_r", 16, 0) : ep; +} +#endif +#endif + int image_check_hcrc(const image_header_t *hdr) { ulong hcrc; diff --git a/include/image.h b/include/image.h index 56bd0dade0..a2d008f35b 100644 --- a/include/image.h +++ b/include/image.h @@ -725,9 +725,17 @@ image_get_hdr_l(magic) /* image_get_magic */ image_get_hdr_l(hcrc) /* image_get_hcrc */ image_get_hdr_l(time) /* image_get_time */ image_get_hdr_l(size) /* image_get_size */ +image_get_hdr_l(dcrc) /* image_get_dcrc */ +#ifdef USE_HOSTCC image_get_hdr_l(load) /* image_get_load */ image_get_hdr_l(ep) /* image_get_ep */ -image_get_hdr_l(dcrc) /* image_get_dcrc */ +#elif defined(CONFIG_SPL_BUILD) +image_get_hdr_l(load) /* image_get_load */ +image_get_hdr_l(ep) /* image_get_ep */ +#else +uint32_t image_get_load(const image_header_t *hdr); +uint32_t image_get_ep(const image_header_t *hdr); +#endif #define image_get_hdr_b(f) \ static inline uint8_t image_get_##f(const image_header_t *hdr) \