2 * User space memory access functions
4 * Copyright (C) 1999, 2002 Niibe Yutaka
5 * Copyright (C) 2003 - 2008 Paul Mundt
8 * MIPS implementation version 1.15 by
9 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
12 #ifndef __ASM_SH_UACCESS_32_H
13 #define __ASM_SH_UACCESS_32_H
15 #define __get_user_size(x,ptr,size,retval) \
20 __get_user_asm(x, ptr, retval, "b"); \
23 __get_user_asm(x, ptr, retval, "w"); \
26 __get_user_asm(x, ptr, retval, "l"); \
29 __get_user_unknown(); \
35 #define __get_user_asm(x, addr, err, insn) \
37 __asm__ __volatile__( \
39 "mov." insn " %2, %1\n\t" \
41 ".section .fixup,\"ax\"\n" \
50 ".section __ex_table,\"a\"\n\t" \
53 :"=&r" (err), "=&r" (x) \
54 :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
56 #define __get_user_asm(x, addr, err, insn) \
58 __asm__ __volatile__ ( \
59 "mov." insn " %1, %0\n\t" \
64 #endif /* CONFIG_MMU */
66 extern void __get_user_unknown(void);
68 #define __put_user_size(x,ptr,size,retval) \
73 __put_user_asm(x, ptr, retval, "b"); \
76 __put_user_asm(x, ptr, retval, "w"); \
79 __put_user_asm(x, ptr, retval, "l"); \
82 __put_user_u64(x, ptr, retval); \
85 __put_user_unknown(); \
90 #define __put_user_asm(x, addr, err, insn) \
92 __asm__ __volatile__ ( \
94 "mov." insn " %1, %2\n\t" \
96 ".section .fixup,\"ax\"\n" \
104 ".section __ex_table,\"a\"\n\t" \
108 : "r" (x), "m" (__m(addr)), "i" (-EFAULT), \
114 #define __put_user_asm(x, addr, err, insn) \
116 __asm__ __volatile__ ( \
117 "mov." insn " %0, %1\n\t" \
119 : "r" (x), "m" (__m(addr)) \
123 #endif /* CONFIG_MMU */
125 #if defined(CONFIG_CPU_LITTLE_ENDIAN)
126 #define __put_user_u64(val,addr,retval) \
128 __asm__ __volatile__( \
131 "mov.l %S1,%T2\n\t" \
133 ".section .fixup,\"ax\"\n" \
141 ".section __ex_table,\"a\"\n\t" \
145 : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \
148 #define __put_user_u64(val,addr,retval) \
150 __asm__ __volatile__( \
153 "mov.l %R1,%T2\n\t" \
155 ".section .fixup,\"ax\"\n" \
163 ".section __ex_table,\"a\"\n\t" \
167 : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \
171 extern void __put_user_unknown(void);
174 __strncpy_from_user(unsigned long __dest
, unsigned long __user __src
, int __count
)
177 unsigned long __dummy
, _d
, _s
, _c
;
179 __asm__
__volatile__(
192 ".section .fixup,\"ax\"\n"
200 ".section __ex_table,\"a\"\n"
204 : "=r" (res
), "=&z" (__dummy
), "=r" (_s
), "=r" (_d
), "=r"(_c
)
205 : "0" (__count
), "2" (__src
), "3" (__dest
), "4" (__count
),
213 * Return the size of a string (including the ending 0 even when we have
214 * exceeded the maximum string length).
216 static inline long __strnlen_user(const char __user
*__s
, long __n
)
219 unsigned long __dummy
;
221 __asm__
__volatile__(
223 "mov.b @(%0,%3), %1\n\t"
230 ".section .fixup,\"ax\"\n"
238 ".section __ex_table,\"a\"\n"
242 : "=z" (res
), "=&r" (__dummy
)
243 : "0" (0), "r" (__s
), "r" (__n
)
248 #endif /* __ASM_SH_UACCESS_32_H */