diff options
author | Marian Balakowicz <m8@semihalf.com> | 2008-01-08 18:14:09 +0100 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2008-02-07 01:12:53 +0100 |
commit | b97a2a0a21f279d66de8a9bdbfe21920968bcb1c (patch) | |
tree | 7746eae37d3a468f3471cd303156920637445350 /common/cmd_autoscript.c | |
parent | ed29bc4e8142b46b626f67524207b36e43d9aad6 (diff) | |
download | u-boot-imx-b97a2a0a21f279d66de8a9bdbfe21920968bcb1c.zip u-boot-imx-b97a2a0a21f279d66de8a9bdbfe21920968bcb1c.tar.gz u-boot-imx-b97a2a0a21f279d66de8a9bdbfe21920968bcb1c.tar.bz2 |
[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 <m8@semihalf.com>
Diffstat (limited to 'common/cmd_autoscript.c')
-rw-r--r-- | common/cmd_autoscript.c | 30 |
1 files changed, 9 insertions, 21 deletions
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; } |