2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2018-08-27 13:02:44 +02:00
/ *
* Accelerated C R C 3 2 ( C ) u s i n g A A r c h64 C R C i n s t r u c t i o n s
*
* Copyright ( C ) 2 0 1 6 - 2 0 1 8 L i n a r o L t d < a r d . b i e s h e u v e l @linaro.org>
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a l t e r n a t i v e . h >
# include < a s m / a s s e m b l e r . h >
.cpu generic+ c r c
.macro _ _ crc3 2 , c
2018-11-27 18:42:55 +01:00
cmp x2 , #16
b. l t 8 f / / l e s s t h a n 1 6 b y t e s
and x7 , x2 , #0x1f
and x2 , x2 , #~ 0x1f
cbz x7 , 3 2 f / / m u l t i p l e o f 3 2 b y t e s
and x8 , x7 , #0xf
ldp x3 , x4 , [ x1 ]
add x8 , x8 , x1
add x1 , x1 , x7
ldp x5 , x6 , [ x8 ]
2018-08-27 13:02:44 +02:00
CPU_ B E ( r e v x3 , x3 )
CPU_ B E ( r e v x4 , x4 )
2018-11-27 18:42:55 +01:00
CPU_ B E ( r e v x5 , x5 )
CPU_ B E ( r e v x6 , x6 )
tst x7 , #8
crc3 2 \ c \ ( ) x w8 , w0 , x3
csel x3 , x3 , x4 , e q
csel w0 , w0 , w8 , e q
tst x7 , #4
lsr x4 , x3 , #32
crc3 2 \ c \ ( ) w w8 , w0 , w3
csel x3 , x3 , x4 , e q
csel w0 , w0 , w8 , e q
tst x7 , #2
lsr w4 , w3 , #16
crc3 2 \ c \ ( ) h w8 , w0 , w3
csel w3 , w3 , w4 , e q
csel w0 , w0 , w8 , e q
tst x7 , #1
crc3 2 \ c \ ( ) b w8 , w0 , w3
csel w0 , w0 , w8 , e q
tst x7 , #16
crc3 2 \ c \ ( ) x w8 , w0 , x5
crc3 2 \ c \ ( ) x w8 , w8 , x6
csel w0 , w0 , w8 , e q
cbz x2 , 0 f
32 : ldp x3 , x4 , [ x1 ] , #32
sub x2 , x2 , #32
ldp x5 , x6 , [ x1 , #- 16 ]
CPU_ B E ( r e v x3 , x3 )
CPU_ B E ( r e v x4 , x4 )
CPU_ B E ( r e v x5 , x5 )
CPU_ B E ( r e v x6 , x6 )
2018-08-27 13:02:44 +02:00
crc3 2 \ c \ ( ) x w0 , w0 , x3
crc3 2 \ c \ ( ) x w0 , w0 , x4
2018-11-27 18:42:55 +01:00
crc3 2 \ c \ ( ) x w0 , w0 , x5
crc3 2 \ c \ ( ) x w0 , w0 , x6
cbnz x2 , 3 2 b
0 : ret
2018-08-27 13:02:44 +02:00
8 : tbz x2 , #3 , 4 f
ldr x3 , [ x1 ] , #8
CPU_ B E ( r e v x3 , x3 )
crc3 2 \ c \ ( ) x w0 , w0 , x3
4 : tbz x2 , #2 , 2 f
ldr w3 , [ x1 ] , #4
CPU_ B E ( r e v w3 , w3 )
crc3 2 \ c \ ( ) w w0 , w0 , w3
2 : tbz x2 , #1 , 1 f
ldrh w3 , [ x1 ] , #2
CPU_ B E ( r e v16 w3 , w3 )
crc3 2 \ c \ ( ) h w0 , w0 , w3
1 : tbz x2 , #0 , 0 f
ldrb w3 , [ x1 ]
crc3 2 \ c \ ( ) b w0 , w0 , w3
0 : ret
.endm
.align 5
2020-01-06 19:58:17 +00:00
SYM_ F U N C _ S T A R T ( c r c32 _ l e )
2018-08-27 13:02:44 +02:00
alternative_ i f _ n o t A R M 6 4 _ H A S _ C R C 3 2
b c r c32 _ l e _ b a s e
alternative_ e l s e _ n o p _ e n d i f
_ _ crc3 2
2020-01-06 19:58:17 +00:00
SYM_ F U N C _ E N D ( c r c32 _ l e )
2018-08-27 13:02:44 +02:00
.align 5
2020-01-06 19:58:17 +00:00
SYM_ F U N C _ S T A R T ( _ _ c r c32 c _ l e )
2018-08-27 13:02:44 +02:00
alternative_ i f _ n o t A R M 6 4 _ H A S _ C R C 3 2
b _ _ c r c32 c _ l e _ b a s e
alternative_ e l s e _ n o p _ e n d i f
_ _ crc3 2 c
2020-01-06 19:58:17 +00:00
SYM_ F U N C _ E N D ( _ _ c r c32 c _ l e )