diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c index 7c2cbf95e..f690fef44 100644 --- a/arch/arm/lib/armlinux.c +++ b/arch/arm/lib/armlinux.c @@ -212,7 +212,7 @@ int do_bootm_linux(struct image_data *data) void (*theKernel)(int zero, int arch, void *params); image_header_t *os_header = &data->os->header; - if (image_check_type(os_header, IH_TYPE_MULTI)) { + if (image_get_type(os_header) == IH_TYPE_MULTI) { printf("Multifile images not handled at the moment\n"); return -1; } diff --git a/arch/m68k/lib/m68k-linuxboot.c b/arch/m68k/lib/m68k-linuxboot.c index e5e90a872..144d5a30b 100644 --- a/arch/m68k/lib/m68k-linuxboot.c +++ b/arch/m68k/lib/m68k-linuxboot.c @@ -109,7 +109,7 @@ static int do_bootm_linux(struct image_data *data) const char *commandline = getenv ("bootargs"); uint32_t loadaddr,loadsize; - if (image_check_type(os_header, IH_TYPE_MULTI)) { + if (image_get_type(os_header) == IH_TYPE_MULTI) { printf("Multifile images not handled at the moment\n"); return -1; } diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c index 5ee908d13..fc22a8717 100644 --- a/arch/ppc/lib/ppclinux.c +++ b/arch/ppc/lib/ppclinux.c @@ -45,7 +45,7 @@ static int do_bootm_linux(struct image_data *idata) printf("entering %s: os_header: %p initrd_header: %p oftree: %s\n", __FUNCTION__, os_header, initrd_header, idata->oftree); - if (image_check_type(os_header, IH_TYPE_MULTI)) { + if (image_get_type(os_header) == IH_TYPE_MULTI) { unsigned long *data = (unsigned long *)(idata->os->data); unsigned long len1 = 0, len2 = 0; diff --git a/commands/bootm.c b/commands/bootm.c index 83d36d3e2..14475c7ef 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -167,7 +167,7 @@ struct image_handle *map_image(const char *filename, int verify) goto err_out; } - if (image_check_magic(header)) { + if (image_get_magic(header) != IH_MAGIC) { puts ("Bad Magic Number\n"); goto err_out; } @@ -332,7 +332,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[]) os_header = &os_handle->header; - if (image_check_arch(os_header, IH_ARCH)) { + if (image_get_arch(os_header) != IH_ARCH) { printf("Unsupported Architecture 0x%x\n", image_get_arch(os_header)); goto err_out; @@ -350,7 +350,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[]) /* loop through the registered handlers */ list_for_each_entry(handler, &handler_list, list) { - if (image_check_os(os_header, handler->image_type)) { + if (image_get_os(os_header) == handler->image_type) { handler->bootm(&data); printf("handler returned!\n"); goto err_out; @@ -409,7 +409,7 @@ static int image_info (ulong addr) /* Copy header so we can blank CRC field for re-calculation */ memmove (&header, (char *)addr, image_get_header_size()); - if (image_check_magic(hdr)) { + if (image_get_magic(hdr) != IH_MAGIC) { puts (" Bad Magic Number\n"); return 1; } diff --git a/common/image.c b/common/image.c index 104446a78..a4c8b9521 100644 --- a/common/image.c +++ b/common/image.c @@ -266,6 +266,7 @@ void image_print_contents(const void *ptr) { const image_header_t *hdr = (const image_header_t *)ptr; const char *p; + int type; #ifdef __BAREBOX__ p = " "; @@ -285,8 +286,8 @@ void image_print_contents(const void *ptr) printf ("%sLoad Address: %08x\n", p, image_get_load(hdr)); printf ("%sEntry Point: %08x\n", p, image_get_ep(hdr)); - if (image_check_type(hdr, IH_TYPE_MULTI) || - image_check_type(hdr, IH_TYPE_SCRIPT)) { + type = image_get_type(hdr); + if (type == IH_TYPE_MULTI || type == IH_TYPE_SCRIPT) { int i; ulong data, len; ulong count = image_multi_count(hdr); @@ -298,7 +299,7 @@ void image_print_contents(const void *ptr) printf("%s Image %d: ", p, i); image_print_size(len); - if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) { + if (image_get_type(hdr) != IH_TYPE_SCRIPT && i > 0) { /* * the user may need to know offsets * if planning to do something with diff --git a/include/image.h b/include/image.h index 2c5956d60..a42d06bc3 100644 --- a/include/image.h +++ b/include/image.h @@ -320,61 +320,6 @@ static inline void image_set_name(image_header_t *hdr, const char *name) strncpy(image_get_name(hdr), name, IH_NMLEN); } -static inline int image_check_magic(const image_header_t *hdr) -{ - return (image_get_magic(hdr) == IH_MAGIC); -} -static inline int image_check_type(const image_header_t *hdr, uint8_t type) -{ - return (image_get_type(hdr) == type); -} -static inline int image_check_arch(const image_header_t *hdr, uint8_t arch) -{ - return (image_get_arch(hdr) == arch); -} -static inline int image_check_os(const image_header_t *hdr, uint8_t os) -{ - return (image_get_os(hdr) == os); -} - -#ifdef __BAREBOX__ -static inline int image_check_target_arch(const image_header_t *hdr) -{ -#if defined(__ARM__) - if (!image_check_arch(hdr, IH_ARCH_ARM)) -#elif defined(__avr32__) - if (!image_check_arch(hdr, IH_ARCH_AVR32)) -#elif defined(__bfin__) - if (!image_check_arch(hdr, IH_ARCH_BLACKFIN)) -#elif defined(__I386__) - if (!image_check_arch(hdr, IH_ARCH_I386)) -#elif defined(__m68k__) - if (!image_check_arch(hdr, IH_ARCH_M68K)) -#elif defined(__microblaze__) - if (!image_check_arch(hdr, IH_ARCH_MICROBLAZE)) -#elif defined(__mips__) - if (!image_check_arch(hdr, IH_ARCH_MIPS)) -#elif defined(__nios__) - if (!image_check_arch(hdr, IH_ARCH_NIOS)) -#elif defined(__nios2__) - if (!image_check_arch(hdr, IH_ARCH_NIOS2)) -#elif defined(__PPC__) - if (!image_check_arch(hdr, IH_ARCH_PPC)) -#elif defined(__sh__) - if (!image_check_arch(hdr, IH_ARCH_SH)) -#elif defined(__sparc__) - if (!image_check_arch(hdr, IH_ARCH_SPARC)) -#elif defined(CONFIG_LINUX) - if (!image_check_arch(hdr, IH_ARCH_LINUX)) -#else -# error Unknown CPU type -#endif - return 0; - - return 1; -} -#endif - ulong image_multi_count(const image_header_t *hdr); void image_multi_getimg(const image_header_t *hdr, ulong idx, ulong *data, ulong *len); diff --git a/scripts/mkimage.c b/scripts/mkimage.c index f6cbb1c4c..40a348313 100644 --- a/scripts/mkimage.c +++ b/scripts/mkimage.c @@ -224,7 +224,7 @@ NXTARG: ; */ memcpy (hdr, ptr, sizeof(image_header_t)); - if (image_check_magic(hdr)) { + if (image_get_magic(hdr) != IH_MAGIC) { fprintf (stderr, "%s: Bad Magic Number: \"%s\" is no valid image\n", cmdname, imagefile);