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.
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) \
46 unsigned long __gu_val; \
47 switch (sizeof(*(p))) { \
49 __get_user_asm_byte(__gu_val, p, __e); \
52 __get_user_asm_half(__gu_val, p, __e); \
55 __get_user_asm_word(__gu_val, p, __e); \
57 default: __e = __get_user_bad(); break; \
59 (x) = (typeof(*(p)))__gu_val; \
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__( \
74 #define __get_user_asm_half(x,__gu_addr,err) \
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); \
82 #define __get_user_asm_half(x,__gu_addr,err) \
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; \
91 #define __get_user_asm_word(x,addr,err) \
92 __asm__ __volatile__( \
98 extern int __get_user_bad(void);
101 #define put_user(x, p) \
104 typeof(*(p)) __pu_val = (x); \
105 typeof(*(p)) __user *__p = (p);\
106 switch (sizeof(*(p))) { \
108 __put_user_asm_byte(__pu_val, __p, __e);\
111 __put_user_asm_half(__pu_val, __p, __e);\
114 __put_user_asm_word(__pu_val, __p, __e);\
117 __put_user_asm_dword(__pu_val, __p, __e);\
119 default: __e = __put_user_bad(); break; \
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" \
131 : "r" (x), "r" (__pu_addr) \
136 #define __put_user_asm_half(x,__pu_addr,err) \
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); \
143 #define __put_user_asm_half(x,__pu_addr,err) \
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); \
151 #define __put_user_asm_word(x,__pu_addr,err) \
152 __asm__ __volatile__( \
155 : "r" (x), "r" (__pu_addr) \
159 #define __reg_oper0 "%R1"
160 #define __reg_oper1 "%Q1"
162 #define __reg_oper0 "%Q1"
163 #define __reg_oper1 "%R1"
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" \
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 */