mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-22 07:01:39 +00:00
Add loads of ntohl() in image header handling
Patch by Steven Scholz, 10 Jun 2005
This commit is contained in:
parent
8ff0208d31
commit
dc013d4640
6 changed files with 20 additions and 17 deletions
|
@ -2,6 +2,9 @@
|
||||||
Changes since U-Boot 1.1.4:
|
Changes since U-Boot 1.1.4:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
* Add loads of ntohl() in image header handling
|
||||||
|
Patch by Steven Scholz, 10 Jun 2005
|
||||||
|
|
||||||
* Switch MPC86xADS and MPC885ADS boards to use cpuclk environment
|
* Switch MPC86xADS and MPC885ADS boards to use cpuclk environment
|
||||||
variable to set clock
|
variable to set clock
|
||||||
Patch by Yuli Barcohen, 05 Jun 2005
|
Patch by Yuli Barcohen, 05 Jun 2005
|
||||||
|
|
|
@ -606,7 +606,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
|
||||||
#endif /* CONFIG_MPC5xxx */
|
#endif /* CONFIG_MPC5xxx */
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep;
|
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong)) ntohl(hdr->ih_ep);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if there is an initrd image
|
* Check if there is an initrd image
|
||||||
|
@ -621,7 +621,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
|
||||||
/* Copy header so we can blank CRC field for re-calculation */
|
/* Copy header so we can blank CRC field for re-calculation */
|
||||||
memmove (&header, (char *)addr, sizeof(image_header_t));
|
memmove (&header, (char *)addr, sizeof(image_header_t));
|
||||||
|
|
||||||
if (hdr->ih_magic != IH_MAGIC) {
|
if (ntohl(hdr->ih_magic) != IH_MAGIC) {
|
||||||
puts ("Bad Magic Number\n");
|
puts ("Bad Magic Number\n");
|
||||||
SHOW_BOOT_PROGRESS (-10);
|
SHOW_BOOT_PROGRESS (-10);
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
@ -630,7 +630,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
|
||||||
data = (ulong)&header;
|
data = (ulong)&header;
|
||||||
len = sizeof(image_header_t);
|
len = sizeof(image_header_t);
|
||||||
|
|
||||||
checksum = hdr->ih_hcrc;
|
checksum = ntohl(hdr->ih_hcrc);
|
||||||
hdr->ih_hcrc = 0;
|
hdr->ih_hcrc = 0;
|
||||||
|
|
||||||
if (crc32 (0, (uchar *)data, len) != checksum) {
|
if (crc32 (0, (uchar *)data, len) != checksum) {
|
||||||
|
@ -644,7 +644,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
|
||||||
print_image_hdr (hdr);
|
print_image_hdr (hdr);
|
||||||
|
|
||||||
data = addr + sizeof(image_header_t);
|
data = addr + sizeof(image_header_t);
|
||||||
len = hdr->ih_size;
|
len = ntohl(hdr->ih_size);
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
ulong csum = 0;
|
ulong csum = 0;
|
||||||
|
@ -670,7 +670,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
|
||||||
csum = crc32 (0, (uchar *)data, len);
|
csum = crc32 (0, (uchar *)data, len);
|
||||||
#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
|
#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
|
||||||
|
|
||||||
if (csum != hdr->ih_dcrc) {
|
if (csum != ntohl(hdr->ih_dcrc)) {
|
||||||
puts ("Bad Data CRC\n");
|
puts ("Bad Data CRC\n");
|
||||||
SHOW_BOOT_PROGRESS (-12);
|
SHOW_BOOT_PROGRESS (-12);
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
@ -902,7 +902,7 @@ do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
|
||||||
cmdline = "";
|
cmdline = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
loader = (void (*)(bd_t *, image_header_t *, char *, char *)) hdr->ih_ep;
|
loader = (void (*)(bd_t *, image_header_t *, char *, char *)) ntohl(hdr->ih_ep);
|
||||||
|
|
||||||
printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
|
printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
|
||||||
(ulong)loader);
|
(ulong)loader);
|
||||||
|
@ -1364,7 +1364,7 @@ do_bootm_rtems (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
image_header_t *hdr = &header;
|
image_header_t *hdr = &header;
|
||||||
void (*entry_point)(bd_t *);
|
void (*entry_point)(bd_t *);
|
||||||
|
|
||||||
entry_point = (void (*)(bd_t *)) hdr->ih_ep;
|
entry_point = (void (*)(bd_t *)) ntohl(hdr->ih_ep);
|
||||||
|
|
||||||
printf ("## Transferring control to RTEMS (at address %08lx) ...\n",
|
printf ("## Transferring control to RTEMS (at address %08lx) ...\n",
|
||||||
(ulong)entry_point);
|
(ulong)entry_point);
|
||||||
|
@ -1387,7 +1387,7 @@ do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
image_header_t *hdr = &header;
|
image_header_t *hdr = &header;
|
||||||
char str[80];
|
char str[80];
|
||||||
|
|
||||||
sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
|
sprintf(str, "%x", ntohl(hdr->ih_ep)); /* write entry-point into string */
|
||||||
setenv("loadaddr", str);
|
setenv("loadaddr", str);
|
||||||
do_bootvx(cmdtp, 0, 0, NULL);
|
do_bootvx(cmdtp, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1400,7 +1400,7 @@ do_bootm_qnxelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
char *local_args[2];
|
char *local_args[2];
|
||||||
char str[16];
|
char str[16];
|
||||||
|
|
||||||
sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
|
sprintf(str, "%x", ntohl(hdr->ih_ep)); /* write entry-point into string */
|
||||||
local_args[0] = argv[0];
|
local_args[0] = argv[0];
|
||||||
local_args[1] = str; /* and provide it via the arguments */
|
local_args[1] = str; /* and provide it via the arguments */
|
||||||
do_bootelf(cmdtp, 0, 2, local_args);
|
do_bootelf(cmdtp, 0, 2, local_args);
|
||||||
|
|
|
@ -250,7 +250,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
|
|
||||||
print_image_hdr (hdr);
|
print_image_hdr (hdr);
|
||||||
|
|
||||||
cnt = (hdr->ih_size + sizeof(image_header_t));
|
cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
|
||||||
cnt -= SECTORSIZE;
|
cnt -= SECTORSIZE;
|
||||||
} else {
|
} else {
|
||||||
puts ("\n** Bad Magic Number **\n");
|
puts ("\n** Bad Magic Number **\n");
|
||||||
|
|
|
@ -836,13 +836,13 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
hdr = (image_header_t *)addr;
|
hdr = (image_header_t *)addr;
|
||||||
if (hdr->ih_magic != IH_MAGIC) {
|
if (ntohl(hdr->ih_magic) != IH_MAGIC) {
|
||||||
printf ("Bad Magic Number\n");
|
printf ("Bad Magic Number\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
print_image_hdr(hdr);
|
print_image_hdr(hdr);
|
||||||
|
|
||||||
imsize= hdr->ih_size+sizeof(image_header_t);
|
imsize= ntohl(hdr->ih_size)+sizeof(image_header_t);
|
||||||
nrofblk=imsize/512;
|
nrofblk=imsize/512;
|
||||||
if((imsize%512)>0)
|
if((imsize%512)>0)
|
||||||
nrofblk++;
|
nrofblk++;
|
||||||
|
|
|
@ -717,7 +717,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
|
cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
|
||||||
cnt -= SECTORSIZE;
|
cnt -= SECTORSIZE;
|
||||||
} else {
|
} else {
|
||||||
printf ("\n** Bad Magic Number 0x%x **\n", hdr->ih_magic);
|
printf ("\n** Bad Magic Number 0x%x **\n", ntohl(hdr->ih_magic));
|
||||||
SHOW_BOOT_PROGRESS (-1);
|
SHOW_BOOT_PROGRESS (-1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
#if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
|
#if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
|
||||||
void lynxkdi_boot ( image_header_t *hdr )
|
void lynxkdi_boot ( image_header_t *hdr )
|
||||||
{
|
{
|
||||||
void (*lynxkdi)(void) = (void(*)(void))hdr->ih_ep;
|
void (*lynxkdi)(void) = (void(*)(void)) ntohl(hdr->ih_ep);
|
||||||
lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020;
|
lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020;
|
||||||
bd_t *kbd;
|
bd_t *kbd;
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
u32 *psz = (u32 *)(hdr->ih_load + 0x0204);
|
u32 *psz = (u32 *)(ntohl(hdr->ih_load) + 0x0204);
|
||||||
|
|
||||||
memset( parms, 0, sizeof(*parms));
|
memset( parms, 0, sizeof(*parms));
|
||||||
kbd = gd->bd;
|
kbd = gd->bd;
|
||||||
|
@ -39,9 +39,9 @@ void lynxkdi_boot ( image_header_t *hdr )
|
||||||
/* Do a simple check for Bluecat so we can pass the
|
/* Do a simple check for Bluecat so we can pass the
|
||||||
* kernel command line parameters.
|
* kernel command line parameters.
|
||||||
*/
|
*/
|
||||||
if( le32_to_cpu(*psz) == hdr->ih_size ){
|
if( le32_to_cpu(*psz) == ntohl(hdr->ih_size) ){ /* FIXME: NOT SURE HERE ! */
|
||||||
char *args;
|
char *args;
|
||||||
char *cmdline = (char *)(hdr->ih_load + 0x020c);
|
char *cmdline = (char *)(ntohl(hdr->ih_load) + 0x020c);
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
printf("Booting Bluecat KDI ...\n");
|
printf("Booting Bluecat KDI ...\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue