summaryrefslogtreecommitdiffstats
path: root/board/mpl/common
diff options
context:
space:
mode:
authorMarian Balakowicz <m8@semihalf.com>2008-01-08 18:14:09 +0100
committerWolfgang Denk <wd@denx.de>2008-02-07 01:12:53 +0100
commitb97a2a0a21f279d66de8a9bdbfe21920968bcb1c (patch)
tree7746eae37d3a468f3471cd303156920637445350 /board/mpl/common
parented29bc4e8142b46b626f67524207b36e43d9aad6 (diff)
downloadblackbird-obmc-uboot-b97a2a0a21f279d66de8a9bdbfe21920968bcb1c.tar.gz
blackbird-obmc-uboot-b97a2a0a21f279d66de8a9bdbfe21920968bcb1c.zip
[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 'board/mpl/common')
-rw-r--r--board/mpl/common/common_util.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c
index 8d4cbe852e..30c6ca9e30 100644
--- a/board/mpl/common/common_util.c
+++ b/board/mpl/common/common_util.c
@@ -57,9 +57,6 @@ extern int mem_test(ulong start, ulong ramsize, int quiet);
extern flash_info_t flash_info[]; /* info for FLASH chips */
-static image_header_t header;
-
-
static int
mpl_prg(uchar *src, ulong size)
{
@@ -77,7 +74,7 @@ mpl_prg(uchar *src, ulong size)
info = &flash_info[0];
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
- if (ntohl(magic[0]) != IH_MAGIC) {
+ if (image_to_cpu (magic[0]) != IH_MAGIC) {
puts("Bad Magic number\n");
return -1;
}
@@ -179,44 +176,39 @@ mpl_prg(uchar *src, ulong size)
static int
mpl_prg_image(uchar *ld_addr)
{
- unsigned long len, checksum;
+ unsigned long len;
uchar *data;
- image_header_t *hdr = &header;
+ image_header_t *hdr = (image_header_t *)ld_addr;
int rc;
- /* Copy header so we can blank CRC field for re-calculation */
- memcpy (&header, (char *)ld_addr, sizeof(image_header_t));
- if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+ if (!image_check_magic (hdr)) {
puts("Bad Magic Number\n");
return 1;
}
print_image_hdr(hdr);
- if (hdr->ih_os != IH_OS_U_BOOT) {
+ if (!image_check_os (hdr, IH_OS_U_BOOT)) {
puts("No U-Boot Image\n");
return 1;
}
- if (hdr->ih_type != IH_TYPE_FIRMWARE) {
+ if (!image_check_type (hdr, IH_TYPE_FIRMWARE)) {
puts("No Firmware Image\n");
return 1;
}
- data = (uchar *)&header;
- len = sizeof(image_header_t);
- checksum = ntohl(hdr->ih_hcrc);
- hdr->ih_hcrc = 0;
- if (crc32 (0, (uchar *)data, len) != checksum) {
+ if (!image_check_hcrc (hdr)) {
puts("Bad Header Checksum\n");
return 1;
}
- data = ld_addr + sizeof(image_header_t);
- len = ntohl(hdr->ih_size);
puts("Verifying Checksum ... ");
- if (crc32 (0, (uchar *)data, len) != ntohl(hdr->ih_dcrc)) {
+ if (!image_check_dcrc (hdr)) {
puts("Bad Data CRC\n");
return 1;
}
puts("OK\n");
- if (hdr->ih_comp != IH_COMP_NONE) {
+ data = (uchar *)image_get_data (hdr);
+ len = image_get_data_size (hdr);
+
+ if (image_get_comp (hdr) != IH_COMP_NONE) {
uchar *buf;
/* reserve space for uncompressed image */
if ((buf = malloc(IMAGE_SIZE)) == NULL) {
@@ -224,7 +216,7 @@ mpl_prg_image(uchar *ld_addr)
return 1;
}
- switch (hdr->ih_comp) {
+ switch (image_get_comp (hdr)) {
case IH_COMP_GZIP:
puts("Uncompressing (GZIP) ... ");
rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len);
@@ -253,7 +245,8 @@ mpl_prg_image(uchar *ld_addr)
break;
#endif
default:
- printf ("Unimplemented compression type %d\n", hdr->ih_comp);
+ printf ("Unimplemented compression type %d\n",
+ image_get_comp (hdr));
free(buf);
return 1;
}
OpenPOWER on IntegriCloud