image-fit: fix fit_image_load() OS check
[oweals/u-boot.git] / common / image-fit.c
index 73ad34e491ba2fdeccaa3de11b6e4f8440bea122..f833fe32cee566b662775b3eb1d9d227a6736391 100644 (file)
@@ -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;
 }
 
@@ -1688,7 +1712,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
                  (image_type == IH_TYPE_KERNEL &&
                   fit_image_check_type(fit, noffset, IH_TYPE_KERNEL_NOLOAD));
 
-       os_ok = image_type == IH_TYPE_FLATDT || IH_TYPE_FPGA ||
+       os_ok = image_type == IH_TYPE_FLATDT ||
+               image_type == IH_TYPE_FPGA ||
                fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
                fit_image_check_os(fit, noffset, IH_OS_U_BOOT) ||
                fit_image_check_os(fit, noffset, IH_OS_OPENRTOS);