diff options
Diffstat (limited to 'lib_microblaze/microblaze_linux.c')
-rw-r--r-- | lib_microblaze/microblaze_linux.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/lib_microblaze/microblaze_linux.c b/lib_microblaze/microblaze_linux.c index 68b58d4..7cd9799 100644 --- a/lib_microblaze/microblaze_linux.c +++ b/lib_microblaze/microblaze_linux.c @@ -48,32 +48,24 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], char *commandline = getenv ("bootargs"); int i; - theKernel = (void (*)(char *))ntohl (hdr->ih_ep); + theKernel = (void (*)(char *))image_get_ep (hdr); /* Check if there is an initrd image */ if (argc >= 3) { show_boot_progress (9); addr = simple_strtoul (argv[2], NULL, 16); + hdr = (image_header_t *)addr; printf ("## Loading Ramdisk Image at %08lx ...\n", addr); - /* Copy header so we can blank CRC field for re-calculation */ - memcpy (&header, (char *)addr, sizeof (image_header_t)); - - if (ntohl (hdr->ih_magic) != IH_MAGIC) { + if (!image_check_magic (hdr)) { printf ("Bad Magic Number\n"); show_boot_progress (-10); do_reset (cmdtp, flag, argc, argv); } - data = (ulong) & header; - len = sizeof (image_header_t); - - checksum = ntohl (hdr->ih_hcrc); - hdr->ih_hcrc = 0; - - if (crc32 (0, (char *)data, len) != checksum) { + if (!image_check_magic (hdr)) { printf ("Bad Header Checksum\n"); show_boot_progress (-11); do_reset (cmdtp, flag, argc, argv); @@ -83,15 +75,12 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], print_image_hdr (hdr); - data = addr + sizeof (image_header_t); - len = ntohl (hdr->ih_size); + data = image_get_data (hdr); + len = image_get_data_size (hdr); if (verify) { - ulong csum = 0; - printf (" Verifying Checksum ... "); - csum = crc32 (0, (char *)data, len); - if (csum != ntohl (hdr->ih_dcrc)) { + if (!image_check_dcrc (hdr)) { printf ("Bad Data CRC\n"); show_boot_progress (-12); do_reset (cmdtp, flag, argc, argv); @@ -101,9 +90,9 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], show_boot_progress (11); - if ((hdr->ih_os != IH_OS_LINUX) || - (hdr->ih_arch != IH_CPU_MICROBLAZE) || - (hdr->ih_type != IH_TYPE_RAMDISK)) { + if (!image_check_os (hdr, IH_OS_LINUX) || + !image_check_arch (hdr, IH_ARCH_MICROBLAZE) || + !image_check_type (hdr, IH_TYPE_RAMDISK)) { printf ("No Linux Microblaze Ramdisk Image\n"); show_boot_progress (-13); do_reset (cmdtp, flag, argc, argv); @@ -112,8 +101,8 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], /* * Now check if we have a multifile image */ - } else if ((hdr->ih_type == IH_TYPE_MULTI) && (len_ptr[1])) { - ulong tail = ntohl (len_ptr[0]) % 4; + } else if (image_check_type (hdr, IH_TYPE_MULTI) && (len_ptr[1])) { + ulong tail = image_to_cpu (len_ptr[0]) % 4; show_boot_progress (13); @@ -123,12 +112,12 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], for (i = 1; len_ptr[i]; ++i) data += 4; /* add kernel length, and align */ - data += ntohl (len_ptr[0]); + data += image_to_cpu (len_ptr[0]); if (tail) { data += 4 - tail; } - len = ntohl (len_ptr[1]); + len = image_to_cpu (len_ptr[1]); } else { /* |