1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/uaccess.h>
5 #include <linux/types.h>
7 unsigned long raw_copy_from_user(void *to, const void *from,
23 "2: ldw %3, (%2, 0) \n"
24 "10: ldw %4, (%2, 4) \n"
27 "11: ldw %3, (%2, 8) \n"
28 "12: ldw %4, (%2, 12) \n"
30 " stw %4, (%1, 12) \n"
37 "4: ldw %3, (%2, 0) \n"
45 "6: ldb %3, (%2, 0) \n"
51 "8: stw %3, (%1, 0) \n"
56 "13: stw %3, (%1, 8) \n"
59 ".section __ex_table, \"a\" \n"
69 : "=r"(n), "=r"(to), "=r"(from), "=r"(nsave),
71 : "0"(n), "1"(to), "2"(from)
76 EXPORT_SYMBOL(raw_copy_from_user);
78 unsigned long raw_copy_to_user(void *to, const void *from,
92 "1: cmplti %0, 16 \n" /* 4W */
97 " ldw %6, (%2, 12) \n"
98 "2: stw %3, (%1, 0) \n"
99 "9: stw %4, (%1, 4) \n"
100 "10: stw %5, (%1, 8) \n"
101 "11: stw %6, (%1, 12) \n"
106 "3: cmplti %0, 4 \n" /* 1W */
108 " ldw %3, (%2, 0) \n"
109 "4: stw %3, (%1, 0) \n"
114 "5: cmpnei %0, 0 \n" /* 1B */
116 " ldb %3, (%2, 0) \n"
117 "6: stb %3, (%1, 0) \n"
126 ".section __ex_table, \"a\" \n"
136 : "=r"(n), "=r"(to), "=r"(from), "=r"(w0),
137 "=r"(w1), "=r"(w2), "=r"(w3)
138 : "0"(n), "1"(to), "2"(from)
143 EXPORT_SYMBOL(raw_copy_to_user);
146 * __clear_user: - Zero a block of memory in user space, with less checking.
147 * @to: Destination address, in user space.
148 * @n: Number of bytes to zero.
150 * Zero a block of memory in user space. Caller must check
151 * the specified block with access_ok() before calling this function.
153 * Returns number of bytes that could not be cleared.
154 * On success, this will be zero.
157 __clear_user(void __user *to, unsigned long n)
159 int data, value, tmp;
161 __asm__ __volatile__(
169 "1: cmplti %0, 32 \n" /* 4W */
171 "8: stw %2, (%1, 0) \n"
172 "10: stw %2, (%1, 4) \n"
173 "11: stw %2, (%1, 8) \n"
174 "12: stw %2, (%1, 12) \n"
175 "13: stw %2, (%1, 16) \n"
176 "14: stw %2, (%1, 20) \n"
177 "15: stw %2, (%1, 24) \n"
178 "16: stw %2, (%1, 28) \n"
182 "3: cmplti %0, 4 \n" /* 1W */
184 "4: stw %2, (%1, 0) \n"
188 "5: cmpnei %0, 0 \n" /* 1B */
190 "6: stb %2, (%1, 0) \n"
194 ".section __ex_table,\"a\" \n"
208 : "=r"(n), "=r" (data), "=r"(value), "=r"(tmp)
209 : "0"(n), "1"(to), "2"(0)
214 EXPORT_SYMBOL(__clear_user);