image: Export fit_check_ramdisk()
[platform/kernel/u-boot.git] / common / image.c
index 95498e6..7b48564 100644 (file)
 #include <logbuff.h>
 #endif
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
 #include <rtc.h>
-#endif
 
 #include <environment.h>
 #include <image.h>
 
 #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
-#include <fdt.h>
 #include <libfdt.h>
 #include <fdt_support.h>
 #endif
 
-#if defined(CONFIG_FIT)
 #include <u-boot/md5.h>
 #include <sha1.h>
 
-static int fit_check_ramdisk(const void *fit, int os_noffset,
-               uint8_t arch, int verify);
-#endif
-
 #ifdef CONFIG_CMD_BDI
 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #endif
@@ -75,6 +67,8 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 #include <image.h>
 #endif /* !USE_HOSTCC*/
 
+#include <u-boot/crc.h>
+
 static const table_entry_t uimage_arch[] = {
        {       IH_ARCH_INVALID,        NULL,           "Invalid ARCH", },
        {       IH_ARCH_ALPHA,          "alpha",        "Alpha",        },
@@ -107,6 +101,7 @@ static const table_entry_t uimage_os[] = {
 #endif
        {       IH_OS_NETBSD,   "netbsd",       "NetBSD",               },
        {       IH_OS_OSE,      "ose",          "Enea OSE",             },
+       {       IH_OS_PLAN9,    "plan9",        "Plan 9",               },
        {       IH_OS_RTEMS,    "rtems",        "RTEMS",                },
        {       IH_OS_U_BOOT,   "u-boot",       "U-Boot",               },
 #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC)
@@ -161,12 +156,6 @@ static const table_entry_t uimage_comp[] = {
        {       -1,             "",             "",                     },
 };
 
-uint32_t crc32(uint32_t, const unsigned char *, uint);
-uint32_t crc32_wd(uint32_t, const unsigned char *, uint, uint);
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
-static void genimg_print_time(time_t timestamp);
-#endif
-
 /*****************************************************************************/
 /* Legacy format routines */
 /*****************************************************************************/
@@ -312,10 +301,10 @@ void image_print_contents(const void *ptr)
 #endif
 
        printf("%sImage Name:   %.*s\n", p, IH_NMLEN, image_get_name(hdr));
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
-       printf("%sCreated:      ", p);
-       genimg_print_time((time_t)image_get_time(hdr));
-#endif
+       if (IMAGE_ENABLE_TIMESTAMP) {
+               printf("%sCreated:      ", p);
+               genimg_print_time((time_t)image_get_time(hdr));
+       }
        printf("%sImage Type:   ", p);
        image_print_type(hdr);
        printf("%sData Size:    ", p);
@@ -524,8 +513,8 @@ void genimg_print_size(uint32_t size)
 #endif
 }
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
-static void genimg_print_time(time_t timestamp)
+#if IMAGE_ENABLE_TIMESTAMP
+void genimg_print_time(time_t timestamp)
 {
 #ifndef USE_HOSTCC
        struct rtc_time tm;
@@ -538,7 +527,7 @@ static void genimg_print_time(time_t timestamp)
        printf("%s", ctime(&timestamp));
 #endif
 }
-#endif /* CONFIG_TIMESTAMP || CONFIG_CMD_DATE || USE_HOSTCC */
+#endif
 
 /**
  * get_table_entry_name - translate entry id to long name
@@ -1911,9 +1900,7 @@ void fit_print_contents(const void *fit)
        int count = 0;
        int ret;
        const char *p;
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
        time_t timestamp;
-#endif
 
 #ifdef USE_HOSTCC
        p = "";
@@ -1929,14 +1916,14 @@ void fit_print_contents(const void *fit)
        else
                printf("%s\n", desc);
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
-       ret = fit_get_timestamp(fit, 0, &timestamp);
-       printf("%sCreated:         ", p);
-       if (ret)
-               printf("unavailable\n");
-       else
-               genimg_print_time(timestamp);
-#endif
+       if (IMAGE_ENABLE_TIMESTAMP) {
+               ret = fit_get_timestamp(fit, 0, &timestamp);
+               printf("%sCreated:         ", p);
+               if (ret)
+                       printf("unavailable\n");
+               else
+                       genimg_print_time(timestamp);
+       }
 
        /* Find images parent node offset */
        images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
@@ -3047,13 +3034,13 @@ int fit_check_format(const void *fit)
                return 0;
        }
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
-       /* mandatory / node 'timestamp' property */
-       if (fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) {
-               debug("Wrong FIT format: no timestamp\n");
-               return 0;
+       if (IMAGE_ENABLE_TIMESTAMP) {
+               /* mandatory / node 'timestamp' property */
+               if (fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) {
+                       debug("Wrong FIT format: no timestamp\n");
+                       return 0;
+               }
        }
-#endif
 
        /* mandatory subimages parent '/images' node */
        if (fdt_path_offset(fit, FIT_IMAGES_PATH) < 0) {
@@ -3372,8 +3359,8 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
  *     0, on failure
  */
 #ifndef USE_HOSTCC
-static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
-                               int verify)
+int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
+                       int verify)
 {
        fit_image_print(fit, rd_noffset, "   ");