2 * User address space access functions.
3 * The non inlined parts of asm-i386/uaccess.h are here.
5 * Copyright 1997 Andi Kleen <ak@muc.de>
6 * Copyright 1997 Linus Torvalds
8 #include <asm/uaccess.h>
11 __generic_copy_to_user(void *to
, const void *from
, unsigned long n
)
13 if ((unsigned long) to
< TASK_SIZE
)
15 if (access_ok(VERIFY_WRITE
, to
, n
))
16 __copy_user(to
,from
,n
);
21 __generic_copy_from_user(void *to
, const void *from
, unsigned long n
)
23 if ((unsigned long) from
< TASK_SIZE
)
25 if (access_ok(VERIFY_READ
, from
, n
))
26 __copy_user(to
,from
,n
);
32 * Copy a null terminated string from userspace.
35 #define __do_strncpy_from_user(dst,src,count,res) \
36 __asm__ __volatile__( \
41 " testb %%al,%%al\n" \
47 ".section .fixup,\"ax\"\n" \
51 ".section __ex_table,\"a\"\n" \
55 : "=d"(res), "=c"(count) \
56 : "i"(-EFAULT), "0"(count), "1"(count), "S"(src), "D"(dst) \
57 : "si", "di", "ax", "memory")
60 __strncpy_from_user(char *dst
, const char *src
, long count
)
64 __do_strncpy_from_user(dst
, src
, count
, res
);
69 strncpy_from_user(char *dst
, const char *src
, long count
)
73 if (access_ok(VERIFY_READ
, src
, 1))
74 __do_strncpy_from_user(dst
, src
, count
, res
);
83 #define __do_clear_user(addr,size) \
84 __asm__ __volatile__( \
89 ".section .fixup,\"ax\"\n" \
90 "3: lea 0(%1,%0,4),%0\n" \
93 ".section __ex_table,\"a\"\n" \
99 : "r"(size & 3), "0"(size / 4), "D"(addr), "a"(0) \
103 clear_user(void *to
, unsigned long n
)
106 if (access_ok(VERIFY_WRITE
, to
, n
))
107 __do_clear_user(to
, n
);
112 __clear_user(void *to
, unsigned long n
)
115 __do_clear_user(to
, n
);
120 * Return the size of a string (including the ending 0)
125 long strlen_user(const char *s
)
130 __asm__
__volatile__(
134 ".section .fixup,\"ax\"\n"
138 ".section __ex_table,\"a\"\n"
142 :"=c" (res
), "=D" (s
)
143 :"1" (s
), "a" (0), "0" (-__addr_ok(s
)));
144 return res
& -__addr_ok(s
);