MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / asm-arm / uaccess-nommu.h
blob3cab9f08f43a0470e2de94299857385b131b813d
1 /*
2 * linux/include/asm-arm/uaccess-nommu.h
4 * Copyright (C) 2003 Hyok S. Choi, Samsung Electronics Co.,Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #ifndef _ASMARM_UACCESS_NOMMU_H
11 #define _ASMARM_UACCESS_NOMMU_H
14 * Note that this is actually 0x1,0000,0000
16 #define KERNEL_DS 0x00000000
17 /* uClinux has only one addr space. */
18 #define USER_DS KERNEL_DS
20 #define get_ds() (KERNEL_DS)
21 #define get_fs() (USER_DS)
23 static inline void set_fs (mm_segment_t fs)
24 { /* nothing to do here for uClinux */
27 /* segment always equal. */
28 #define segment_eq(a,b) 1
31 * assuming __range_ok & __addr_ok always succeed.
33 #define __addr_ok(addr) 1
34 #define __range_ok(addr,size) 0
36 #define access_ok(type,addr,size) 1
39 * These are the main single-value transfer routines. They automatically
40 * use the right size if we just have the right pointer type.
43 #define get_user(x, p) \
44 ({ \
45 int __e = 0; \
46 unsigned long __gu_val; \
47 switch (sizeof(*(p))) { \
48 case 1: \
49 __get_user_asm_byte(__gu_val, p, __e); \
50 break; \
51 case 2: \
52 __get_user_asm_half(__gu_val, p, __e); \
53 break; \
54 case 4: \
55 __get_user_asm_word(__gu_val, p, __e); \
56 break; \
57 default: __e = __get_user_bad(); break; \
58 } \
59 (x) = (typeof(*(p)))__gu_val; \
60 __e; \
63 #define __get_user(x, ptr) get_user(x, ptr)
64 #define __get_user_error(x,ptr,err) get_user(x, ptr)
66 #define __get_user_asm_byte(x,addr,err) \
67 __asm__ __volatile__( \
68 "ldrbt %0,[%1],#0" \
69 : "=&r" (x) \
70 : "r" (addr) \
71 : "cc")
73 #ifndef __ARMEB__
74 #define __get_user_asm_half(x,__gu_addr,err) \
75 ({ \
76 unsigned long __b1, __b2; \
77 __get_user_asm_byte(__b1, __gu_addr, err); \
78 __get_user_asm_byte(__b2, __gu_addr + 1, err); \
79 (x) = __b1 | (__b2 << 8); \
81 #else
82 #define __get_user_asm_half(x,__gu_addr,err) \
83 ({ \
84 unsigned long __b1, __b2; \
85 __get_user_asm_byte(__b1, __gu_addr, err); \
86 __get_user_asm_byte(__b2, __gu_addr + 1, err); \
87 (x) = (__b1 << 8) | __b2; \
89 #endif
91 #define __get_user_asm_word(x,addr,err) \
92 __asm__ __volatile__( \
93 "ldrt %0,[%1],#0\n" \
94 : "=&r" (x) \
95 : "r" (addr) \
96 : "cc")
98 extern int __get_user_bad(void);
101 #define put_user(x, p) \
102 ({ \
103 int __e = 0; \
104 typeof(*(p)) __pu_val = (x); \
105 typeof(*(p)) __user *__p = (p);\
106 switch (sizeof(*(p))) { \
107 case 1: \
108 __put_user_asm_byte(__pu_val, __p, __e);\
109 break; \
110 case 2: \
111 __put_user_asm_half(__pu_val, __p, __e);\
112 break; \
113 case 4: \
114 __put_user_asm_word(__pu_val, __p, __e);\
115 break; \
116 case 8: \
117 __put_user_asm_dword(__pu_val, __p, __e);\
118 break; \
119 default: __e = __put_user_bad(); break; \
121 __e; \
124 #define __put_user(x, ptr) put_user(x, ptr)
125 #define __put_user_error(x,ptr,err) put_user(x, ptr)
127 #define __put_user_asm_byte(x,__pu_addr,err) \
128 __asm__ __volatile__( \
129 "strbt %0,[%1],#0\n" \
130 : /* none */ \
131 : "r" (x), "r" (__pu_addr) \
132 : "cc")
135 #ifndef __ARMEB__
136 #define __put_user_asm_half(x,__pu_addr,err) \
137 ({ \
138 unsigned long __temp = (unsigned long)(x); \
139 __put_user_asm_byte(__temp, __pu_addr, err); \
140 __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err); \
142 #else
143 #define __put_user_asm_half(x,__pu_addr,err) \
144 ({ \
145 unsigned long __temp = (unsigned long)(x); \
146 __put_user_asm_byte(__temp >> 8, __pu_addr, err); \
147 __put_user_asm_byte(__temp, __pu_addr + 1, err); \
149 #endif
151 #define __put_user_asm_word(x,__pu_addr,err) \
152 __asm__ __volatile__( \
153 "strt %0,[%1],#0" \
154 : /* none */ \
155 : "r" (x), "r" (__pu_addr) \
156 : "cc")
158 #ifndef __ARMEB__
159 #define __reg_oper0 "%R1"
160 #define __reg_oper1 "%Q1"
161 #else
162 #define __reg_oper0 "%Q1"
163 #define __reg_oper1 "%R1"
164 #endif
166 #define __put_user_asm_dword(x,__pu_addr,err) \
167 __asm__ __volatile__( \
168 "strt " __reg_oper1 ", [%0], #4\n" \
169 "strt " __reg_oper0 ", [%0], #0" \
170 : "+r" (__pu_addr) \
171 : "r" (x) \
172 : "cc")
174 extern int __put_user_bad(void);
176 #define copy_from_user(to, from, n) (memcpy(to, from, n), 0)
177 #define copy_to_user(to, from, n) (memcpy(to, from, n), 0)
178 #define clear_user(to, n) (memset(to, 0, n), 0)
180 #define __copy_from_user(to, from, n) copy_from_user(to, from, n)
181 #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
182 #define __clear_user(ptr, n) clear_user(ptr, n)
184 #define __copy_to_user_inatomic __copy_to_user
185 #define __copy_from_user_inatomic __copy_from_user
187 /* these are just for symbol compatibility */
188 static inline unsigned long __arch_copy_from_user (void *to, void *from, unsigned long n)
190 return copy_from_user(to, from, n);
193 static inline unsigned long __arch_copy_to_user (void *to, void *from, unsigned long n)
195 return copy_to_user(to, from, n);
198 static inline unsigned long __arch_clear_user(void *to, unsigned long n)
200 return clear_user(to, n);
203 #endif /* _ASMARM_UACCESS-NOMMU_H */