2 * Copyright 2002,2003 Andi Kleen, SuSE Labs.
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details. No warranty for anything given at all.
8 #include <linux/linkage.h>
12 * Checksum copy with exception handling.
13 * On exceptions src_err_ptr or dst_err_ptr is set to -EFAULT and the
14 * destination is zeroed.
21 * r8 src_err_ptr (int)
22 * r9 dst_err_ptr (int)
25 * eax 64bit sum. undefined in case of exception.
27 * Wrappers need to take care of valid exception sum and zeroing.
28 * They also should align source or destination to 8 bytes.
33 .section __ex_table,"a"
35 .quad 10b,.Lbad_source
41 .section __ex_table,"a"
47 .macro ignore L=.Lignore
49 .section __ex_table,"a"
56 .globl csum_partial_copy_generic
58 csum_partial_copy_generic:
80 jz .Lhandle_tail /* < 64 */
84 /* main loop. clear in 64 byte blocks */
85 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
86 /* r11: temp3, rdx: temp4, r12 loopcnt */
87 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
109 prefetcht0 5*64(%rdi)
149 /* do last upto 56 bytes */
165 leaq 8(%rsi),%rsi /* preserve carry */
168 adcq %r9,%rax /* add in carry */
171 /* reduce checksum to 32bits */
177 /* do last upto 6 bytes */
197 adcl %r9d,%eax /* add in carry */
199 /* handle last odd byte */
209 adcl %r9d,%eax /* carry */
220 /* Exception handlers. Very simple, zeroing is done in the wrappers */