Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / arm26 / lib / csumpartialcopyuser.S
blob5b821188e4792934a00a9be6903c379097f9b2cf
1 /*
2  *  linux/arch/arm26/lib/csumpartialcopyuser.S
3  *
4  *  Copyright (C) 1995-1998 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 #include <linux/config.h>
11 #include <linux/linkage.h>
12 #include <asm/assembler.h>
13 #include <asm/errno.h>
14 #include <asm/asm_offsets.h>
16                 .text
18                 .macro  save_regs
19                 stmfd   sp!, {r1 - r2, r4 - r9, fp, ip, lr, pc}
20                 mov     r9, sp, lsr #13
21                 mov     r9, r9, lsl #13
22                 ldr     r9, [r9, #TSK_ADDR_LIMIT]
23                 mov     r9, r9, lsr #24
24                 .endm
26                 .macro  load_regs,flags
27                 ldm\flags       fp, {r1, r2, r4-r9, fp, sp, pc}^
28                 .endm
30                 .macro  load1b, reg1
31                 tst     r9, #0x01
32 9999:           ldreqbt \reg1, [r0], #1
33                 ldrneb  \reg1, [r0], #1
34                 .section __ex_table, "a"
35                 .align  3
36                 .long   9999b, 6001f
37                 .previous
38                 .endm
40                 .macro  load2b, reg1, reg2
41                 tst     r9, #0x01
42 9999:           ldreqbt \reg1, [r0], #1
43                 ldrneb  \reg1, [r0], #1
44 9998:           ldreqbt \reg2, [r0], #1
45                 ldrneb  \reg2, [r0], #1
46                 .section __ex_table, "a"
47                 .long   9999b, 6001f
48                 .long   9998b, 6001f
49                 .previous
50                 .endm
52                 .macro  load1l, reg1
53                 tst     r9, #0x01
54 9999:           ldreqt  \reg1, [r0], #4
55                 ldrne   \reg1, [r0], #4
56                 .section __ex_table, "a"
57                 .align  3
58                 .long   9999b, 6001f
59                 .previous
60                 .endm
62                 .macro  load2l, reg1, reg2
63                 tst     r9, #0x01
64                 ldmneia r0!, {\reg1, \reg2}
65 9999:           ldreqt  \reg1, [r0], #4
66 9998:           ldreqt  \reg2, [r0], #4
67                 .section __ex_table, "a"
68                 .long   9999b, 6001f
69                 .long   9998b, 6001f
70                 .previous
71                 .endm
73                 .macro  load4l, reg1, reg2, reg3, reg4
74                 tst     r9, #0x01
75                 ldmneia r0!, {\reg1, \reg2, \reg3, \reg4}
76 9999:           ldreqt  \reg1, [r0], #4
77 9998:           ldreqt  \reg2, [r0], #4
78 9997:           ldreqt  \reg3, [r0], #4
79 9996:           ldreqt  \reg4, [r0], #4
80                 .section __ex_table, "a"
81                 .long   9999b, 6001f
82                 .long   9998b, 6001f
83                 .long   9997b, 6001f
84                 .long   9996b, 6001f
85                 .previous
86                 .endm
89  * unsigned int
90  * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr)
91  *  r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr
92  *  Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
93  */
95 #define FN_ENTRY        ENTRY(csum_partial_copy_from_user)
97 #include "csumpartialcopygeneric.S"
100  * FIXME: minor buglet here
101  * We don't return the checksum for the data present in the buffer.  To do
102  * so properly, we would have to add in whatever registers were loaded before
103  * the fault, which, with the current asm above is not predictable.
104  */
105                 .align  4
106 6001:           mov     r4, #-EFAULT
107                 ldr     r5, [fp, #4]            @ *err_ptr
108                 str     r4, [r5]
109                 ldmia   sp, {r1, r2}            @ retrieve dst, len
110                 add     r2, r2, r1
111                 mov     r0, #0                  @ zero the buffer
112 6002:           teq     r2, r1
113                 strneb  r0, [r1], #1
114                 bne     6002b
115                 load_regs       ea