Go to the documentation of this file.
8 #ifndef __ASM_AVR32_UACCESS_H
9 #define __ASM_AVR32_UACCESS_H
11 #include <linux/errno.h>
12 #include <linux/sched.h>
15 #define VERIFY_WRITE 1
28 #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
29 #define segment_eq(a,b) ((a).is_user_space == (b).is_user_space)
31 #define USER_ADDR_LIMIT 0x80000000
33 #define KERNEL_DS MAKE_MM_SEG(0)
34 #define USER_DS MAKE_MM_SEG(1)
36 #define get_ds() (KERNEL_DS)
63 #define __range_ok(addr, size) \
64 (test_thread_flag(TIF_USERSPACE) \
65 && (((unsigned long)(addr) >= 0x80000000) \
66 || ((unsigned long)(size) > 0x80000000) \
67 || (((unsigned long)(addr) + (unsigned long)(size)) > 0x80000000)))
69 #define access_ok(type, addr, size) (likely(__range_ok(addr, size) == 0))
86 const void __user *from,
92 #define __copy_to_user_inatomic __copy_to_user
93 #define __copy_from_user_inatomic __copy_from_user
111 #define put_user(x,ptr) \
112 __put_user_check((x),(ptr),sizeof(*(ptr)))
131 #define get_user(x,ptr) \
132 __get_user_check((x),(ptr),sizeof(*(ptr)))
153 #define __put_user(x,ptr) \
154 __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
176 #define __get_user(x,ptr) \
177 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
182 #define __get_user_nocheck(x, ptr, size) \
184 unsigned long __gu_val = 0; \
188 case 1: __get_user_asm("ub", __gu_val, ptr, __gu_err); break; \
189 case 2: __get_user_asm("uh", __gu_val, ptr, __gu_err); break; \
190 case 4: __get_user_asm("w", __gu_val, ptr, __gu_err); break; \
191 default: __gu_err = __get_user_bad(); break; \
194 x = (typeof(*(ptr)))__gu_val; \
198 #define __get_user_check(x, ptr, size) \
200 unsigned long __gu_val = 0; \
201 const typeof(*(ptr)) __user * __gu_addr = (ptr); \
204 if (access_ok(VERIFY_READ, __gu_addr, size)) { \
207 __get_user_asm("ub", __gu_val, __gu_addr, \
211 __get_user_asm("uh", __gu_val, __gu_addr, \
215 __get_user_asm("w", __gu_val, __gu_addr, \
219 __gu_err = __get_user_bad(); \
223 __gu_err = -EFAULT; \
225 x = (typeof(*(ptr)))__gu_val; \
229 #define __get_user_asm(suffix, __gu_val, ptr, __gu_err) \
231 "1: ld." suffix " %1, %3 \n" \
233 " .subsection 1 \n" \
236 " .subsection 0 \n" \
237 " .section __ex_table, \"a\" \n" \
240 : "=r"(__gu_err), "=r"(__gu_val) \
241 : "0"(__gu_err), "m"(*(ptr)), "i"(-EFAULT))
243 #define __put_user_nocheck(x, ptr, size) \
245 typeof(*(ptr)) __pu_val; \
250 case 1: __put_user_asm("b", ptr, __pu_val, __pu_err); break; \
251 case 2: __put_user_asm("h", ptr, __pu_val, __pu_err); break; \
252 case 4: __put_user_asm("w", ptr, __pu_val, __pu_err); break; \
253 case 8: __put_user_asm("d", ptr, __pu_val, __pu_err); break; \
254 default: __pu_err = __put_user_bad(); break; \
259 #define __put_user_check(x, ptr, size) \
261 typeof(*(ptr)) __pu_val; \
262 typeof(*(ptr)) __user *__pu_addr = (ptr); \
266 if (access_ok(VERIFY_WRITE, __pu_addr, size)) { \
269 __put_user_asm("b", __pu_addr, __pu_val, \
273 __put_user_asm("h", __pu_addr, __pu_val, \
277 __put_user_asm("w", __pu_addr, __pu_val, \
281 __put_user_asm("d", __pu_addr, __pu_val, \
285 __pu_err = __put_user_bad(); \
289 __pu_err = -EFAULT; \
294 #define __put_user_asm(suffix, ptr, __pu_val, __gu_err) \
296 "1: st." suffix " %1, %3 \n" \
298 " .subsection 1 \n" \
301 " .subsection 0 \n" \
302 " .section __ex_table, \"a\" \n" \
305 : "=r"(__gu_err), "=m"(*(ptr)) \
306 : "0"(__gu_err), "r"(__pu_val), "i"(-EFAULT))
314 extern long strnlen_user(
const char __user *__s,
long __n);
317 #define strlen_user(s) strnlen_user(s, ~0UL >> 1)