summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-02-24 20:30:22 +0000
committerSimon Glass <sjg@chromium.org>2013-02-28 19:09:23 -0800
commitd20a40de9db07de1f1f06a79a4da1cdda5379b75 (patch)
tree6d1952a17439f0ffa0fb09882f7a3df2a0e917e1 /include
parentd5b76673a5dfe0b5250baea3c36cdfa7a9fd5230 (diff)
downloadblackbird-obmc-uboot-d20a40de9db07de1f1f06a79a4da1cdda5379b75.tar.gz
blackbird-obmc-uboot-d20a40de9db07de1f1f06a79a4da1cdda5379b75.zip
Roll crc32 into hash infrastructure
Add the CRC32 algorithm to the list of available hashes, and make the crc32 command use hash_command(). Add a new crc32_wd_buf() to make this possible, which puts its result in a buffer rather than returning it as a 32-bit value. Note: For some boards the hash command is not enabled, neither are sha1, sha256 or the verify option. In this case the full hash implementation adds about 500 bytes of overhead. So as a special case, we use #ifdef to select very simple bahaviour in that case. The justification for this is that it is currently a very common case (virtually all boards enable crc32 but only some enable more advanced features). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/hash.h2
-rw-r--r--include/u-boot/crc.h11
2 files changed, 12 insertions, 1 deletions
diff --git a/include/hash.h b/include/hash.h
index 88fa2b5a57..f2b2c4520d 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -22,7 +22,7 @@
#ifndef _HASH_H
#define _HASH_H
-#ifdef CONFIG_SHA1SUM_VERIFY
+#if defined(CONFIG_SHA1SUM_VERIFY) || defined(CONFIG_CRC32_VERIFY)
#define CONFIG_HASH_VERIFY
#endif
diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h
index 07badbfc5a..08e509edb4 100644
--- a/include/u-boot/crc.h
+++ b/include/u-boot/crc.h
@@ -30,4 +30,15 @@ uint32_t crc32 (uint32_t, const unsigned char *, uint);
uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
+/**
+ * crc32_wd_buf - Perform CRC32 on a buffer and return result in buffer
+ *
+ * @input: Input buffer
+ * @ilen: Input buffer length
+ * @output: Place to put checksum result (4 bytes)
+ * @chunk_sz: Trigger watchdog after processing this many bytes
+ */
+void crc32_wd_buf(const unsigned char *input, uint ilen,
+ unsigned char *output, uint chunk_sz);
+
#endif /* _UBOOT_CRC_H */
OpenPOWER on IntegriCloud