2 * linux/include/asm-arm/proc-armo/uaccess.h
4 * Copyright (C) 1996 Russell King
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.
12 * The fs functions are implemented on the ARM2 and ARM3 architectures
14 * Use *_user functions to access user memory with faulting behaving
15 * as though the user is accessing the memory.
16 * Use set_fs(get_ds()) and then the *_user functions to allow them to
17 * access kernel memory.
21 * These are the values used to represent the user `fs' and the kernel `ds'
22 * FIXME - the KERNEL_DS should end at 0x03000000 but we want to access ROM at
23 * 0x03400000. ideally we want to forbid access to the IO space inbetween.
25 #define KERNEL_DS 0x03FFFFFF
26 #define USER_DS 0x02000000
28 extern uaccess_t uaccess_user
, uaccess_kernel
;
30 static inline void set_fs (mm_segment_t fs
)
32 current_thread_info()->addr_limit
= fs
;
33 current
->thread
.uaccess
= (fs
== USER_DS
? &uaccess_user
: &uaccess_kernel
);
36 #define __range_ok(addr,size) ({ \
37 unsigned long flag, sum; \
38 __asm__ __volatile__("subs %1, %0, %3; cmpcs %1, %2; movcs %0, #0" \
39 : "=&r" (flag), "=&r" (sum) \
40 : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
44 #define __addr_ok(addr) ({ \
46 __asm__ __volatile__("cmp %2, %0; movlo %0, #0" \
48 : "0" (current_thread_info()->addr_limit), "r" (addr) \
52 #define __put_user_asm_byte(x,addr,err) \
53 __asm__ __volatile__( \
61 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_byte), \
63 : "r0", "r1", "r2", "lr")
65 #define __put_user_asm_half(x,addr,err) \
66 __asm__ __volatile__( \
74 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_half), \
76 : "r0", "r1", "r2", "lr")
78 #define __put_user_asm_word(x,addr,err) \
79 __asm__ __volatile__( \
87 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_word), \
89 : "r0", "r1", "r2", "lr")
91 #define __put_user_asm_dword(x,addr,err) \
92 __asm__ __volatile__( \
100 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_dword), \
102 : "r0", "r1", "r2", "lr")
104 #define __get_user_asm_byte(x,addr,err) \
105 __asm__ __volatile__( \
112 : "=r" (err), "=r" (x) \
113 : "r" (addr), "r" (current->thread.uaccess->get_byte), "0" (err) \
114 : "r0", "r1", "r2", "lr")
116 #define __get_user_asm_half(x,addr,err) \
117 __asm__ __volatile__( \
124 : "=r" (err), "=r" (x) \
125 : "r" (addr), "r" (current->thread.uaccess->get_half), "0" (err) \
126 : "r0", "r1", "r2", "lr")
128 #define __get_user_asm_word(x,addr,err) \
129 __asm__ __volatile__( \
136 : "=r" (err), "=r" (x) \
137 : "r" (addr), "r" (current->thread.uaccess->get_word), "0" (err) \
138 : "r0", "r1", "r2", "lr")
140 #define __do_copy_from_user(to,from,n) \
141 (n) = current->thread.uaccess->copy_from_user((to),(from),(n))
143 #define __do_copy_to_user(to,from,n) \
144 (n) = current->thread.uaccess->copy_to_user((to),(from),(n))
146 #define __do_clear_user(addr,sz) \
147 (sz) = current->thread.uaccess->clear_user((addr),(sz))
149 #define __do_strncpy_from_user(dst,src,count,res) \
150 (res) = current->thread.uaccess->strncpy_from_user(dst,src,count)
152 #define __do_strnlen_user(s,n,res) \
153 (res) = current->thread.uaccess->strnlen_user(s,n)