summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-10-07 14:09:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-10-07 14:09:21 +0200
commit884f4d47c697b825a7e69fe51d3b409be58da5d0 (patch)
tree24226d1678b57d7a58947fe8899b41facf630878 /scripts
parent656f0370c1a572996fd8c7e284f7052aae89ccb1 (diff)
downloadbarebox-884f4d47c697b825a7e69fe51d3b409be58da5d0.tar.gz
barebox-884f4d47c697b825a7e69fe51d3b409be58da5d0.tar.xz
Revert "image: factorise image printing contents"
This reverts commit d424ce77f5e9295584252452dbd78eea562c9af0.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mkimage.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/scripts/mkimage.c b/scripts/mkimage.c
index 2698aa2c54..fef82c6c9e 100644
--- a/scripts/mkimage.c
+++ b/scripts/mkimage.c
@@ -38,6 +38,8 @@ 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 *);
@@ -253,7 +255,7 @@ NXTARG: ;
}
/* for multi-file images we need the data part, too */
- image_print_contents((image_header_t *)ptr);
+ print_header ((image_header_t *)ptr);
(void) munmap((void *)ptr, sbuf.st_size);
(void) close (ifd);
@@ -379,7 +381,7 @@ NXTARG: ;
image_set_hcrc(hdr, checksum);
- image_print_contents(hdr);
+ print_header (hdr);
(void) munmap((void *)ptr, sbuf.st_size);
@@ -502,6 +504,71 @@ 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(&timestamp));
+ 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));