summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2021-08-30 16:05:23 +0300
committerTom Rini <trini@konsulko.com>2021-09-23 21:15:32 +0300
commit270f8710f92fff3911a830b6c0bcb6fd229ccddd (patch)
tree1bc7d5b2e91d9b1a123cc9bee448fb1d33f58c02 /lib
parent37479e65a353d6d5328092c092c8dc7dbcd4d001 (diff)
downloadu-boot-270f8710f92fff3911a830b6c0bcb6fd229ccddd.tar.xz
crc32: Add crc32 implementation using __builtin_aarch64_crc32b
ARMv8.0 has optional crc32 instruction for crc32 calculation. The instruction is mandatory since ARMv8.1. The crc32 calculation is faster using the dedicated instruction, e.g. 1.4 GHz iMX8MN gives: => time crc32 0x50000000 0x2000000 time: 0.126 seconds # crc32 instruction time: 0.213 seconds # software crc32 Add implementation using the compiler builtin wrapper for the crc32 instruction and enable it by default, since we don't support any platforms which do not implement this instruction. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org> [trini: Make crc32_table guarded by CONFIG_ARM64_CRC32] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/crc32.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index f2acc107fe..5a3127e03a 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -84,7 +84,7 @@ static void __efi_runtime make_crc_table(void)
}
crc_table_empty = 0;
}
-#else
+#elif !defined(CONFIG_ARM64_CRC32)
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
@@ -184,6 +184,12 @@ const uint32_t * ZEXPORT get_crc_table()
*/
uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
{
+#ifdef CONFIG_ARM64_CRC32
+ crc = cpu_to_le32(crc);
+ while (len--)
+ crc = __builtin_aarch64_crc32b(crc, *buf++);
+ return le32_to_cpu(crc);
+#else
const uint32_t *tab = crc_table;
const uint32_t *b =(const uint32_t *)buf;
size_t rem_len;
@@ -221,6 +227,7 @@ uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
}
return le32_to_cpu(crc);
+#endif
}
#undef DO_CRC