* (C) Copyright 2000-2004
* DENX Software Engineering
* Wolfgang Denk, wd@denx.de
- * All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
#include "mkimage.h"
#include <image.h>
-extern int errno;
-
-#ifndef MAP_FAILED
-#define MAP_FAILED (-1)
-#endif
-
extern unsigned long crc32 (unsigned long crc, const char *buf, unsigned int len);
static void copy_file (int, const char *, int);
static void usage (void);
exit (EXIT_FAILURE);
}
- ptr = (unsigned char *)mmap(0, sbuf.st_size,
- PROT_READ, MAP_SHARED, ifd, 0);
- if ((caddr_t)ptr == (caddr_t)-1) {
+ ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, ifd, 0);
+ if (ptr == MAP_FAILED) {
fprintf (stderr, "%s: Can't read %s: %s\n",
cmdname, imagefile, strerror(errno));
exit (EXIT_FAILURE);
if (fdt_check_header (ptr)) {
/* old-style image */
image_verify_header ((char *)ptr, sbuf.st_size);
- image_print_contents_noindent ((image_header_t *)ptr);
+ image_print_contents ((image_header_t *)ptr);
} else {
/* FIT image */
- fit_print_contents_noindent (ptr);
+ fit_print_contents (ptr);
}
(void) munmap((void *)ptr, sbuf.st_size);
exit (EXIT_FAILURE);
}
- ptr = (unsigned char *)mmap(0, sbuf.st_size,
- PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0);
- if (ptr == (unsigned char *)MAP_FAILED) {
+ ptr = mmap(0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0);
+ if (ptr == MAP_FAILED) {
fprintf (stderr, "%s: Can't map %s: %s\n",
cmdname, imagefile, strerror(errno));
exit (EXIT_FAILURE);
image_set_hcrc (hdr, checksum);
- image_print_contents_noindent (hdr);
+ image_print_contents (hdr);
(void) munmap((void *)ptr, sbuf.st_size);
exit (EXIT_FAILURE);
}
- ptr = (unsigned char *)mmap(0, sbuf.st_size,
- PROT_READ, MAP_SHARED, dfd, 0);
- if (ptr == (unsigned char *)MAP_FAILED) {
+ ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, dfd, 0);
+ if (ptr == MAP_FAILED) {
fprintf (stderr, "%s: Can't read %s: %s\n",
cmdname, datafile, strerror(errno));
exit (EXIT_FAILURE);
*/
memcpy (hdr, ptr, sizeof(image_header_t));
- if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+ if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
fprintf (stderr,
"%s: Bad Magic Number: \"%s\" is no valid image\n",
cmdname, imagefile);
data = (char *)hdr;
len = sizeof(image_header_t);
- checksum = ntohl(hdr->ih_hcrc);
- hdr->ih_hcrc = htonl(0); /* clear for re-calculation */
+ checksum = be32_to_cpu(hdr->ih_hcrc);
+ hdr->ih_hcrc = cpu_to_be32(0); /* clear for re-calculation */
if (crc32 (0, data, len) != checksum) {
fprintf (stderr,
data = ptr + sizeof(image_header_t);
len = image_size - sizeof(image_header_t) ;
- if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
+ if (crc32 (0, data, len) != be32_to_cpu(hdr->ih_dcrc)) {
fprintf (stderr,
"%s: ERROR: \"%s\" has corrupted data!\n",
cmdname, imagefile);
exit (EXIT_FAILURE);
}
- ptr = (unsigned char *)mmap (0, sbuf.st_size,
- PROT_READ|PROT_WRITE, MAP_SHARED, tfd, 0);
- if ((caddr_t)ptr == (caddr_t)-1) {
+ ptr = mmap (0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, tfd, 0);
+ if (ptr == MAP_FAILED) {
fprintf (stderr, "%s: Can't read %s: %s\n",
cmdname, tmpfile, strerror(errno));
unlink (tmpfile);