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 #ifndef CONFIG_COLDFIRE
9 #include <asm/uaccess.h>
11 unsigned long __generic_copy_from_user(void *to, const void __user *from,
14 unsigned long tmp, res;
19 "1: moves.l (%1)+,%3\n"
25 "3: moves.w (%1)+,%3\n"
29 "5: moves.b (%1)+,%3\n"
32 " .section .fixup,\"ax\"\n"
50 " .section __ex_table,\"a\"\n"
56 : "=d" (res), "+a" (from), "+a" (to), "=&r" (tmp)
57 : "0" (n / 4), "d" (n & 3));
61 EXPORT_SYMBOL(__generic_copy_from_user);
63 unsigned long __generic_copy_to_user(void __user *to, const void *from,
66 unsigned long tmp, res;
71 "1: move.l (%1)+,%3\n"
72 "2: moves.l %3,(%2)+\n"
78 "5: moves.w %3,(%2)+\n"
82 "7: moves.b %3,(%2)+\n"
84 " .section .fixup,\"ax\"\n"
91 " .section __ex_table,\"a\"\n"
100 : "=d" (res), "+a" (from), "+a" (to), "=&r" (tmp)
101 : "0" (n / 4), "d" (n & 3));
105 EXPORT_SYMBOL(__generic_copy_to_user);
108 * Copy a null terminated string from userspace.
110 long strncpy_from_user(char *dst, const char __user *src, long count)
119 "1: moves.b (%2)+,%4\n"
126 " .section .fixup,\"ax\"\n"
132 " .section __ex_table,\"a\"\n"
136 : "=d" (res), "+a" (dst), "+a" (src), "+r" (count), "=&d" (c)
137 : "i" (-EFAULT), "0" (count));
141 EXPORT_SYMBOL(strncpy_from_user);
144 * Return the size of a string (including the ending 0)
146 * Return 0 on exception, a value greater than N if too long
148 long strnlen_user(const char __user *src, long n)
156 "2: moves.b (%0)+,%2\n"
164 " .section .fixup,\"ax\"\n"
170 " .section __ex_table,\"a\"\n"
174 : "=&a" (res), "+d" (n), "=&d" (c)
175 : "0" (src), "r" (src));
179 EXPORT_SYMBOL(strnlen_user);
185 unsigned long __clear_user(void __user *to, unsigned long n)
192 "1: moves.l %2,(%1)+\n"
197 "4: moves.w %2,(%1)+\n"
200 "6: moves.b %2,(%1)\n"
202 " .section .fixup,\"ax\"\n"
209 " .section __ex_table,\"a\"\n"
218 : "=d" (res), "+a" (to)
219 : "r" (0), "0" (n / 4), "d" (n & 3));
223 EXPORT_SYMBOL(__clear_user);
225 #else /* CONFIG_COLDFIRE */
227 #include <asm/uaccess_coldfire.h>
229 unsigned long __generic_copy_from_user(void *to, const void *from,
236 "1: movel (%1)+,%3\n"
243 "3: movew (%1)+,%3\n"
247 "5: moveb (%1)+,%3\n"
250 ".section .fixup,\"ax\"\n"
272 ".section __ex_table,\"a\"\n"
278 : "=a"(to), "=a"(from), "=d"(n), "=&d"(tmp)
279 : "d"(n & 3), "0"(to), "1"(from), "2"(n/4)
283 EXPORT_SYMBOL(__generic_copy_from_user);
286 unsigned long __generic_copy_to_user(void *to, const void *from,
293 "1: movel (%1)+,%3\n"
294 "22:movel %3,(%0)+\n"
301 "24:movew %3,(%0)+\n"
305 "25:moveb %3,(%0)+\n"
307 ".section .fixup,\"ax\"\n"
318 ".section __ex_table,\"a\"\n"
329 : "=a"(to), "=a"(from), "=d"(n), "=&d"(tmp)
330 : "r"(n & 3), "0"(to), "1"(from), "2"(n / 4)
334 EXPORT_SYMBOL(__generic_copy_to_user);
337 * Copy a null terminated string from userspace.
340 long strncpy_from_user(char *dst, const char *src, long count)
343 if (!(access_ok(VERIFY_READ, src, 1))) /* --tym-- */
345 if (count == 0) return count;
347 ("1: moveb (%2)+,%%d0\n"
348 "12:moveb %%d0,(%1)+\n"
354 ".section .fixup,\"ax\"\n"
359 ".section __ex_table,\"a\"\n"
364 : "=d"(res), "=a"(dst), "=a"(src), "=d"(count)
365 : "i"(-EFAULT), "0"(count), "1"(dst), "2"(src), "3"(count)
369 EXPORT_SYMBOL(strncpy_from_user);
372 * Return the size of a string (including the ending 0)
374 * Return 0 on exception, a value greater than N if too long
376 long strnlen_user(const char *src, long n)
379 if (!(access_ok(VERIFY_READ, src, 1))) /* --tym-- */
387 "2: moveb (%1)+,%%d0\n"
398 ".section .fixup,\"ax\"\n"
403 ".section __ex_table,\"a\"\n"
408 : "=d"(res), "=a"(src), "=d"(n)
409 : "i"(0), "0"(res), "1"(src), "2"(n)
413 EXPORT_SYMBOL(strnlen_user);
420 unsigned long __clear_user(void *to, unsigned long n)
425 "1: movel %3,(%0)+\n"
431 "24:movew %3,(%0)+\n"
434 "25:moveb %3,(%0)+\n"
436 ".section .fixup,\"ax\"\n"
447 ".section __ex_table,\"a\"\n"
458 : "r"(n & 3), "d"(0), "0"(to), "1"(n/4));
461 EXPORT_SYMBOL(__clear_user);
463 #endif /* CONFIG_COLDFIRE */