Linux-2.6.12-rc2
[pandora-kernel.git] / arch / i386 / lib / getuser.S
1 /*
2  * __get_user functions.
3  *
4  * (C) Copyright 1998 Linus Torvalds
5  *
6  * These functions have a non-standard call interface
7  * to make them more efficient, especially as they
8  * return an error value in addition to the "real"
9  * return value.
10  */
11 #include <asm/thread_info.h>
12
13
14 /*
15  * __get_user_X
16  *
17  * Inputs:      %eax contains the address
18  *
19  * Outputs:     %eax is error code (0 or -EFAULT)
20  *              %edx contains zero-extended value
21  *
22  * These functions should not modify any other registers,
23  * as they get called from within inline assembly.
24  */
25
26 .text
27 .align 4
28 .globl __get_user_1
29 __get_user_1:
30         GET_THREAD_INFO(%edx)
31         cmpl TI_addr_limit(%edx),%eax
32         jae bad_get_user
33 1:      movzbl (%eax),%edx
34         xorl %eax,%eax
35         ret
36
37 .align 4
38 .globl __get_user_2
39 __get_user_2:
40         addl $1,%eax
41         jc bad_get_user
42         GET_THREAD_INFO(%edx)
43         cmpl TI_addr_limit(%edx),%eax
44         jae bad_get_user
45 2:      movzwl -1(%eax),%edx
46         xorl %eax,%eax
47         ret
48
49 .align 4
50 .globl __get_user_4
51 __get_user_4:
52         addl $3,%eax
53         jc bad_get_user
54         GET_THREAD_INFO(%edx)
55         cmpl TI_addr_limit(%edx),%eax
56         jae bad_get_user
57 3:      movl -3(%eax),%edx
58         xorl %eax,%eax
59         ret
60
61 bad_get_user:
62         xorl %edx,%edx
63         movl $-14,%eax
64         ret
65
66 .section __ex_table,"a"
67         .long 1b,bad_get_user
68         .long 2b,bad_get_user
69         .long 3b,bad_get_user
70 .previous