1 /* SPDX-License-Identifier: GPL-2.0 */
3 * A fast checksum+copy routine using movem
4 * Copyright (c) 1998-2007 Axis Communications AB
8 * csum_partial_copy_nocheck(const char *src, char *dst,
9 * int len, unsigned int sum)
12 .globl csum_partial_copy_nocheck
13 .type csum_partial_copy_nocheck,@function
14 csum_partial_copy_nocheck:
21 ;; Optimized for large packets
30 ;; do a movem copy and checksum
31 1: ;; A failing userspace access (the read) will have this as PC.
32 _mloop: movem [$r10+],$r9 ; read 10 longwords
33 addoq -10*4, $acr, $acr ; loop counter in latency cycle
34 movem $r9,[$r11+] ; write 10 longwords
36 ;; perform dword checksumming on the 10 longwords
48 ;; test $acr, without trashing carry.
51 ;; r12 <= acr is needed after mloop and in the exception handlers.
54 ;; fold the last carry into r13
56 movem [$sp+],$r8 ; restore regs
59 addq 10*4,$r12 ; compensate for last loop underflowing length
61 ;; fold 32-bit checksum into a 16-bit checksum, to avoid carries below
62 ;; r9 can be used as temporary.
64 lsrq 16,$r9 ; r0 = checksum >> 16
65 and.d 0xffff,$r13 ; checksum = checksum & 0xffff
69 add.d $r9,$r13 ; checksum += r0
71 ;; copy and checksum the rest of the words
72 2: ;; A failing userspace access for the read below will have this as PC.
73 _wloop: move.w [$r10+],$r9
87 ;; copy and checksum the last byte
88 3: ;; A failing userspace access for the read below will have this as PC.
95 .size csum_partial_copy_nocheck, . - csum_partial_copy_nocheck