2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/lib/csumpartialcopygeneric.S
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995-2001 Russell King
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
2014-06-30 23:29:12 +08:00
|
|
|
#include <asm/assembler.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* unsigned int
|
|
|
|
* csum_partial_copy_xxx(const char *src, char *dst, int len, int sum, )
|
|
|
|
* r0 = src, r1 = dst, r2 = len, r3 = sum
|
|
|
|
* Returns : r0 = checksum
|
|
|
|
*
|
|
|
|
* Note that 'tst' and 'teq' preserve the carry flag.
|
|
|
|
*/
|
|
|
|
|
|
|
|
src .req r0
|
|
|
|
dst .req r1
|
|
|
|
len .req r2
|
|
|
|
sum .req r3
|
|
|
|
|
2005-11-12 05:51:49 +08:00
|
|
|
.Lzero: mov r0, sum
|
2006-01-13 00:53:51 +08:00
|
|
|
load_regs
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Align an unaligned destination pointer. We know that
|
|
|
|
* we have >= 8 bytes here, so we don't need to check
|
|
|
|
* the length. Note that the source pointer hasn't been
|
|
|
|
* aligned yet.
|
|
|
|
*/
|
2005-11-12 05:51:49 +08:00
|
|
|
.Ldst_unaligned:
|
|
|
|
tst dst, #1
|
|
|
|
beq .Ldst_16bit
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
load1b ip
|
|
|
|
sub len, len, #1
|
|
|
|
adcs sum, sum, ip, put_byte_1 @ update checksum
|
|
|
|
strb ip, [dst], #1
|
|
|
|
tst dst, #2
|
2014-06-30 23:29:12 +08:00
|
|
|
reteq lr @ dst is now 32bit aligned
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-12 05:51:49 +08:00
|
|
|
.Ldst_16bit: load2b r8, ip
|
2005-04-17 06:20:36 +08:00
|
|
|
sub len, len, #2
|
|
|
|
adcs sum, sum, r8, put_byte_0
|
|
|
|
strb r8, [dst], #1
|
|
|
|
adcs sum, sum, ip, put_byte_1
|
|
|
|
strb ip, [dst], #1
|
2014-06-30 23:29:12 +08:00
|
|
|
ret lr @ dst is now 32bit aligned
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle 0 to 7 bytes, with any alignment of source and
|
|
|
|
* destination pointers. Note that when we get here, C = 0
|
|
|
|
*/
|
2005-11-12 05:51:49 +08:00
|
|
|
.Lless8: teq len, #0 @ check for zero count
|
|
|
|
beq .Lzero
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* we must have at least one byte. */
|
|
|
|
tst dst, #1 @ dst 16-bit aligned
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lless8_aligned
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Align dst */
|
|
|
|
load1b ip
|
|
|
|
sub len, len, #1
|
|
|
|
adcs sum, sum, ip, put_byte_1 @ update checksum
|
|
|
|
strb ip, [dst], #1
|
|
|
|
tst len, #6
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lless8_byteonly
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
1: load2b r8, ip
|
|
|
|
sub len, len, #2
|
|
|
|
adcs sum, sum, r8, put_byte_0
|
|
|
|
strb r8, [dst], #1
|
|
|
|
adcs sum, sum, ip, put_byte_1
|
|
|
|
strb ip, [dst], #1
|
2005-11-12 05:51:49 +08:00
|
|
|
.Lless8_aligned:
|
|
|
|
tst len, #6
|
2005-04-17 06:20:36 +08:00
|
|
|
bne 1b
|
2005-11-12 05:51:49 +08:00
|
|
|
.Lless8_byteonly:
|
2005-04-17 06:20:36 +08:00
|
|
|
tst len, #1
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
load1b r8
|
|
|
|
adcs sum, sum, r8, put_byte_0 @ update checksum
|
|
|
|
strb r8, [dst], #1
|
2005-11-12 05:51:49 +08:00
|
|
|
b .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
FN_ENTRY
|
|
|
|
save_regs
|
|
|
|
|
|
|
|
cmp len, #8 @ Ensure that we have at least
|
2005-11-12 05:51:49 +08:00
|
|
|
blo .Lless8 @ 8 bytes to copy.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
adds sum, sum, #0 @ C = 0
|
|
|
|
tst dst, #3 @ Test destination alignment
|
2005-11-12 05:51:49 +08:00
|
|
|
blne .Ldst_unaligned @ align destination, return here
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ok, the dst pointer is now 32bit aligned, and we know
|
|
|
|
* that we must have more than 4 bytes to copy. Note
|
|
|
|
* that C contains the carry from the dst alignment above.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tst src, #3 @ Test source alignment
|
2005-11-12 05:51:49 +08:00
|
|
|
bne .Lsrc_not_aligned
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Routine for src & dst aligned */
|
|
|
|
|
|
|
|
bics ip, len, #15
|
|
|
|
beq 2f
|
|
|
|
|
|
|
|
1: load4l r4, r5, r6, r7
|
|
|
|
stmia dst!, {r4, r5, r6, r7}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
|
|
|
adcs sum, sum, r6
|
|
|
|
adcs sum, sum, r7
|
|
|
|
sub ip, ip, #16
|
|
|
|
teq ip, #0
|
|
|
|
bne 1b
|
|
|
|
|
|
|
|
2: ands ip, len, #12
|
|
|
|
beq 4f
|
|
|
|
tst ip, #8
|
|
|
|
beq 3f
|
|
|
|
load2l r4, r5
|
|
|
|
stmia dst!, {r4, r5}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
|
|
|
tst ip, #4
|
|
|
|
beq 4f
|
|
|
|
|
|
|
|
3: load1l r4
|
|
|
|
str r4, [dst], #4
|
|
|
|
adcs sum, sum, r4
|
|
|
|
|
|
|
|
4: ands len, len, #3
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
load1l r4
|
|
|
|
tst len, #2
|
|
|
|
mov r5, r4, get_byte_0
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lexit
|
2014-02-25 15:41:09 +08:00
|
|
|
adcs sum, sum, r4, lspush #16
|
2005-04-17 06:20:36 +08:00
|
|
|
strb r5, [dst], #1
|
|
|
|
mov r5, r4, get_byte_1
|
|
|
|
strb r5, [dst], #1
|
|
|
|
mov r5, r4, get_byte_2
|
2005-11-12 05:51:49 +08:00
|
|
|
.Lexit: tst len, #1
|
2019-02-18 07:57:38 +08:00
|
|
|
strbne r5, [dst], #1
|
2005-04-17 06:20:36 +08:00
|
|
|
andne r5, r5, #255
|
2019-02-18 07:57:38 +08:00
|
|
|
adcsne sum, sum, r5, put_byte_0
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the dst pointer was not 16-bit aligned, we
|
|
|
|
* need to rotate the checksum here to get around
|
|
|
|
* the inefficient byte manipulations in the
|
|
|
|
* architecture independent code.
|
|
|
|
*/
|
2005-11-12 05:51:49 +08:00
|
|
|
.Ldone: adc r0, sum, #0
|
2005-04-17 06:20:36 +08:00
|
|
|
ldr sum, [sp, #0] @ dst
|
|
|
|
tst sum, #1
|
|
|
|
movne r0, r0, ror #8
|
2006-01-13 00:53:51 +08:00
|
|
|
load_regs
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-12 05:51:49 +08:00
|
|
|
.Lsrc_not_aligned:
|
2005-04-17 06:20:36 +08:00
|
|
|
adc sum, sum, #0 @ include C from dst alignment
|
|
|
|
and ip, src, #3
|
|
|
|
bic src, src, #3
|
|
|
|
load1l r5
|
|
|
|
cmp ip, #2
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lsrc2_aligned
|
|
|
|
bhi .Lsrc3_aligned
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r5, lspull #8 @ C = 0
|
2005-04-17 06:20:36 +08:00
|
|
|
bics ip, len, #15
|
|
|
|
beq 2f
|
|
|
|
1: load4l r5, r6, r7, r8
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #24
|
|
|
|
mov r5, r5, lspull #8
|
|
|
|
orr r5, r5, r6, lspush #24
|
|
|
|
mov r6, r6, lspull #8
|
|
|
|
orr r6, r6, r7, lspush #24
|
|
|
|
mov r7, r7, lspull #8
|
|
|
|
orr r7, r7, r8, lspush #24
|
2005-04-17 06:20:36 +08:00
|
|
|
stmia dst!, {r4, r5, r6, r7}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
|
|
|
adcs sum, sum, r6
|
|
|
|
adcs sum, sum, r7
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r8, lspull #8
|
2005-04-17 06:20:36 +08:00
|
|
|
sub ip, ip, #16
|
|
|
|
teq ip, #0
|
|
|
|
bne 1b
|
|
|
|
2: ands ip, len, #12
|
|
|
|
beq 4f
|
|
|
|
tst ip, #8
|
|
|
|
beq 3f
|
|
|
|
load2l r5, r6
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #24
|
|
|
|
mov r5, r5, lspull #8
|
|
|
|
orr r5, r5, r6, lspush #24
|
2005-04-17 06:20:36 +08:00
|
|
|
stmia dst!, {r4, r5}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r6, lspull #8
|
2005-04-17 06:20:36 +08:00
|
|
|
tst ip, #4
|
|
|
|
beq 4f
|
|
|
|
3: load1l r5
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #24
|
2005-04-17 06:20:36 +08:00
|
|
|
str r4, [dst], #4
|
|
|
|
adcs sum, sum, r4
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r5, lspull #8
|
2005-04-17 06:20:36 +08:00
|
|
|
4: ands len, len, #3
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
mov r5, r4, get_byte_0
|
|
|
|
tst len, #2
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lexit
|
2014-02-25 15:41:09 +08:00
|
|
|
adcs sum, sum, r4, lspush #16
|
2005-04-17 06:20:36 +08:00
|
|
|
strb r5, [dst], #1
|
|
|
|
mov r5, r4, get_byte_1
|
|
|
|
strb r5, [dst], #1
|
|
|
|
mov r5, r4, get_byte_2
|
2005-11-12 05:51:49 +08:00
|
|
|
b .Lexit
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-02-25 15:41:09 +08:00
|
|
|
.Lsrc2_aligned: mov r4, r5, lspull #16
|
2005-04-17 06:20:36 +08:00
|
|
|
adds sum, sum, #0
|
|
|
|
bics ip, len, #15
|
|
|
|
beq 2f
|
|
|
|
1: load4l r5, r6, r7, r8
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #16
|
|
|
|
mov r5, r5, lspull #16
|
|
|
|
orr r5, r5, r6, lspush #16
|
|
|
|
mov r6, r6, lspull #16
|
|
|
|
orr r6, r6, r7, lspush #16
|
|
|
|
mov r7, r7, lspull #16
|
|
|
|
orr r7, r7, r8, lspush #16
|
2005-04-17 06:20:36 +08:00
|
|
|
stmia dst!, {r4, r5, r6, r7}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
|
|
|
adcs sum, sum, r6
|
|
|
|
adcs sum, sum, r7
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r8, lspull #16
|
2005-04-17 06:20:36 +08:00
|
|
|
sub ip, ip, #16
|
|
|
|
teq ip, #0
|
|
|
|
bne 1b
|
|
|
|
2: ands ip, len, #12
|
|
|
|
beq 4f
|
|
|
|
tst ip, #8
|
|
|
|
beq 3f
|
|
|
|
load2l r5, r6
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #16
|
|
|
|
mov r5, r5, lspull #16
|
|
|
|
orr r5, r5, r6, lspush #16
|
2005-04-17 06:20:36 +08:00
|
|
|
stmia dst!, {r4, r5}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r6, lspull #16
|
2005-04-17 06:20:36 +08:00
|
|
|
tst ip, #4
|
|
|
|
beq 4f
|
|
|
|
3: load1l r5
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #16
|
2005-04-17 06:20:36 +08:00
|
|
|
str r4, [dst], #4
|
|
|
|
adcs sum, sum, r4
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r5, lspull #16
|
2005-04-17 06:20:36 +08:00
|
|
|
4: ands len, len, #3
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
mov r5, r4, get_byte_0
|
|
|
|
tst len, #2
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lexit
|
2005-04-17 06:20:36 +08:00
|
|
|
adcs sum, sum, r4
|
|
|
|
strb r5, [dst], #1
|
|
|
|
mov r5, r4, get_byte_1
|
|
|
|
strb r5, [dst], #1
|
|
|
|
tst len, #1
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
load1b r5
|
2005-11-12 05:51:49 +08:00
|
|
|
b .Lexit
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-02-25 15:41:09 +08:00
|
|
|
.Lsrc3_aligned: mov r4, r5, lspull #24
|
2005-04-17 06:20:36 +08:00
|
|
|
adds sum, sum, #0
|
|
|
|
bics ip, len, #15
|
|
|
|
beq 2f
|
|
|
|
1: load4l r5, r6, r7, r8
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #8
|
|
|
|
mov r5, r5, lspull #24
|
|
|
|
orr r5, r5, r6, lspush #8
|
|
|
|
mov r6, r6, lspull #24
|
|
|
|
orr r6, r6, r7, lspush #8
|
|
|
|
mov r7, r7, lspull #24
|
|
|
|
orr r7, r7, r8, lspush #8
|
2005-04-17 06:20:36 +08:00
|
|
|
stmia dst!, {r4, r5, r6, r7}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
|
|
|
adcs sum, sum, r6
|
|
|
|
adcs sum, sum, r7
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r8, lspull #24
|
2005-04-17 06:20:36 +08:00
|
|
|
sub ip, ip, #16
|
|
|
|
teq ip, #0
|
|
|
|
bne 1b
|
|
|
|
2: ands ip, len, #12
|
|
|
|
beq 4f
|
|
|
|
tst ip, #8
|
|
|
|
beq 3f
|
|
|
|
load2l r5, r6
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #8
|
|
|
|
mov r5, r5, lspull #24
|
|
|
|
orr r5, r5, r6, lspush #8
|
2005-04-17 06:20:36 +08:00
|
|
|
stmia dst!, {r4, r5}
|
|
|
|
adcs sum, sum, r4
|
|
|
|
adcs sum, sum, r5
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r6, lspull #24
|
2005-04-17 06:20:36 +08:00
|
|
|
tst ip, #4
|
|
|
|
beq 4f
|
|
|
|
3: load1l r5
|
2014-02-25 15:41:09 +08:00
|
|
|
orr r4, r4, r5, lspush #8
|
2005-04-17 06:20:36 +08:00
|
|
|
str r4, [dst], #4
|
|
|
|
adcs sum, sum, r4
|
2014-02-25 15:41:09 +08:00
|
|
|
mov r4, r5, lspull #24
|
2005-04-17 06:20:36 +08:00
|
|
|
4: ands len, len, #3
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Ldone
|
2005-04-17 06:20:36 +08:00
|
|
|
mov r5, r4, get_byte_0
|
|
|
|
tst len, #2
|
2005-11-12 05:51:49 +08:00
|
|
|
beq .Lexit
|
2005-04-17 06:20:36 +08:00
|
|
|
strb r5, [dst], #1
|
|
|
|
adcs sum, sum, r4
|
|
|
|
load1l r4
|
|
|
|
mov r5, r4, get_byte_0
|
|
|
|
strb r5, [dst], #1
|
2014-02-25 15:41:09 +08:00
|
|
|
adcs sum, sum, r4, lspush #24
|
2005-04-17 06:20:36 +08:00
|
|
|
mov r5, r4, get_byte_1
|
2005-11-12 05:51:49 +08:00
|
|
|
b .Lexit
|
2008-08-28 18:22:32 +08:00
|
|
|
FN_EXIT
|