2 * linux/include/asm-arm/proc-armo/segment.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'
23 #define KERNEL_DS 0x03000000
24 #define USER_DS 0x02000000
26 extern uaccess_t uaccess_user, uaccess_kernel;
28 static inline void set_fs (mm_segment_t fs)
30 current->addr_limit = fs;
31 current->thread.uaccess = fs == USER_DS ? &uaccess_user : &uaccess_kernel;
34 #define __range_ok(addr,size) ({ \
35 unsigned long flag, sum; \
36 __asm__ __volatile__("subs %1, %0, %3; cmpcs %1, %2; movcs %0, #0" \
37 : "=&r" (flag), "=&r" (sum) \
38 : "r" (addr), "Ir" (size), "0" (current->addr_limit) \
42 #define __addr_ok(addr) ({ \
44 __asm__ __volatile__("cmp %2, %0; movlo %0, #0" \
46 : "0" (current->addr_limit), "r" (addr) \
50 #define __put_user_asm_byte(x,addr,err) \
51 __asm__ __volatile__( \
59 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_byte), \
61 : "r0", "r1", "r2", "lr")
63 #define __put_user_asm_half(x,addr,err) \
64 __asm__ __volatile__( \
72 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_half), \
74 : "r0", "r1", "r2", "lr")
76 #define __put_user_asm_word(x,addr,err) \
77 __asm__ __volatile__( \
85 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_word), \
87 : "r0", "r1", "r2", "lr")
89 #define __get_user_asm_byte(x,addr,err) \
90 __asm__ __volatile__( \
97 : "=r" (err), "=r" (x) \
98 : "r" (addr), "r" (current->thread.uaccess->get_byte), "0" (err) \
99 : "r0", "r1", "r2", "lr")
101 #define __get_user_asm_half(x,addr,err) \
102 __asm__ __volatile__( \
109 : "=r" (err), "=r" (x) \
110 : "r" (addr), "r" (current->thread.uaccess->get_half), "0" (err) \
111 : "r0", "r1", "r2", "lr")
113 #define __get_user_asm_word(x,addr,err) \
114 __asm__ __volatile__( \
121 : "=r" (err), "=r" (x) \
122 : "r" (addr), "r" (current->thread.uaccess->get_word), "0" (err) \
123 : "r0", "r1", "r2", "lr")
125 #define __do_copy_from_user(to,from,n) \
126 (n) = current->thread.uaccess->copy_from_user((to),(from),(n))
128 #define __do_copy_to_user(to,from,n) \
129 (n) = current->thread.uaccess->copy_to_user((to),(from),(n))
131 #define __do_clear_user(addr,sz) \
132 (sz) = current->thread.uaccess->clear_user((addr),(sz))
134 #define __do_strncpy_from_user(dst,src,count,res) \
135 (res) = current->thread.uaccess->strncpy_from_user(dst,src,count)
137 #define __do_strnlen_user(s,n,res) \
138 (res) = current->thread.uaccess->strnlen_user(s,n)