]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - tools/mxsimage.c
Merge branch 'master' of git://git.denx.de/u-boot-imx
[karo-tx-uboot.git] / tools / mxsimage.c
index 7bd9deef5f0cca908ea775e9e741647faf90d07f..81c7f2d4c553f525022613d5a223618e1b5aaf15 100644 (file)
@@ -17,8 +17,9 @@
 
 #include <openssl/evp.h>
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include "mxsimage.h"
+#include "pbl_crc32.h"
 #include <image.h>
 
 
@@ -230,29 +231,6 @@ static int sb_aes_reinit(struct sb_image_ctx *ictx, int enc)
        return sb_aes_init(ictx, iv, enc);
 }
 
-/*
- * CRC32
- */
-static uint32_t crc32(uint8_t *data, uint32_t len)
-{
-       const uint32_t poly = 0x04c11db7;
-       uint32_t crc32 = 0xffffffff;
-       unsigned int byte, bit;
-
-       for (byte = 0; byte < len; byte++) {
-               crc32 ^= data[byte] << 24;
-
-               for (bit = 8; bit > 0; bit--) {
-                       if (crc32 & (1UL << 31))
-                               crc32 = (crc32 << 1) ^ poly;
-                       else
-                               crc32 = (crc32 << 1);
-               }
-       }
-
-       return crc32;
-}
-
 /*
  * Debug
  */
@@ -998,7 +976,9 @@ static int sb_build_command_load(struct sb_image_ctx *ictx,
 
        ccmd->load.address      = dest;
        ccmd->load.count        = cctx->length;
-       ccmd->load.crc32        = crc32(cctx->data, cctx->length);
+       ccmd->load.crc32        = pbl_crc32(0,
+                                           (const char *)cctx->data,
+                                           cctx->length);
 
        cctx->size = sizeof(*ccmd) + cctx->length;
 
@@ -1834,7 +1814,9 @@ static int sb_verify_command(struct sb_image_ctx *ictx,
                EVP_DigestUpdate(&ictx->md_ctx, cctx->data, asize);
                sb_aes_crypt(ictx, cctx->data, cctx->data, asize);
 
-               if (ccmd->load.crc32 != crc32(cctx->data, asize)) {
+               if (ccmd->load.crc32 != pbl_crc32(0,
+                                                 (const char *)cctx->data,
+                                                 asize)) {
                        fprintf(stderr,
                                "ERR: SB LOAD command payload CRC32 invalid!\n");
                        return -EINVAL;
@@ -2149,11 +2131,11 @@ static int mxsimage_check_image_types(uint8_t type)
 }
 
 static void mxsimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
 }
 
-int mxsimage_check_params(struct mkimage_params *params)
+int mxsimage_check_params(struct image_tool_params *params)
 {
        if (!params)
                return -1;
@@ -2194,7 +2176,7 @@ static int mxsimage_verify_print_header(char *file, int silent)
 
 char *imagefile;
 static int mxsimage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct sb_boot_image_header *hdr;
 
@@ -2292,7 +2274,7 @@ static int sb_build_image(struct sb_image_ctx *ictx,
        return 0;
 }
 
-static int mxsimage_generate(struct mkimage_params *params,
+static int mxsimage_generate(struct image_tool_params *params,
        struct image_type_params *tparams)
 {
        int ret;
@@ -2338,7 +2320,7 @@ static struct image_type_params mxsimage_params = {
 
 void init_mxs_image_type(void)
 {
-       mkimage_register(&mxsimage_params);
+       register_image_type(&mxsimage_params);
 }
 
 #else