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 .globl csum_partial_copy_generic
49 csum_partial_copy_generic:
67 jz .Lhandle_tail /* < 64 */
71 /* main loop. clear in 64 byte blocks */
72 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
73 /* r11: temp3, rdx: temp4, r12 loopcnt */
74 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
131 /* do last upto 56 bytes */
147 leaq 8(%rsi),%rsi /* preserve carry */
150 adcq %r9,%rax /* add in carry */
153 /* reduce checksum to 32bits */
159 /* do last upto 6 bytes */
179 adcl %r9d,%eax /* add in carry */
181 /* handle last odd byte */
191 adcl %r9d,%eax /* carry */
202 /* Exception handlers. Very simple, zeroing is done in the wrappers */