2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2009 PetaLogix
4 * Copyright (C) 2007 LynuxWorks, Inc.
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/errno.h>
12 #include <linux/linkage.h>
15 /* Loop unrolling for __copy_tofrom_user */
16 #define COPY(offset) \
17 1: lwi r4 , r6, 0x0000 + offset; \
18 2: lwi r19, r6, 0x0004 + offset; \
19 3: lwi r20, r6, 0x0008 + offset; \
20 4: lwi r21, r6, 0x000C + offset; \
21 5: lwi r22, r6, 0x0010 + offset; \
22 6: lwi r23, r6, 0x0014 + offset; \
23 7: lwi r24, r6, 0x0018 + offset; \
24 8: lwi r25, r6, 0x001C + offset; \
25 9: swi r4 , r5, 0x0000 + offset; \
26 10: swi r19, r5, 0x0004 + offset; \
27 11: swi r20, r5, 0x0008 + offset; \
28 12: swi r21, r5, 0x000C + offset; \
29 13: swi r22, r5, 0x0010 + offset; \
30 14: swi r23, r5, 0x0014 + offset; \
31 15: swi r24, r5, 0x0018 + offset; \
32 16: swi r25, r5, 0x001C + offset; \
33 .section __ex_table,"a"; \
52 #define COPY_80(offset) \
59 * int __copy_tofrom_user(char *to, char *from, int len)
62 * number of not copied bytes on error
65 .globl __copy_tofrom_user;
66 .type __copy_tofrom_user, @function
75 beqid r7, 0f /* zero size is not likely */
76 or r3, r5, r6 /* find if is any to/from unaligned */
77 or r3, r3, r7 /* find if count is unaligned */
78 andi r3, r3, 0x3 /* mask last 3 bits */
79 bneid r3, bu1 /* if r3 is not zero then byte copying */
82 rsubi r3, r7, PAGE_SIZE /* detect PAGE_SIZE */
86 w1: lw r4, r6, r3 /* at least one 4 byte copy */
95 .section __ex_table,"a"
100 .align 4 /* Alignment is important to keep icache happy */
101 page: /* Create room on stack and save registers for storing values */
113 loop: /* r4, r19, r20, r21, r22, r23, r24, r25 are used for storing values */
114 /* Loop unrolling to get performance boost */
125 /* Restore register content */
142 /* Fault case - return temp count */
145 /* Restore register content */
161 .align 4 /* Alignment is important to keep icache happy */
166 addik r3,r3,1 /* delay slot */
171 .size __copy_tofrom_user, . - __copy_tofrom_user
173 .section __ex_table,"a"