summaryrefslogtreecommitdiff
path: root/common/image-fit.c
diff options
context:
space:
mode:
authorAndreas Dannenberg <dannenberg@ti.com>2016-07-27 17:12:39 (GMT)
committerTom Rini <trini@konsulko.com>2016-08-12 13:22:18 (GMT)
commiteba3fbd6a12b1c4a75c24135535075f0d0fb8074 (patch)
treec6749d26585cd6448d764872fb606bfad99c1c40 /common/image-fit.c
parentb25732c22beccb5a2ce3ec4174ea084ba0e176ab (diff)
downloadu-boot-eba3fbd6a12b1c4a75c24135535075f0d0fb8074.tar.xz
common: image: Add support for post-processing of images
This commit allows injecting a board/platform/device-specific post- processing function into the FIT image data loading process, which can include modifying the size and altering the starting source address of an image data artifact. This might be desired to do things like strip headers or footers attached to the images before they were packaged into the FIT, or to perform operations such as decryption or authentication. Introduce new configuration option CONFIG_FIT_IMAGE_POST_PROCESS to allow controlling this feature. If enabled, a platform-specific post- process function must be provided. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/image-fit.c')
-rw-r--r--common/image-fit.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/common/image-fit.c b/common/image-fit.c
index 73ad34e..d8d4e95 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -11,9 +11,9 @@
#ifdef USE_HOSTCC
#include "mkimage.h"
-#include <image.h>
#include <time.h>
#else
+#include <linux/compiler.h>
#include <common.h>
#include <errno.h>
#include <mapmem.h>
@@ -21,6 +21,7 @@
DECLARE_GLOBAL_DATA_PTR;
#endif /* !USE_HOSTCC*/
+#include <image.h>
#include <bootstage.h>
#include <u-boot/crc.h>
#include <u-boot/md5.h>
@@ -1507,6 +1508,12 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
static int fit_image_select(const void *fit, int rd_noffset, int verify)
{
+#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS)
+ const void *data;
+ size_t size;
+ int ret;
+#endif
+
fit_image_print(fit, rd_noffset, " ");
if (verify) {
@@ -1518,6 +1525,23 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
puts("OK\n");
}
+#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS)
+ ret = fit_image_get_data(fit, rd_noffset, &data, &size);
+ if (ret)
+ return ret;
+
+ /* perform any post-processing on the image data */
+ board_fit_image_post_process((void **)&data, &size);
+
+ /*
+ * update U-Boot's understanding of the "data" property start address
+ * and size according to the performed post-processing
+ */
+ ret = fdt_setprop((void *)fit, rd_noffset, FIT_DATA_PROP, data, size);
+ if (ret)
+ return ret;
+#endif
+
return 0;
}