import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / 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
31         .global __put_user_1
32 __put_user_1:
33         bic     r2, sp, #0x1f00
34         bic     r2, r2, #0x00ff
35         ldr     r2, [r2, #TSK_ADDR_LIMIT]
36         sub     r2, r2, #1
37         cmp     r0, r2
38 1:      strlsbt r1, [r0]
39         movls   r0, #0
40         movls   pc, lr
41         b       __put_user_bad
42
43         .global __put_user_2
44 __put_user_2:
45         bic     r2, sp, #0x1f00
46         bic     r2, r2, #0x00ff
47         ldr     r2, [r2, #TSK_ADDR_LIMIT]
48         sub     r2, r2, #2
49         cmp     r0, r2
50 2:      strlsbt r1, [r0], #1
51         movls   r1, r1, lsr #8
52 3:      strlsbt r1, [r0]
53         movls   r0, #0
54         movls   pc, lr
55         b       __put_user_bad
56
57         .global __put_user_4
58 __put_user_4:
59         bic     r2, sp, #0x1f00
60         bic     r2, r2, #0x00ff
61         ldr     r2, [r2, #TSK_ADDR_LIMIT]
62         sub     r2, r2, #4
63         cmp     r0, r2
64 4:      strlst  r1, [r0]
65         movls   r0, #0
66         movls   pc, lr
67         b       __put_user_bad
68
69         .global __put_user_8
70 __put_user_8:
71         bic     ip, sp, #0x1f00
72         bic     ip, ip, #0x00ff
73         ldr     ip, [ip, #TSK_ADDR_LIMIT]
74         sub     ip, ip, #8
75         cmp     r0, ip
76 5:      strlst  r1, [r0], #4
77 6:      strlst  r2, [r0]
78         movls   r0, #0
79         movls   pc, lr
80
81         /* fall through */
82
83 __put_user_bad:
84         mov     r0, #-14
85         mov     pc, lr
86
87 .section __ex_table, "a"
88         .long   1b, __put_user_bad
89         .long   2b, __put_user_bad
90         .long   3b, __put_user_bad
91         .long   4b, __put_user_bad
92         .long   5b, __put_user_bad
93         .long   6b, __put_user_bad
94 .previous