v2.4.8 -> v2.4.8.1
[opensuse:kernel.git] / include / asm-arm / proc-armv / uaccess.h
1 /*
2  *  linux/include/asm-arm/proc-armv/uaccess.h
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8 #include <asm/arch/memory.h>
9 #include <asm/proc/domain.h>
10
11 /*
12  * Note that this is actually 0x1,0000,0000
13  */
14 #define KERNEL_DS       0x00000000
15 #define USER_DS         PAGE_OFFSET
16
17 static inline void set_fs (mm_segment_t fs)
18 {
19         current->addr_limit = fs;
20
21         modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
22 }
23
24 /* We use 33-bit arithmetic here... */
25 #define __range_ok(addr,size) ({ \
26         unsigned long flag, sum; \
27         __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
28                 : "=&r" (flag), "=&r" (sum) \
29                 : "r" (addr), "Ir" (size), "0" (current->addr_limit) \
30                 : "cc"); \
31         flag; })
32
33 #define __addr_ok(addr) ({ \
34         unsigned long flag; \
35         __asm__("cmp %2, %0; movlo %0, #0" \
36                 : "=&r" (flag) \
37                 : "0" (current->addr_limit), "r" (addr) \
38                 : "cc"); \
39         (flag == 0); })
40
41 #define __put_user_asm_byte(x,addr,err)                         \
42         __asm__ __volatile__(                                   \
43         "1:     strbt   %1,[%2],#0\n"                           \
44         "2:\n"                                                  \
45         "       .section .fixup,\"ax\"\n"                       \
46         "       .align  2\n"                                    \
47         "3:     mov     %0, %3\n"                               \
48         "       b       2b\n"                                   \
49         "       .previous\n"                                    \
50         "       .section __ex_table,\"a\"\n"                    \
51         "       .align  3\n"                                    \
52         "       .long   1b, 3b\n"                               \
53         "       .previous"                                      \
54         : "=r" (err)                                            \
55         : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err))
56
57 #define __put_user_asm_half(x,addr,err)                         \
58 ({                                                              \
59         unsigned long __temp = (unsigned long)(x);              \
60         __put_user_asm_byte(__temp, addr, err);                 \
61         __put_user_asm_byte(__temp >> 8, (int)(addr) + 1, err); \
62 })
63
64 #define __put_user_asm_word(x,addr,err)                         \
65         __asm__ __volatile__(                                   \
66         "1:     strt    %1,[%2],#0\n"                           \
67         "2:\n"                                                  \
68         "       .section .fixup,\"ax\"\n"                       \
69         "       .align  2\n"                                    \
70         "3:     mov     %0, %3\n"                               \
71         "       b       2b\n"                                   \
72         "       .previous\n"                                    \
73         "       .section __ex_table,\"a\"\n"                    \
74         "       .align  3\n"                                    \
75         "       .long   1b, 3b\n"                               \
76         "       .previous"                                      \
77         : "=r" (err)                                            \
78         : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err))
79
80 #define __get_user_asm_byte(x,addr,err)                         \
81         __asm__ __volatile__(                                   \
82         "1:     ldrbt   %1,[%2],#0\n"                           \
83         "2:\n"                                                  \
84         "       .section .fixup,\"ax\"\n"                       \
85         "       .align  2\n"                                    \
86         "3:     mov     %0, %3\n"                               \
87         "       mov     %1, #0\n"                               \
88         "       b       2b\n"                                   \
89         "       .previous\n"                                    \
90         "       .section __ex_table,\"a\"\n"                    \
91         "       .align  3\n"                                    \
92         "       .long   1b, 3b\n"                               \
93         "       .previous"                                      \
94         : "=r" (err), "=&r" (x)                                 \
95         : "r" (addr), "i" (-EFAULT), "0" (err))
96
97 #define __get_user_asm_half(x,addr,err)                         \
98 ({                                                              \
99         unsigned long __b1, __b2;                               \
100         __get_user_asm_byte(__b1, addr, err);                   \
101         __get_user_asm_byte(__b2, (int)(addr) + 1, err);        \
102         (x) = __b1 | (__b2 << 8);                               \
103 })
104
105
106 #define __get_user_asm_word(x,addr,err)                         \
107         __asm__ __volatile__(                                   \
108         "1:     ldrt    %1,[%2],#0\n"                           \
109         "2:\n"                                                  \
110         "       .section .fixup,\"ax\"\n"                       \
111         "       .align  2\n"                                    \
112         "3:     mov     %0, %3\n"                               \
113         "       mov     %1, #0\n"                               \
114         "       b       2b\n"                                   \
115         "       .previous\n"                                    \
116         "       .section __ex_table,\"a\"\n"                    \
117         "       .align  3\n"                                    \
118         "       .long   1b, 3b\n"                               \
119         "       .previous"                                      \
120         : "=r" (err), "=&r" (x)                                 \
121         : "r" (addr), "i" (-EFAULT), "0" (err))
122
123 extern unsigned long __arch_copy_from_user(void *to, const void *from, unsigned long n);
124 #define __do_copy_from_user(to,from,n)                          \
125         (n) = __arch_copy_from_user(to,from,n)
126
127 extern unsigned long __arch_copy_to_user(void *to, const void *from, unsigned long n);
128 #define __do_copy_to_user(to,from,n)                            \
129         (n) = __arch_copy_to_user(to,from,n)
130
131 extern unsigned long __arch_clear_user(void *addr, unsigned long n);
132 #define __do_clear_user(addr,sz)                                \
133         (sz) = __arch_clear_user(addr,sz)
134
135 extern unsigned long __arch_strncpy_from_user(char *to, const char *from, unsigned long count);
136 #define __do_strncpy_from_user(dst,src,count,res)               \
137         (res) = __arch_strncpy_from_user(dst,src,count)
138
139 extern unsigned long __arch_strnlen_user(const char *s, long n);
140 #define __do_strnlen_user(s,n,res)                                      \
141         (res) = __arch_strnlen_user(s,n)