http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / arch / arm / lib / putuser.S
1 /*
2  *  linux/arch/arm/lib/putuser.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
13  * them more efficient, especially as they return an error
14  * value in addition to the "real" return value.
15  *
16  * __put_user_X
17  *
18  * Inputs:      r0 contains the address
19  *              r1, r2 contains the value
20  * Outputs:     r0 is the error code
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 __put_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 __put_user_1
34 __put_user_1:
35         bic     ip, sp, #0x1f00
36         bic     ip, ip, #0x00ff
37         ldr     ip, [ip, #TI_ADDR_LIMIT]
38         sub     ip, ip, #1
39         cmp     r0, ip
40 1:      strlsbt r1, [r0]
41         movls   r0, #0
42         movls   pc, lr
43         b       __put_user_bad
44
45         .global __put_user_2
46 __put_user_2:
47         bic     ip, sp, #0x1f00
48         bic     ip, ip, #0x00ff
49         ldr     ip, [ip, #TI_ADDR_LIMIT]
50         sub     ip, ip, #2
51         cmp     r0, ip
52         movls   ip, r1, lsr #8
53 #ifndef __ARMEB__
54 2:      strlsbt r1, [r0], #1
55 3:      strlsbt ip, [r0]
56 #else
57 2:      strlsbt ip, [r0], #1
58 3:      strlsbt r1, [r0]
59 #endif
60         movls   r0, #0
61         movls   pc, lr
62         b       __put_user_bad
63
64         .global __put_user_4
65 __put_user_4:
66         bic     ip, sp, #0x1f00
67         bic     ip, ip, #0x00ff
68         ldr     ip, [ip, #TI_ADDR_LIMIT]
69         sub     ip, ip, #4
70         cmp     r0, ip
71 4:      strlst  r1, [r0]
72         movls   r0, #0
73         movls   pc, lr
74         b       __put_user_bad
75
76         .global __put_user_8
77 __put_user_8:
78         bic     ip, sp, #0x1f00
79         bic     ip, ip, #0x00ff
80         ldr     ip, [ip, #TI_ADDR_LIMIT]
81         sub     ip, ip, #8
82         cmp     r0, ip
83 5:      strlst  r1, [r0], #4
84 6:      strlst  r2, [r0]
85         movls   r0, #0
86         movls   pc, lr
87
88         /* fall through */
89
90 __put_user_bad:
91         mov     r0, #-EFAULT
92         mov     pc, lr
93
94 .section __ex_table, "a"
95         .long   1b, __put_user_bad
96         .long   2b, __put_user_bad
97         .long   3b, __put_user_bad
98         .long   4b, __put_user_bad
99         .long   5b, __put_user_bad
100         .long   6b, __put_user_bad
101 .previous