cmd: simplify command efidebug
[platform/kernel/u-boot.git] / cmd / ximg.c
index 9e53cc4..1c40fd2 100644 (file)
  */
 #include <common.h>
 #include <command.h>
+#include <cpu_func.h>
+#include <env.h>
+#include <gzip.h>
 #include <image.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <watchdog.h>
 #if defined(CONFIG_BZIP2)
 #include <bzlib.h>
 #endif
 #include <asm/byteorder.h>
+#include <asm/cache.h>
 #include <asm/io.h>
 
 #ifndef CONFIG_SYS_XIMG_LEN
 #endif
 
 static int
-do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-       ulong           addr = load_addr;
+       ulong           addr = image_load_addr;
        ulong           dest = 0;
        ulong           data, len;
        int             verify;
        int             part = 0;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
        ulong           count;
-       image_header_t  *hdr = NULL;
+       struct legacy_img_hdr   *hdr = NULL;
 #endif
 #if defined(CONFIG_FIT)
        const char      *uname = NULL;
@@ -54,16 +59,16 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
        verify = env_get_yesno("verify");
 
        if (argc > 1) {
-               addr = simple_strtoul(argv[1], NULL, 16);
+               addr = hextoul(argv[1], NULL);
        }
        if (argc > 2) {
-               part = simple_strtoul(argv[2], NULL, 16);
+               part = hextoul(argv[2], NULL);
 #if defined(CONFIG_FIT)
                uname = argv[2];
 #endif
        }
        if (argc > 3) {
-               dest = simple_strtoul(argv[3], NULL, 16);
+               dest = hextoul(argv[3], NULL);
        }
 
        switch (genimg_get_format((void *)addr)) {
@@ -73,7 +78,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
                printf("## Copying part %d from legacy image "
                        "at %08lx ...\n", part, addr);
 
-               hdr = (image_header_t *)addr;
+               hdr = (struct legacy_img_hdr *)addr;
                if (!image_check_magic(hdr)) {
                        printf("Bad Magic Number\n");
                        return 1;
@@ -131,7 +136,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
                        "at %08lx ...\n", uname, addr);
 
                fit_hdr = (const void *)addr;
-               if (!fit_check_format(fit_hdr)) {
+               if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
                        puts("Bad FIT image format\n");
                        return 1;
                }
@@ -166,11 +171,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
                        return 1;
                }
 
-               if (fit_image_get_comp(fit_hdr, noffset, &comp)) {
-                       puts("Could not find script subimage "
-                               "compression type\n");
-                       return 1;
-               }
+               if (fit_image_get_comp(fit_hdr, noffset, &comp))
+                       comp = IH_COMP_NONE;
 
                data = (ulong)fit_data;
                len = (ulong)fit_len;
@@ -195,7 +197,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 
                                while (l > 0) {
                                        tail = (l > CHUNKSZ) ? CHUNKSZ : l;
-                                       WATCHDOG_RESET();
+                                       schedule();
                                        memmove(to, from, tail);
                                        to += tail;
                                        from += tail;