1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef __ASM_CSKY_UACCESS_H
4 #define __ASM_CSKY_UACCESS_H
9 extern int __put_user_bad(void);
11 #define __put_user_asm_b(x, ptr, err) \
14 __asm__ __volatile__( \
15 "1: stb %1, (%2,0) \n" \
19 ".section __ex_table, \"a\" \n" \
24 : "=r"(err), "=r"(x), "=r"(ptr), "=r"(errcode) \
25 : "0"(err), "1"(x), "2"(ptr), "3"(-EFAULT) \
29 #define __put_user_asm_h(x, ptr, err) \
32 __asm__ __volatile__( \
33 "1: sth %1, (%2,0) \n" \
37 ".section __ex_table, \"a\" \n" \
42 : "=r"(err), "=r"(x), "=r"(ptr), "=r"(errcode) \
43 : "0"(err), "1"(x), "2"(ptr), "3"(-EFAULT) \
47 #define __put_user_asm_w(x, ptr, err) \
50 __asm__ __volatile__( \
51 "1: stw %1, (%2,0) \n" \
55 ".section __ex_table,\"a\" \n" \
60 : "=r"(err), "=r"(x), "=r"(ptr), "=r"(errcode) \
61 : "0"(err), "1"(x), "2"(ptr), "3"(-EFAULT) \
65 #define __put_user_asm_64(x, ptr, err) \
70 __asm__ __volatile__( \
71 " ldw %3, (%1, 0) \n" \
72 "1: stw %3, (%2, 0) \n" \
73 " ldw %3, (%1, 4) \n" \
74 "2: stw %3, (%2, 4) \n" \
78 ".section __ex_table, \"a\" \n" \
84 : "=r"(err), "=r"(x), "=r"(ptr), \
85 "=r"(tmp), "=r"(errcode) \
86 : "0"(err), "1"(x), "2"(ptr), "3"(0), \
91 static inline int __put_user_fn(size_t size
, void __user
*ptr
, void *x
)
99 __put_user_asm_b(tmp
, ptr
, retval
);
103 __put_user_asm_h(tmp
, ptr
, retval
);
107 __put_user_asm_w(tmp
, ptr
, retval
);
110 __put_user_asm_64(x
, (u64
*)ptr
, retval
);
116 #define __put_user_fn __put_user_fn
121 extern int __get_user_bad(void);
123 #define __get_user_asm_common(x, ptr, ins, err) \
126 __asm__ __volatile__( \
127 "1: " ins " %1, (%4, 0) \n" \
132 ".section __ex_table,\"a\" \n" \
137 : "=r"(err), "=r"(x), "=r"(errcode) \
138 : "0"(0), "r"(ptr), "2"(-EFAULT) \
142 #define __get_user_asm_64(x, ptr, err) \
147 __asm__ __volatile__( \
148 "1: ldw %3, (%2, 0) \n" \
149 " stw %3, (%1, 0) \n" \
150 "2: ldw %3, (%2, 4) \n" \
151 " stw %3, (%1, 4) \n" \
155 ".section __ex_table, \"a\" \n" \
161 : "=r"(err), "=r"(x), "=r"(ptr), \
162 "=r"(tmp), "=r"(errcode) \
163 : "0"(err), "1"(x), "2"(ptr), "3"(0), \
168 static inline int __get_user_fn(size_t size
, const void __user
*ptr
, void *x
)
175 __get_user_asm_common(tmp
, ptr
, "ldb", retval
);
179 __get_user_asm_common(tmp
, ptr
, "ldh", retval
);
180 *(u16
*)x
= (u16
)tmp
;
183 __get_user_asm_common(tmp
, ptr
, "ldw", retval
);
184 *(u32
*)x
= (u32
)tmp
;
187 __get_user_asm_64(x
, ptr
, retval
);
193 #define __get_user_fn __get_user_fn
195 unsigned long raw_copy_from_user(void *to
, const void *from
, unsigned long n
);
196 unsigned long raw_copy_to_user(void *to
, const void *from
, unsigned long n
);
198 unsigned long __clear_user(void __user
*to
, unsigned long n
);
199 #define __clear_user __clear_user
201 #include <asm-generic/uaccess.h>
203 #endif /* __ASM_CSKY_UACCESS_H */