diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2010-09-23 21:32:20 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-09-24 08:46:40 +0200 |
commit | d424ce77f5e9295584252452dbd78eea562c9af0 (patch) | |
tree | 8a1ded02eb19e0d41c9738958f33a59e5c8f63f7 /scripts/mkimage.c | |
parent | 0ceafe14be072696eff3e549d8c7b7de8a3e416d (diff) | |
download | barebox-d424ce77f5e9295584252452dbd78eea562c9af0.tar.gz barebox-d424ce77f5e9295584252452dbd78eea562c9af0.tar.xz |
image: factorise image printing contents
before we duplicate it between command/bootm.c and scripts/mkimage.c
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/mkimage.c')
-rw-r--r-- | scripts/mkimage.c | 71 |
1 files changed, 2 insertions, 69 deletions
diff --git a/scripts/mkimage.c b/scripts/mkimage.c index 6cbf80e8c9..def872838b 100644 --- a/scripts/mkimage.c +++ b/scripts/mkimage.c @@ -74,8 +74,6 @@ char *cmdname; static void copy_file (int, const char *, int); static void usage (void); -static void print_header (image_header_t *); -static void print_type (image_header_t *); static int get_table_entry (table_entry_t *, char *, char *); static int get_arch(char *); static int get_comp(char *); @@ -291,7 +289,7 @@ NXTARG: ; } /* for multi-file images we need the data part, too */ - print_header ((image_header_t *)ptr); + image_print_contents((image_header_t *)ptr); (void) munmap((void *)ptr, sbuf.st_size); (void) close (ifd); @@ -417,7 +415,7 @@ NXTARG: ; image_set_hcrc(hdr, checksum); - print_header (hdr); + image_print_contents(hdr); (void) munmap((void *)ptr, sbuf.st_size); @@ -540,71 +538,6 @@ usage () exit (EXIT_FAILURE); } -static void -print_header (image_header_t *hdr) -{ - time_t timestamp; - uint32_t size; - - timestamp = (time_t)image_get_time(hdr); - size = image_get_size(hdr); - - printf ("Image Name: %.*s\n", IH_NMLEN, image_get_name(hdr)); - printf ("Created: %s", ctime(×tamp)); - printf ("Image Type: "); print_type(hdr); - printf ("Data Size: %d Bytes = %.2f kB = %.2f MB\n", - size, (double)size / 1.024e3, (double)size / 1.048576e6 ); - printf ("Load Address: 0x%08X\n", image_get_load(hdr)); - printf ("Entry Point: 0x%08X\n", image_get_ep(hdr)); - - if (image_check_type(hdr, IH_TYPE_MULTI) || - image_check_type(hdr, IH_TYPE_SCRIPT)) { - int i, ptrs; - uint32_t pos; - uint32_t *len_ptr = (uint32_t *) ( - (unsigned long)hdr + image_get_header_size() - ); - - /* determine number of images first (to calculate image offsets) */ - for (i=0; len_ptr[i]; ++i) /* null pointer terminates list */ - ; - ptrs = i; /* null pointer terminates list */ - - pos = image_get_header_size() + ptrs * sizeof(long); - printf ("Contents:\n"); - for (i=0; len_ptr[i]; ++i) { - size = ntohl(len_ptr[i]); - - printf (" Image %d: %8d Bytes = %4d kB = %d MB\n", - i, size, size>>10, size>>20); - if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) { - /* - * the user may need to know offsets - * if planning to do something with - * multiple files - */ - printf (" Offset = %08X\n", pos); - } - /* copy_file() will pad the first files to even word align */ - size += 3; - size &= ~3; - pos += size; - } - } -} - - -static void -print_type (image_header_t *hdr) -{ - printf ("%s %s %s (%s)\n", - image_get_arch_name(image_get_arch(hdr)), - image_get_os_name(image_get_os(hdr)), - image_get_type_name(image_get_type(hdr)), - image_get_comp_name(image_get_comp(hdr)) - ); -} - static int get_arch(char *name) { return (get_table_entry(arch_name, "CPU", name)); |