Commit dc013d464000635a5b8ae841c6e683f94a6bee3d
1 parent
8ff0208d31
Exists in
master
and in
56 other branches
Add loads of ntohl() in image header handling
Patch by Steven Scholz, 10 Jun 2005
Showing 6 changed files with 20 additions and 17 deletions Side-by-side Diff
CHANGELOG
... | ... | @@ -2,6 +2,9 @@ |
2 | 2 | Changes since U-Boot 1.1.4: |
3 | 3 | ====================================================================== |
4 | 4 | |
5 | +* Add loads of ntohl() in image header handling | |
6 | + Patch by Steven Scholz, 10 Jun 2005 | |
7 | + | |
5 | 8 | * Switch MPC86xADS and MPC885ADS boards to use cpuclk environment |
6 | 9 | variable to set clock |
7 | 10 | Patch by Yuli Barcohen, 05 Jun 2005 |
common/cmd_bootm.c
... | ... | @@ -606,7 +606,7 @@ |
606 | 606 | #endif /* CONFIG_MPC5xxx */ |
607 | 607 | } |
608 | 608 | |
609 | - kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep; | |
609 | + kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong)) ntohl(hdr->ih_ep); | |
610 | 610 | |
611 | 611 | /* |
612 | 612 | * Check if there is an initrd image |
... | ... | @@ -621,7 +621,7 @@ |
621 | 621 | /* Copy header so we can blank CRC field for re-calculation */ |
622 | 622 | memmove (&header, (char *)addr, sizeof(image_header_t)); |
623 | 623 | |
624 | - if (hdr->ih_magic != IH_MAGIC) { | |
624 | + if (ntohl(hdr->ih_magic) != IH_MAGIC) { | |
625 | 625 | puts ("Bad Magic Number\n"); |
626 | 626 | SHOW_BOOT_PROGRESS (-10); |
627 | 627 | do_reset (cmdtp, flag, argc, argv); |
... | ... | @@ -630,7 +630,7 @@ |
630 | 630 | data = (ulong)&header; |
631 | 631 | len = sizeof(image_header_t); |
632 | 632 | |
633 | - checksum = hdr->ih_hcrc; | |
633 | + checksum = ntohl(hdr->ih_hcrc); | |
634 | 634 | hdr->ih_hcrc = 0; |
635 | 635 | |
636 | 636 | if (crc32 (0, (uchar *)data, len) != checksum) { |
... | ... | @@ -644,7 +644,7 @@ |
644 | 644 | print_image_hdr (hdr); |
645 | 645 | |
646 | 646 | data = addr + sizeof(image_header_t); |
647 | - len = hdr->ih_size; | |
647 | + len = ntohl(hdr->ih_size); | |
648 | 648 | |
649 | 649 | if (verify) { |
650 | 650 | ulong csum = 0; |
... | ... | @@ -670,7 +670,7 @@ |
670 | 670 | csum = crc32 (0, (uchar *)data, len); |
671 | 671 | #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */ |
672 | 672 | |
673 | - if (csum != hdr->ih_dcrc) { | |
673 | + if (csum != ntohl(hdr->ih_dcrc)) { | |
674 | 674 | puts ("Bad Data CRC\n"); |
675 | 675 | SHOW_BOOT_PROGRESS (-12); |
676 | 676 | do_reset (cmdtp, flag, argc, argv); |
... | ... | @@ -902,7 +902,7 @@ |
902 | 902 | cmdline = ""; |
903 | 903 | } |
904 | 904 | |
905 | - loader = (void (*)(bd_t *, image_header_t *, char *, char *)) hdr->ih_ep; | |
905 | + loader = (void (*)(bd_t *, image_header_t *, char *, char *)) ntohl(hdr->ih_ep); | |
906 | 906 | |
907 | 907 | printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n", |
908 | 908 | (ulong)loader); |
... | ... | @@ -1364,7 +1364,7 @@ |
1364 | 1364 | image_header_t *hdr = &header; |
1365 | 1365 | void (*entry_point)(bd_t *); |
1366 | 1366 | |
1367 | - entry_point = (void (*)(bd_t *)) hdr->ih_ep; | |
1367 | + entry_point = (void (*)(bd_t *)) ntohl(hdr->ih_ep); | |
1368 | 1368 | |
1369 | 1369 | printf ("## Transferring control to RTEMS (at address %08lx) ...\n", |
1370 | 1370 | (ulong)entry_point); |
... | ... | @@ -1387,7 +1387,7 @@ |
1387 | 1387 | image_header_t *hdr = &header; |
1388 | 1388 | char str[80]; |
1389 | 1389 | |
1390 | - sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */ | |
1390 | + sprintf(str, "%x", ntohl(hdr->ih_ep)); /* write entry-point into string */ | |
1391 | 1391 | setenv("loadaddr", str); |
1392 | 1392 | do_bootvx(cmdtp, 0, 0, NULL); |
1393 | 1393 | } |
... | ... | @@ -1400,7 +1400,7 @@ |
1400 | 1400 | char *local_args[2]; |
1401 | 1401 | char str[16]; |
1402 | 1402 | |
1403 | - sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */ | |
1403 | + sprintf(str, "%x", ntohl(hdr->ih_ep)); /* write entry-point into string */ | |
1404 | 1404 | local_args[0] = argv[0]; |
1405 | 1405 | local_args[1] = str; /* and provide it via the arguments */ |
1406 | 1406 | do_bootelf(cmdtp, 0, 2, local_args); |
common/cmd_doc.c
common/cmd_fdc.c
... | ... | @@ -836,13 +836,13 @@ |
836 | 836 | return 1; |
837 | 837 | } |
838 | 838 | hdr = (image_header_t *)addr; |
839 | - if (hdr->ih_magic != IH_MAGIC) { | |
839 | + if (ntohl(hdr->ih_magic) != IH_MAGIC) { | |
840 | 840 | printf ("Bad Magic Number\n"); |
841 | 841 | return 1; |
842 | 842 | } |
843 | 843 | print_image_hdr(hdr); |
844 | 844 | |
845 | - imsize= hdr->ih_size+sizeof(image_header_t); | |
845 | + imsize= ntohl(hdr->ih_size)+sizeof(image_header_t); | |
846 | 846 | nrofblk=imsize/512; |
847 | 847 | if((imsize%512)>0) |
848 | 848 | nrofblk++; |
common/cmd_nand.c
... | ... | @@ -717,7 +717,7 @@ |
717 | 717 | cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t)); |
718 | 718 | cnt -= SECTORSIZE; |
719 | 719 | } else { |
720 | - printf ("\n** Bad Magic Number 0x%x **\n", hdr->ih_magic); | |
720 | + printf ("\n** Bad Magic Number 0x%x **\n", ntohl(hdr->ih_magic)); | |
721 | 721 | SHOW_BOOT_PROGRESS (-1); |
722 | 722 | return 1; |
723 | 723 | } |
common/lynxkdi.c
... | ... | @@ -23,11 +23,11 @@ |
23 | 23 | #if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR) |
24 | 24 | void lynxkdi_boot ( image_header_t *hdr ) |
25 | 25 | { |
26 | - void (*lynxkdi)(void) = (void(*)(void))hdr->ih_ep; | |
26 | + void (*lynxkdi)(void) = (void(*)(void)) ntohl(hdr->ih_ep); | |
27 | 27 | lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020; |
28 | 28 | bd_t *kbd; |
29 | 29 | DECLARE_GLOBAL_DATA_PTR; |
30 | - u32 *psz = (u32 *)(hdr->ih_load + 0x0204); | |
30 | + u32 *psz = (u32 *)(ntohl(hdr->ih_load) + 0x0204); | |
31 | 31 | |
32 | 32 | memset( parms, 0, sizeof(*parms)); |
33 | 33 | kbd = gd->bd; |
34 | 34 | |
... | ... | @@ -39,9 +39,9 @@ |
39 | 39 | /* Do a simple check for Bluecat so we can pass the |
40 | 40 | * kernel command line parameters. |
41 | 41 | */ |
42 | - if( le32_to_cpu(*psz) == hdr->ih_size ){ | |
42 | + if( le32_to_cpu(*psz) == ntohl(hdr->ih_size) ){ /* FIXME: NOT SURE HERE ! */ | |
43 | 43 | char *args; |
44 | - char *cmdline = (char *)(hdr->ih_load + 0x020c); | |
44 | + char *cmdline = (char *)(ntohl(hdr->ih_load) + 0x020c); | |
45 | 45 | int len; |
46 | 46 | |
47 | 47 | printf("Booting Bluecat KDI ...\n"); |