From: wdenk Date: Mon, 30 Oct 2000 13:02:28 +0000 (+0000) Subject: Made "iminfo" work with default load address, too. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bf10409362035680a4060f762b979d26f334f8cc;p=users%2Frw%2Fppcboot.git Made "iminfo" work with default load address, too. --- diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 0e51418..c127ee6 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -37,6 +37,7 @@ void run_default_command (int len, cmd_tbl_t *cmdtp, bd_t *bd, int flag); static void *zalloc(void *, unsigned, unsigned); static void zfree(void *, void *, unsigned); +static void image_info (unsigned long addr); static void print_type (image_header_t *hdr); image_header_t header; @@ -333,51 +334,57 @@ void do_bootd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) void do_iminfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { int arg; - ulong addr, data, len, checksum; - image_header_t *hdr = &header; + ulong addr; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + image_info (load_addr); return; - } + } for (arg=1; arg ih_magic != IH_MAGIC) { - printf (" Bad Magic Number\n"); - continue; - } + /* Copy header so we can blank CRC field for re-calculation */ + memcpy (&header, (char *)addr, sizeof(image_header_t)); - data = (ulong)&header; - len = sizeof(image_header_t); + if (hdr->ih_magic != IH_MAGIC) { + printf (" Bad Magic Number\n"); + return; + } - checksum = hdr->ih_hcrc; - hdr->ih_hcrc = 0; + data = (ulong)&header; + len = sizeof(image_header_t); - if (crc32 (0, (char *)data, len) != checksum) { - printf (" Bad Header Checksum\n"); - continue; - } + checksum = hdr->ih_hcrc; + hdr->ih_hcrc = 0; - /* for multi-file images we need the data part, too */ - print_image_hdr ((image_header_t *)addr); + if (crc32 (0, (char *)data, len) != checksum) { + printf (" Bad Header Checksum\n"); + return; + } - data = addr + sizeof(image_header_t); - len = hdr->ih_size; + /* for multi-file images we need the data part, too */ + print_image_hdr ((image_header_t *)addr); - printf (" Verifying Checksum ... "); - if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) { - printf (" Bad Data CRC\n"); - continue; - } - printf ("OK\n"); + data = addr + sizeof(image_header_t); + len = hdr->ih_size; + + printf (" Verifying Checksum ... "); + if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) { + printf (" Bad Data CRC\n"); + return; } + printf ("OK\n"); } #endif /* CFG_CMD_IMI */