From b97a2a0a21f279d66de8a9bdbfe21920968bcb1c Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Tue, 8 Jan 2008 18:14:09 +0100 Subject: [new uImage] Define a API for image handling operations - Add inline helper macros for basic header processing - Move common non inline code common/image.c - Replace direct header access with the API routines - Rename IH_CPU_* to IH_ARCH_* Signed-off-by: Marian Balakowicz --- common/cmd_autoscript.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'common/cmd_autoscript.c') diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c index a6038a6..3e68ced 100644 --- a/common/cmd_autoscript.c +++ b/common/cmd_autoscript.c @@ -49,56 +49,44 @@ #if defined(CONFIG_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT) -extern image_header_t header; /* from cmd_bootm.c */ int autoscript (ulong addr) { - ulong crc, data, len; - image_header_t *hdr = &header; + ulong len; + image_header_t *hdr = (image_header_t *)addr; ulong *len_ptr; char *cmd; int rcode = 0; int verify; - cmd = getenv ("verify"); - verify = (cmd && (*cmd == 'n')) ? 0 : 1; + verify = getenv_verify (); - - memmove (hdr, (char *)addr, sizeof(image_header_t)); - - if (ntohl(hdr->ih_magic) != IH_MAGIC) { + if (!image_check_magic (hdr)) { puts ("Bad magic number\n"); return 1; } - crc = ntohl(hdr->ih_hcrc); - hdr->ih_hcrc = 0; - len = sizeof (image_header_t); - data = (ulong)hdr; - if (crc32(0, (uchar *)data, len) != crc) { + if (!image_check_hcrc (hdr)) { puts ("Bad header crc\n"); return 1; } - data = addr + sizeof(image_header_t); - len = ntohl(hdr->ih_size); - if (verify) { - if (crc32(0, (uchar *)data, len) != ntohl(hdr->ih_dcrc)) { + if (!image_check_dcrc (hdr)) { puts ("Bad data crc\n"); return 1; } } - if (hdr->ih_type != IH_TYPE_SCRIPT) { + if (!image_check_type (hdr, IH_TYPE_SCRIPT)) { puts ("Bad image type\n"); return 1; } /* get length of script */ - len_ptr = (ulong *)data; + len_ptr = (ulong *)image_get_data (hdr); - if ((len = ntohl(*len_ptr)) == 0) { + if ((len = image_to_cpu (*len_ptr)) == 0) { puts ("Empty Script\n"); return 1; } -- cgit v1.1