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 * int __strncpy_user(char *to, char *from, int len);
18 * -EFAULT for an exception
19 * len if we hit the buffer limit
24 .globl __strncpy_user;
25 .type __strncpy_user, @function
36 addik r3,r7,0 /* temp_count = len */
43 beqi r3,2f /* break on len */
47 addik r6,r6,1 /* delay slot */
48 addik r3,r3,1 /* undo "temp_count--" */
50 rsubk r3,r3,r7 /* temp_count = len - temp_count */
54 .size __strncpy_user, . - __strncpy_user
62 .section __ex_table, "a"
66 * int __strnlen_user(char __user *str, int maxlen);
70 * maxlen + 1 if no NUL byte found within maxlen bytes
71 * size of the string (including NUL byte)
75 .globl __strnlen_user;
76 .type __strnlen_user, @function
83 beqid r4,2f /* break on NUL */
84 addik r3,r3,-1 /* delay slot */
87 addik r5,r5,1 /* delay slot */
89 addik r3,r3,-1 /* for break on len */
95 .size __strnlen_user, . - __strnlen_user
102 .section __ex_table,"a"
106 * int __copy_tofrom_user(char *to, char *from, int len)
109 * number of not copied bytes on error
112 .globl __copy_tofrom_user;
113 .type __copy_tofrom_user, @function
122 beqid r7, 3f /* zero size is not likely */
123 andi r3, r7, 0x3 /* filter add count */
124 bneid r3, 4f /* if is odd value then byte copying */
125 or r3, r5, r6 /* find if is any to/from unaligned */
126 andi r3, r3, 0x3 /* mask unaligned */
127 bneid r3, 1f /* it is unaligned -> then jump */
130 /* at least one 4 byte copy */
144 addik r3,r3,1 /* delay slot */
149 .size __copy_tofrom_user, . - __copy_tofrom_user
151 .section __ex_table,"a"
152 .word 1b,3b,2b,3b,5b,3b,6b,3b