# BRCM_VERSION=3
[bcm963xx.git] / kernel / linux / arch / arm26 / 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/asm_offsets.h>
30 #include <asm/thread_info.h>
31
32         .global __put_user_1
33 __put_user_1:
34         bic     r2, sp, #0x1f00
35         bic     r2, r2, #0x00ff
36         str     lr, [sp, #-4]!
37         ldr     r2, [r2, #TI_ADDR_LIMIT]
38         sub     r2, r2, #1
39         cmp     r0, r2
40         bge     __put_user_bad
41 1:      cmp     r0, #0x02000000
42         strlsbt r1, [r0]
43         strgeb  r1, [r0]
44         mov     r0, #0
45         ldmfd   sp!, {pc}^
46
47         .global __put_user_2
48 __put_user_2:
49         bic     r2, sp, #0x1f00
50         bic     r2, r2, #0x00ff
51         str     lr, [sp, #-4]!
52         ldr     r2, [r2, #TI_ADDR_LIMIT]
53         sub     r2, r2, #2
54         cmp     r0, r2
55         bge     __put_user_bad
56 2:      cmp     r0, #0x02000000
57         strlsbt r1, [r0], #1
58         strgeb  r1, [r0], #1
59         mov     r1, r1, lsr #8
60 3:      strlsbt r1, [r0]
61         strgeb  r1, [r0]
62         mov     r0, #0
63         ldmfd   sp!, {pc}^
64
65         .global __put_user_4
66 __put_user_4:
67         bic     r2, sp, #0x1f00
68         bic     r2, r2, #0x00ff
69         str     lr, [sp, #-4]!
70         ldr     r2, [r2, #TI_ADDR_LIMIT]
71         sub     r2, r2, #4
72         cmp     r0, r2
73 4:      bge     __put_user_bad
74         cmp     r0, #0x02000000
75         strlst  r1, [r0]
76         strge   r1, [r0]
77         mov     r0, #0
78         ldmfd   sp!, {pc}^
79
80         .global __put_user_8
81 __put_user_8:
82         bic     ip, sp, #0x1f00
83         bic     ip, ip, #0x00ff
84         str     lr, [sp, #-4]!
85         ldr     ip, [ip, #TI_ADDR_LIMIT]
86         sub     ip, ip, #8
87         cmp     r0, ip
88         bge     __put_user_bad
89         cmp     r0, #0x02000000
90 5:      strlst  r1, [r0], #4
91 6:      strlst  r2, [r0]
92         strge   r1, [r0], #4
93         strge   r2, [r0]
94         mov     r0, #0
95         ldmfd   sp!, {pc}^
96
97 __put_user_bad:
98         mov     r0, #-14
99         mov     pc, lr
100
101 .section __ex_table, "a"
102         .long   1b, __put_user_bad
103         .long   2b, __put_user_bad
104         .long   3b, __put_user_bad
105         .long   4b, __put_user_bad
106         .long   5b, __put_user_bad
107         .long   6b, __put_user_bad
108 .previous