2 * A fast checksum+copy routine using movem
3 * Copyright (c) 1998-2007 Axis Communications AB
7 * csum_partial_copy_nocheck(const char *src, char *dst,
8 * int len, unsigned int sum)
11 .globl csum_partial_copy_nocheck
12 .type csum_partial_copy_nocheck,@function
13 csum_partial_copy_nocheck:
20 ;; Optimized for large packets
29 ;; do a movem copy and checksum
30 1: ;; A failing userspace access (the read) will have this as PC.
31 _mloop: movem [$r10+],$r9 ; read 10 longwords
32 addoq -10*4, $acr, $acr ; loop counter in latency cycle
33 movem $r9,[$r11+] ; write 10 longwords
35 ;; perform dword checksumming on the 10 longwords
47 ;; test $acr, without trashing carry.
50 ;; r12 <= acr is needed after mloop and in the exception handlers.
53 ;; fold the last carry into r13
55 movem [$sp+],$r8 ; restore regs
58 addq 10*4,$r12 ; compensate for last loop underflowing length
60 ;; fold 32-bit checksum into a 16-bit checksum, to avoid carries below
61 ;; r9 can be used as temporary.
63 lsrq 16,$r9 ; r0 = checksum >> 16
64 and.d 0xffff,$r13 ; checksum = checksum & 0xffff
68 add.d $r9,$r13 ; checksum += r0
70 ;; copy and checksum the rest of the words
71 2: ;; A failing userspace access for the read below will have this as PC.
72 _wloop: move.w [$r10+],$r9
86 ;; copy and checksum the last byte
87 3: ;; A failing userspace access for the read below will have this as PC.
94 .size csum_partial_copy_nocheck, . - csum_partial_copy_nocheck