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 csum_partial_copy_nocheck:
19 ;; Optimized for large packets
28 ;; do a movem copy and checksum
29 1: ;; A failing userspace access (the read) will have this as PC.
30 _mloop: movem [$r10+],$r9 ; read 10 longwords
31 addoq -10*4, $acr, $acr ; loop counter in latency cycle
32 movem $r9,[$r11+] ; write 10 longwords
34 ;; perform dword checksumming on the 10 longwords
46 ;; test $acr, without trashing carry.
49 ;; r12 <= acr is needed after mloop and in the exception handlers.
52 ;; fold the last carry into r13
54 movem [$sp+],$r8 ; restore regs
57 addq 10*4,$r12 ; compensate for last loop underflowing length
59 ;; fold 32-bit checksum into a 16-bit checksum, to avoid carries below
60 ;; r9 can be used as temporary.
62 lsrq 16,$r9 ; r0 = checksum >> 16
63 and.d 0xffff,$r13 ; checksum = checksum & 0xffff
67 add.d $r9,$r13 ; checksum += r0
69 ;; copy and checksum the rest of the words
70 2: ;; A failing userspace access for the read below will have this as PC.
71 _wloop: move.w [$r10+],$r9
85 ;; copy and checksum the last byte
86 3: ;; A failing userspace access for the read below will have this as PC.