/*-1* Copyright (c) 2017 Michael Tuexen2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*25*/2627#include <machine/asm.h>28#include <sys/elf_common.h>2930.arch_extension crc3132/*33* uint32_t34* armv8_crc32c(uint32_t crc, const unsigned char *buf, unsigned int len)35*/3637ENTRY(armv8_crc32c)38cbz w2, end39tbz x1, #0x0, half_word_aligned40sub w2, w2, 0x141ldr w10, [x1], #0x142crc32cb w0, w0, w1043half_word_aligned:44cmp w2, #0x245b.lo last_byte46tbz x1, #0x1, word_aligned47sub w2, w2, 0x248ldr w10, [x1], #0x249crc32ch w0, w0, w1050word_aligned:51cmp w2, #0x452b.lo last_half_word53tbz x1, #0x2, double_word_aligned54sub w2, w2, 0x455ldr w10, [x1], #0x456crc32cw w0, w0, w1057double_word_aligned:58lsr w9, w2, #0x359cbz w9, last_word60loop:61ldr x10, [x1], #0x862crc32cx w0, w0, x1063subs w9, w9, #164b.ne loop65last_word:66tbz w2, #0x2, last_half_word67ldr w10, [x1], #0x468crc32cw w0, w0, w1069last_half_word:70tbz w2, #0x1, last_byte71ldr w10, [x1], #0x272crc32ch w0, w0, w1073last_byte:74tbz w2, #0x0, end75ldr w10, [x1], #0x176crc32cb w0, w0, w1077end:78ret79END(armv8_crc32c)8081GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)828384