[new uImage] Add dual format uImage support framework

This patch adds framework for dual format images. Format detection is added
and the bootm controll flow is updated to include cases for new FIT format
uImages.

When the legacy (image_header based) format is detected appropriate
legacy specific handling is invoked. For the new (FIT based) format uImages
dual boot framework has a minial support, that will only print out a
corresponding debug messages. Implementation of the FIT specific handling will
be added in following patches.

Signed-off-by: Marian Balakowicz <m8@semihalf.com>
diff --git a/board/cray/L1/L1.c b/board/cray/L1/L1.c
index 8e6d74e..c00acc8 100644
--- a/board/cray/L1/L1.c
+++ b/board/cray/L1/L1.c
@@ -140,6 +140,13 @@
 	char bootcmd[32];
 
 	hdr = (image_header_t *) (CFG_MONITOR_BASE - image_get_header_size ());
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	timestamp = (time_t)image_get_time (hdr);
 	to_tm (timestamp, &tm);
 	printf ("Welcome to U-Boot on Cray L1. Compiled %4d-%02d-%02d  %2d:%02d:%02d (UTC)\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
diff --git a/board/esd/common/auto_update.c b/board/esd/common/auto_update.c
index cb8087b..976707d 100644
--- a/board/esd/common/auto_update.c
+++ b/board/esd/common/auto_update.c
@@ -91,6 +91,12 @@
 	image_header_t *hdr;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	if ((au_image[i].type == AU_FIRMWARE) &&
 	    (au_image[i].size != image_get_data_size (hdr))) {
@@ -118,6 +124,13 @@
 	unsigned long checksum;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* check the easy ones first */
 #undef CHECK_VALID_DEBUG
 #ifdef CHECK_VALID_DEBUG
@@ -183,6 +196,12 @@
 #endif
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	switch (au_image[i].type) {
 	case AU_SCRIPT:
diff --git a/board/mcc200/auto_update.c b/board/mcc200/auto_update.c
index 8b520c8..fcae35a 100644
--- a/board/mcc200/auto_update.c
+++ b/board/mcc200/auto_update.c
@@ -143,6 +143,12 @@
 	image_header_t *hdr;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	if (nbytes != image_get_image_size (hdr)) {
 		printf ("Image %s bad total SIZE\n", aufile[idx]);
@@ -162,6 +168,13 @@
 	unsigned long checksum, fsize;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* check the easy ones first */
 #undef CHECK_VALID_DEBUG
 #ifdef CHECK_VALID_DEBUG
@@ -233,6 +246,12 @@
 	uint nbytes;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	/* execute a script */
 	if (image_check_type (hdr, IH_TYPE_SCRIPT)) {
diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c
index b171ca5..fffd25c 100644
--- a/board/mpl/common/common_util.c
+++ b/board/mpl/common/common_util.c
@@ -181,6 +181,13 @@
 	image_header_t *hdr = (image_header_t *)ld_addr;
 	int rc;
 
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	if (!image_check_magic (hdr)) {
 		puts("Bad Magic Number\n");
 		return 1;
diff --git a/board/siemens/common/fpga.c b/board/siemens/common/fpga.c
index 9d71946..a9a6dfe 100644
--- a/board/siemens/common/fpga.c
+++ b/board/siemens/common/fpga.c
@@ -137,6 +137,13 @@
     char msg[32];
     int verify, i;
 
+#if defined(CONFIG_FIT)
+    if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+	puts ("Non legacy image format not supported\n");
+	return -1;
+    }
+#endif
+
     /*
      * Check the image header and data of the net-list
      */
@@ -333,6 +340,13 @@
 	}
 
 	hdr = (image_header_t *)addr;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+	   puts ("Non legacy image format not supported\n");
+	   return -1;
+	}
+#endif
+
 	if ((new_id = fpga_get_version(fpga, image_get_name (hdr))) == -1)
 	    return 1;
 
diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
index bd9ee0c..8f67535 100644
--- a/board/trab/auto_update.c
+++ b/board/trab/auto_update.c
@@ -211,6 +211,12 @@
 	image_header_t *hdr;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	if (nbytes != image_get_image_size (hdr))
 	{
@@ -234,6 +240,13 @@
 	unsigned char buf[4];
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* check the easy ones first */
 #undef CHECK_VALID_DEBUG
 #ifdef CHECK_VALID_DEBUG
@@ -327,6 +340,12 @@
 	uint nbytes;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	/* disable the power switch */
 	*CPLD_VFD_BK |= POWER_OFF;
@@ -417,6 +436,13 @@
 	}
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* write the time field into EEPROM */
 	off = auee_off[idx].time;
 	val = image_get_time (hdr);