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;
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 <argc; ++arg) {
addr = simple_strtoul(argv[arg], NULL, 16);
+ image_info (addr);
+ }
+}
- printf ("\n## Checking Image at %08lx ...\n", addr);
+static void image_info (ulong addr)
+{
+ ulong data, len, checksum;
+ image_header_t *hdr = &header;
- /* Copy header so we can blank CRC field for re-calculation */
- memcpy (&header, (char *)addr, sizeof(image_header_t));
+ printf ("\n## Checking Image at %08lx ...\n", addr);
- if (hdr->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 */