Commit dc013d464000635a5b8ae841c6e683f94a6bee3d

Authored by Wolfgang Denk
1 parent 8ff0208d31
Exists in master and in 56 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf_v2022.04, emb_lf_v2023.04, emb_lf_v2024.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

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

... ... @@ -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
... ... @@ -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);
... ... @@ -250,7 +250,7 @@
250 250  
251 251 print_image_hdr (hdr);
252 252  
253   - cnt = (hdr->ih_size + sizeof(image_header_t));
  253 + cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
254 254 cnt -= SECTORSIZE;
255 255 } else {
256 256 puts ("\n** Bad Magic Number **\n");
... ... @@ -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++;
... ... @@ -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 }
... ... @@ -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");