2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file COPYING in the main directory of this archive
7 #include <linux/module.h>
8 #include <asm/uaccess.h>
10 unsigned long __generic_copy_from_user(void *to, const void __user *from,
13 unsigned long tmp, res;
18 "1: moves.l (%1)+,%3\n"
24 "3: moves.w (%1)+,%3\n"
28 "5: moves.b (%1)+,%3\n"
31 " .section .fixup,\"ax\"\n"
49 " .section __ex_table,\"a\"\n"
55 : "=d" (res), "+a" (from), "+a" (to), "=&r" (tmp)
56 : "0" (n / 4), "d" (n & 3));
60 EXPORT_SYMBOL(__generic_copy_from_user);
62 unsigned long __generic_copy_to_user(void __user *to, const void *from,
65 unsigned long tmp, res;
70 "1: move.l (%1)+,%3\n"
71 "2: moves.l %3,(%2)+\n"
77 "5: moves.w %3,(%2)+\n"
81 "7: moves.b %3,(%2)+\n"
83 " .section .fixup,\"ax\"\n"
90 " .section __ex_table,\"a\"\n"
99 : "=d" (res), "+a" (from), "+a" (to), "=&r" (tmp)
100 : "0" (n / 4), "d" (n & 3));
104 EXPORT_SYMBOL(__generic_copy_to_user);
107 * Copy a null terminated string from userspace.
109 long strncpy_from_user(char *dst, const char __user *src, long count)
118 "1: moves.b (%2)+,%4\n"
125 " .section .fixup,\"ax\"\n"
131 " .section __ex_table,\"a\"\n"
135 : "=d" (res), "+a" (dst), "+a" (src), "+r" (count), "=&d" (c)
136 : "i" (-EFAULT), "0" (count));
140 EXPORT_SYMBOL(strncpy_from_user);
143 * Return the size of a string (including the ending 0)
145 * Return 0 on exception, a value greater than N if too long
147 long strnlen_user(const char __user *src, long n)
155 "2: moves.b (%0)+,%2\n"
163 " .section .fixup,\"ax\"\n"
169 " .section __ex_table,\"a\"\n"
173 : "=&a" (res), "+d" (n), "=&d" (c)
174 : "0" (src), "r" (src));
178 EXPORT_SYMBOL(strnlen_user);
184 unsigned long __clear_user(void __user *to, unsigned long n)
191 "1: moves.l %2,(%1)+\n"
196 "4: moves.w %2,(%1)+\n"
199 "6: moves.b %2,(%1)\n"
201 " .section .fixup,\"ax\"\n"
208 " .section __ex_table,\"a\"\n"
217 : "=d" (res), "+a" (to)
218 : "r" (0), "0" (n / 4), "d" (n & 3));
222 EXPORT_SYMBOL(__clear_user);