aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-parisc/uaccess.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-parisc/uaccess.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-parisc/uaccess.h')
-rw-r--r--include/asm-parisc/uaccess.h287
1 files changed, 287 insertions, 0 deletions
diff --git a/include/asm-parisc/uaccess.h b/include/asm-parisc/uaccess.h
new file mode 100644
index 000000000000..8a08423b7570
--- /dev/null
+++ b/include/asm-parisc/uaccess.h
@@ -0,0 +1,287 @@
1#ifndef __PARISC_UACCESS_H
2#define __PARISC_UACCESS_H
3
4/*
5 * User space memory access functions
6 */
7#include <linux/sched.h>
8#include <asm/page.h>
9#include <asm/system.h>
10#include <asm/cache.h>
11#include <asm-generic/uaccess.h>
12
13#define VERIFY_READ 0
14#define VERIFY_WRITE 1
15
16#define KERNEL_DS ((mm_segment_t){0})
17#define USER_DS ((mm_segment_t){1})
18
19#define segment_eq(a,b) ((a).seg == (b).seg)
20
21#define get_ds() (KERNEL_DS)
22#define get_fs() (current_thread_info()->addr_limit)
23#define set_fs(x) (current_thread_info()->addr_limit = (x))
24
25/*
26 * Note that since kernel addresses are in a separate address space on
27 * parisc, we don't need to do anything for access_ok() or verify_area().
28 * We just let the page fault handler do the right thing. This also means
29 * that put_user is the same as __put_user, etc.
30 */
31
32extern int __get_kernel_bad(void);
33extern int __get_user_bad(void);
34extern int __put_kernel_bad(void);
35extern int __put_user_bad(void);
36
37static inline long access_ok(int type, const void __user * addr,
38 unsigned long size)
39{
40 return 1;
41}
42
43#define verify_area(type,addr,size) (0) /* FIXME: all users should go away soon,
44 * and use access_ok instead, then this
45 * should be removed. */
46
47#define put_user __put_user
48#define get_user __get_user
49
50#if BITS_PER_LONG == 32
51#define LDD_KERNEL(ptr) __get_kernel_bad();
52#define LDD_USER(ptr) __get_user_bad();
53#define STD_KERNEL(x, ptr) __put_kernel_asm64(x,ptr)
54#define STD_USER(x, ptr) __put_user_asm64(x,ptr)
55#else
56#define LDD_KERNEL(ptr) __get_kernel_asm("ldd",ptr)
57#define LDD_USER(ptr) __get_user_asm("ldd",ptr)
58#define STD_KERNEL(x, ptr) __put_kernel_asm("std",x,ptr)
59#define STD_USER(x, ptr) __put_user_asm("std",x,ptr)
60#endif
61
62/*
63 * The exception table contains two values: the first is an address
64 * for an instruction that is allowed to fault, and the second is
65 * the address to the fixup routine.
66 */
67
68struct exception_table_entry {
69 unsigned long insn; /* address of insn that is allowed to fault. */
70 long fixup; /* fixup routine */
71};
72
73/*
74 * The page fault handler stores, in a per-cpu area, the following information
75 * if a fixup routine is available.
76 */
77struct exception_data {
78 unsigned long fault_ip;
79 unsigned long fault_space;
80 unsigned long fault_addr;
81};
82
83#define __get_user(x,ptr) \
84({ \
85 register long __gu_err __asm__ ("r8") = 0; \
86 register long __gu_val __asm__ ("r9") = 0; \
87 \
88 if (segment_eq(get_fs(),KERNEL_DS)) { \
89 switch (sizeof(*(ptr))) { \
90 case 1: __get_kernel_asm("ldb",ptr); break; \
91 case 2: __get_kernel_asm("ldh",ptr); break; \
92 case 4: __get_kernel_asm("ldw",ptr); break; \
93 case 8: LDD_KERNEL(ptr); break; \
94 default: __get_kernel_bad(); break; \
95 } \
96 } \
97 else { \
98 switch (sizeof(*(ptr))) { \
99 case 1: __get_user_asm("ldb",ptr); break; \
100 case 2: __get_user_asm("ldh",ptr); break; \
101 case 4: __get_user_asm("ldw",ptr); break; \
102 case 8: LDD_USER(ptr); break; \
103 default: __get_user_bad(); break; \
104 } \
105 } \
106 \
107 (x) = (__typeof__(*(ptr))) __gu_val; \
108 __gu_err; \
109})
110
111#ifdef __LP64__
112#define __get_kernel_asm(ldx,ptr) \
113 __asm__("\n1:\t" ldx "\t0(%2),%0\n" \
114 "\t.section __ex_table,\"aw\"\n" \
115 "\t.dword\t1b,fixup_get_user_skip_1\n" \
116 "\t.previous" \
117 : "=r"(__gu_val), "=r"(__gu_err) \
118 : "r"(ptr), "1"(__gu_err) \
119 : "r1");
120
121#define __get_user_asm(ldx,ptr) \
122 __asm__("\n1:\t" ldx "\t0(%%sr3,%2),%0\n" \
123 "\t.section __ex_table,\"aw\"\n" \
124 "\t.dword\t1b,fixup_get_user_skip_1\n" \
125 "\t.previous" \
126 : "=r"(__gu_val), "=r"(__gu_err) \
127 : "r"(ptr), "1"(__gu_err) \
128 : "r1");
129#else
130#define __get_kernel_asm(ldx,ptr) \
131 __asm__("\n1:\t" ldx "\t0(%2),%0\n" \
132 "\t.section __ex_table,\"aw\"\n" \
133 "\t.word\t1b,fixup_get_user_skip_1\n" \
134 "\t.previous" \
135 : "=r"(__gu_val), "=r"(__gu_err) \
136 : "r"(ptr), "1"(__gu_err) \
137 : "r1");
138
139#define __get_user_asm(ldx,ptr) \
140 __asm__("\n1:\t" ldx "\t0(%%sr3,%2),%0\n" \
141 "\t.section __ex_table,\"aw\"\n" \
142 "\t.word\t1b,fixup_get_user_skip_1\n" \
143 "\t.previous" \
144 : "=r"(__gu_val), "=r"(__gu_err) \
145 : "r"(ptr), "1"(__gu_err) \
146 : "r1");
147#endif /* !__LP64__ */
148
149#define __put_user(x,ptr) \
150({ \
151 register long __pu_err __asm__ ("r8") = 0; \
152 __typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \
153 \
154 if (segment_eq(get_fs(),KERNEL_DS)) { \
155 switch (sizeof(*(ptr))) { \
156 case 1: __put_kernel_asm("stb",__x,ptr); break; \
157 case 2: __put_kernel_asm("sth",__x,ptr); break; \
158 case 4: __put_kernel_asm("stw",__x,ptr); break; \
159 case 8: STD_KERNEL(__x,ptr); break; \
160 default: __put_kernel_bad(); break; \
161 } \
162 } \
163 else { \
164 switch (sizeof(*(ptr))) { \
165 case 1: __put_user_asm("stb",__x,ptr); break; \
166 case 2: __put_user_asm("sth",__x,ptr); break; \
167 case 4: __put_user_asm("stw",__x,ptr); break; \
168 case 8: STD_USER(__x,ptr); break; \
169 default: __put_user_bad(); break; \
170 } \
171 } \
172 \
173 __pu_err; \
174})
175
176/*
177 * The "__put_user/kernel_asm()" macros tell gcc they read from memory
178 * instead of writing. This is because they do not write to any memory
179 * gcc knows about, so there are no aliasing issues.
180 */
181
182#ifdef __LP64__
183#define __put_kernel_asm(stx,x,ptr) \
184 __asm__ __volatile__ ( \
185 "\n1:\t" stx "\t%2,0(%1)\n" \
186 "\t.section __ex_table,\"aw\"\n" \
187 "\t.dword\t1b,fixup_put_user_skip_1\n" \
188 "\t.previous" \
189 : "=r"(__pu_err) \
190 : "r"(ptr), "r"(x), "0"(__pu_err))
191
192#define __put_user_asm(stx,x,ptr) \
193 __asm__ __volatile__ ( \
194 "\n1:\t" stx "\t%2,0(%%sr3,%1)\n" \
195 "\t.section __ex_table,\"aw\"\n" \
196 "\t.dword\t1b,fixup_put_user_skip_1\n" \
197 "\t.previous" \
198 : "=r"(__pu_err) \
199 : "r"(ptr), "r"(x), "0"(__pu_err) \
200 : "r1")
201#else
202#define __put_kernel_asm(stx,x,ptr) \
203 __asm__ __volatile__ ( \
204 "\n1:\t" stx "\t%2,0(%1)\n" \
205 "\t.section __ex_table,\"aw\"\n" \
206 "\t.word\t1b,fixup_put_user_skip_1\n" \
207 "\t.previous" \
208 : "=r"(__pu_err) \
209 : "r"(ptr), "r"(x), "0"(__pu_err) \
210 : "r1")
211
212#define __put_user_asm(stx,x,ptr) \
213 __asm__ __volatile__ ( \
214 "\n1:\t" stx "\t%2,0(%%sr3,%1)\n" \
215 "\t.section __ex_table,\"aw\"\n" \
216 "\t.word\t1b,fixup_put_user_skip_1\n" \
217 "\t.previous" \
218 : "=r"(__pu_err) \
219 : "r"(ptr), "r"(x), "0"(__pu_err) \
220 : "r1")
221
222#define __put_kernel_asm64(__val,ptr) do { \
223 u64 __val64 = (u64)(__val); \
224 u32 hi = (__val64) >> 32; \
225 u32 lo = (__val64) & 0xffffffff; \
226 __asm__ __volatile__ ( \
227 "\n1:\tstw %2,0(%1)\n" \
228 "\n2:\tstw %3,4(%1)\n" \
229 "\t.section __ex_table,\"aw\"\n" \
230 "\t.word\t1b,fixup_put_user_skip_2\n" \
231 "\t.word\t2b,fixup_put_user_skip_1\n" \
232 "\t.previous" \
233 : "=r"(__pu_err) \
234 : "r"(ptr), "r"(hi), "r"(lo), "0"(__pu_err) \
235 : "r1"); \
236} while (0)
237
238#define __put_user_asm64(__val,ptr) do { \
239 u64 __val64 = (u64)__val; \
240 u32 hi = (__val64) >> 32; \
241 u32 lo = (__val64) & 0xffffffff; \
242 __asm__ __volatile__ ( \
243 "\n1:\tstw %2,0(%%sr3,%1)\n" \
244 "\n2:\tstw %3,4(%%sr3,%1)\n" \
245 "\t.section __ex_table,\"aw\"\n" \
246 "\t.word\t1b,fixup_get_user_skip_2\n" \
247 "\t.word\t2b,fixup_get_user_skip_1\n" \
248 "\t.previous" \
249 : "=r"(__pu_err) \
250 : "r"(ptr), "r"(hi), "r"(lo), "0"(__pu_err) \
251 : "r1"); \
252} while (0)
253
254#endif /* !__LP64__ */
255
256
257/*
258 * Complex access routines -- external declarations
259 */
260
261extern unsigned long lcopy_to_user(void __user *, const void *, unsigned long);
262extern unsigned long lcopy_from_user(void *, const void __user *, unsigned long);
263extern unsigned long lcopy_in_user(void __user *, const void __user *, unsigned long);
264extern long lstrncpy_from_user(char *, const char __user *, long);
265extern unsigned lclear_user(void __user *,unsigned long);
266extern long lstrnlen_user(const char __user *,long);
267
268/*
269 * Complex access routines -- macros
270 */
271
272#define strncpy_from_user lstrncpy_from_user
273#define strnlen_user lstrnlen_user
274#define strlen_user(str) lstrnlen_user(str, 0x7fffffffL)
275#define clear_user lclear_user
276#define __clear_user lclear_user
277
278unsigned long copy_to_user(void __user *dst, const void *src, unsigned long len);
279#define __copy_to_user copy_to_user
280unsigned long copy_from_user(void *dst, const void __user *src, unsigned long len);
281#define __copy_from_user copy_from_user
282unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned long len);
283#define __copy_in_user copy_in_user
284#define __copy_to_user_inatomic __copy_to_user
285#define __copy_from_user_inatomic __copy_from_user
286
287#endif /* __PARISC_UACCESS_H */