# BRCM_VERSION=3
[bcm963xx.git] / kernel / linux / arch / arm / lib / getuser.S
1 /*
2  *  linux/arch/arm/lib/getuser.S
3  *
4  *  Copyright (C) 2001 Russell King
5  *
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.
9  *
10  *  Idea from x86 version, (C) Copyright 1998 Linus Torvalds
11  *
12  * These functions have a non-standard call interface to make them more
13  * efficient, especially as they return an error value in addition to
14  * the "real" return value.
15  *
16  * __get_user_X
17  *
18  * Inputs:      r0 contains the address
19  * Outputs:     r0 is the error code
20  *              r1, r2 contains the zero-extended value
21  *              lr corrupted
22  *
23  * No other registers must be altered.  (see include/asm-arm/uaccess.h
24  * for specific ASM register usage).
25  *
26  * Note that ADDR_LIMIT is either 0 or 0xc0000000.
27  * Note also that it is intended that __get_user_bad is not global.
28  */
29 #include <asm/constants.h>
30 #include <asm/thread_info.h>
31 #include <asm/errno.h>
32
33         .global __get_user_1
34 __get_user_1:
35         bic     r1, sp, #0x1f00
36         bic     r1, r1, #0x00ff
37         ldr     r1, [r1, #TI_ADDR_LIMIT]
38         sub     r1, r1, #1
39         cmp     r0, r1
40 1:      ldrlsbt r1, [r0]
41         movls   r0, #0
42         movls   pc, lr
43         b       __get_user_bad
44
45         .global __get_user_2
46 __get_user_2:
47         bic     r2, sp, #0x1f00
48         bic     r2, r2, #0x00ff
49         ldr     r2, [r2, #TI_ADDR_LIMIT]
50         sub     r2, r2, #2
51         cmp     r0, r2
52 2:      ldrlsbt r1, [r0], #1
53 3:      ldrlsbt r2, [r0]
54 #ifndef __ARMEB__
55         orrls   r1, r1, r2, lsl #8
56 #else
57         orrls   r1, r2, r1, lsl #8
58 #endif
59         movls   r0, #0
60         movls   pc, lr
61         b       __get_user_bad
62
63         .global __get_user_4
64 __get_user_4:
65         bic     r1, sp, #0x1f00
66         bic     r1, r1, #0x00ff
67         ldr     r1, [r1, #TI_ADDR_LIMIT]
68         sub     r1, r1, #4
69         cmp     r0, r1
70 4:      ldrlst  r1, [r0]
71         movls   r0, #0
72         movls   pc, lr
73         b       __get_user_bad
74
75         .global __get_user_8
76 __get_user_8:
77         bic     r2, sp, #0x1f00
78         bic     r2, r2, #0x00ff
79         ldr     r2, [r2, #TI_ADDR_LIMIT]
80         sub     r2, r2, #8
81         cmp     r0, r2
82 5:      ldrlst  r1, [r0], #4
83 6:      ldrlst  r2, [r0]
84         movls   r0, #0
85         movls   pc, lr
86
87         /* fall through */
88
89 __get_user_bad_8:
90         mov     r2, #0
91 __get_user_bad:
92         mov     r1, #0
93         mov     r0, #-EFAULT
94         mov     pc, lr
95
96 .section __ex_table, "a"
97         .long   1b, __get_user_bad
98         .long   2b, __get_user_bad
99         .long   3b, __get_user_bad
100         .long   4b, __get_user_bad
101         .long   5b, __get_user_bad_8
102         .long   6b, __get_user_bad_8
103 .previous