2 * linux/arch/arm26/lib/csumpartial.S
4 * Copyright (C) 1995-1998 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
16 * Function: __u32 csum_partial(const char *src, int len, __u32 sum)
17 * Params : r0 = buffer, r1 = len, r2 = checksum
18 * Returns : r0 = new checksum
25 td1 .req r4 @ save before use
26 td2 .req r5 @ save before use
34 * Handle 0 to 7 bytes, with any alignment of source and
35 * destination pointers. Note that when we get here, C = 0
37 .less8: teq len, #0 @ check for zero count
40 /* we must have at least one byte. */
41 tst buf, #1 @ odd address?
44 adcnes sum, sum, td0, lsl #byte(1)
49 /* we are now half-word aligned */
52 #if __LINUX_ARM_ARCH__ >= 4
59 orr td0, td0, td3, lsl #8
65 .less8_byte: tst len, #1 @ odd number of bytes
66 ldrneb td0, [buf], #1 @ include last byte
67 adcnes sum, sum, td0, lsl #byte(0) @ update checksum
69 .done: adc r0, sum, #0 @ collect up the last carry
71 tst td0, #1 @ check buffer alignment
72 movne td0, r0, lsl #8 @ rotate checksum by 8 bits
73 orrne r0, td0, r0, lsr #24
74 ldr pc, [sp], #4 @ return
76 .not_aligned: tst buf, #1 @ odd address
77 ldrneb td0, [buf], #1 @ make even
79 adcnes sum, sum, td0, lsl #byte(1) @ update checksum
81 tst buf, #2 @ 32-bit aligned?
82 #if __LINUX_ARM_ARCH__ >= 4
83 ldrneh td0, [buf], #2 @ make 32-bit aligned
89 orrne td0, td0, ip, lsl #8
91 adcnes sum, sum, td0 @ update checksum
96 cmp len, #8 @ Ensure that we have at least
97 blo .less8 @ 8 bytes to copy.
99 adds sum, sum, #0 @ C = 0
100 tst buf, #3 @ Test destination alignment
101 blne .not_aligned @ aligh destination, return here
107 2: ldmia buf!, {td0, td1, td2, td3}
112 ldmia buf!, {td0, td1, td2, td3}
122 3: tst len, #0x1c @ should not change C
125 4: ldr td0, [buf], #4