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>
9 #include <asm/dwarf2.h>
10 #include <asm/errno.h>
13 * Checksum copy with exception handling.
14 * On exceptions src_err_ptr or dst_err_ptr is set to -EFAULT and the
15 * destination is zeroed.
22 * r8 src_err_ptr (int)
23 * r9 dst_err_ptr (int)
26 * eax 64bit sum. undefined in case of exception.
28 * Wrappers need to take care of valid exception sum and zeroing.
29 * They also should align source or destination to 8 bytes.
34 .section __ex_table,"a"
36 .quad 10b,.Lbad_source
42 .section __ex_table,"a"
48 .macro ignore L=.Lignore
50 .section __ex_table,"a"
57 ENTRY(csum_partial_copy_generic)
64 CFI_ADJUST_CFA_OFFSET 7*8
66 CFI_REL_OFFSET rbx, 2*8
68 CFI_REL_OFFSET r12, 3*8
70 CFI_REL_OFFSET r14, 4*8
72 CFI_REL_OFFSET r13, 5*8
74 CFI_REL_OFFSET rbp, 6*8
86 jz .Lhandle_tail /* < 64 */
90 /* main loop. clear in 64 byte blocks */
91 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
92 /* r11: temp3, rdx: temp4, r12 loopcnt */
93 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
115 prefetcht0 5*64(%rdi)
155 /* do last upto 56 bytes */
171 leaq 8(%rsi),%rsi /* preserve carry */
174 adcq %r9,%rax /* add in carry */
177 /* reduce checksum to 32bits */
183 /* do last upto 6 bytes */
203 adcl %r9d,%eax /* add in carry */
205 /* handle last odd byte */
215 adcl %r9d,%eax /* carry */
230 CFI_ADJUST_CFA_OFFSET -7*8
234 /* Exception handlers. Very simple, zeroing is done in the wrappers */
249 ENDPROC(csum_partial_copy_generic)