Path: blob/master/arch/cris/arch-v32/lib/checksumcopy.S
15125 views
/*1* A fast checksum+copy routine using movem2* Copyright (c) 1998-2007 Axis Communications AB3*4* Authors: Bjorn Wesen5*6* csum_partial_copy_nocheck(const char *src, char *dst,7* int len, unsigned int sum)8*/910.globl csum_partial_copy_nocheck11.type csum_partial_copy_nocheck,@function12csum_partial_copy_nocheck:1314;; r10 - src15;; r11 - dst16;; r12 - length17;; r13 - checksum1819;; Optimized for large packets20subq 10*4, $r1221blt _word_loop22move.d $r12, $acr2324subq 9*4,$sp25clearf c26movem $r8,[$sp]2728;; do a movem copy and checksum291: ;; A failing userspace access (the read) will have this as PC.30_mloop: movem [$r10+],$r9 ; read 10 longwords31addoq -10*4, $acr, $acr ; loop counter in latency cycle32movem $r9,[$r11+] ; write 10 longwords3334;; perform dword checksumming on the 10 longwords35addc $r0,$r1336addc $r1,$r1337addc $r2,$r1338addc $r3,$r1339addc $r4,$r1340addc $r5,$r1341addc $r6,$r1342addc $r7,$r1343addc $r8,$r1344addc $r9,$r134546;; test $acr, without trashing carry.47move.d $acr, $acr48bpl _mloop49;; r12 <= acr is needed after mloop and in the exception handlers.50move.d $acr, $r125152;; fold the last carry into r1353addc 0, $r1354movem [$sp+],$r8 ; restore regs5556_word_loop:57addq 10*4,$r12 ; compensate for last loop underflowing length5859;; fold 32-bit checksum into a 16-bit checksum, to avoid carries below60;; r9 can be used as temporary.61move.d $r13,$r962lsrq 16,$r9 ; r0 = checksum >> 1663and.d 0xffff,$r13 ; checksum = checksum & 0xffff6465subq 2, $r1266blt _no_words67add.d $r9,$r13 ; checksum += r06869;; copy and checksum the rest of the words702: ;; A failing userspace access for the read below will have this as PC.71_wloop: move.w [$r10+],$r972addu.w $r9,$r1373subq 2,$r1274bge _wloop75move.w $r9,[$r11+]7677_no_words:78addq 2,$r1279bne _do_byte80nop81ret82move.d $r13,$r108384_do_byte:85;; copy and checksum the last byte863: ;; A failing userspace access for the read below will have this as PC.87move.b [$r10],$r988addu.b $r9,$r1389move.b $r9,[$r11]90ret91move.d $r13,$r109293.size csum_partial_copy_nocheck, . - csum_partial_copy_nocheck949596