OMAP: Add new function to check wether there is irq pending
[linux-ginger.git] / arch / arm / lib / csumpartialcopyuser.S
blob14677fb4b0c4f504bc09ba19e2dcc5acd3362393
1 /*
2  *  linux/arch/arm/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  * 27/03/03 Ian Molton Clean up CONFIG_CPU
11  *
12  */
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
15 #include <asm/errno.h>
16 #include <asm/asm-offsets.h>
18                 .text
20                 .macro  save_regs
21                 stmfd   sp!, {r1, r2, r4 - r8, lr}
22                 .endm
24                 .macro  load_regs
25                 ldmfd   sp!, {r1, r2, r4 - r8, pc}
26                 .endm
28                 .macro  load1b, reg1
29 9999:           ldrbt   \reg1, [r0], $1
30                 .section __ex_table, "a"
31                 .align  3
32                 .long   9999b, 6001f
33                 .previous
34                 .endm
36                 .macro  load2b, reg1, reg2
37 9999:           ldrbt   \reg1, [r0], $1
38 9998:           ldrbt   \reg2, [r0], $1
39                 .section __ex_table, "a"
40                 .long   9999b, 6001f
41                 .long   9998b, 6001f
42                 .previous
43                 .endm
45                 .macro  load1l, reg1
46 9999:           ldrt    \reg1, [r0], $4
47                 .section __ex_table, "a"
48                 .align  3
49                 .long   9999b, 6001f
50                 .previous
51                 .endm
53                 .macro  load2l, reg1, reg2
54 9999:           ldrt    \reg1, [r0], $4
55 9998:           ldrt    \reg2, [r0], $4
56                 .section __ex_table, "a"
57                 .long   9999b, 6001f
58                 .long   9998b, 6001f
59                 .previous
60                 .endm
62                 .macro  load4l, reg1, reg2, reg3, reg4
63 9999:           ldrt    \reg1, [r0], $4
64 9998:           ldrt    \reg2, [r0], $4
65 9997:           ldrt    \reg3, [r0], $4
66 9996:           ldrt    \reg4, [r0], $4
67                 .section __ex_table, "a"
68                 .long   9999b, 6001f
69                 .long   9998b, 6001f
70                 .long   9997b, 6001f
71                 .long   9996b, 6001f
72                 .previous
73                 .endm
76  * unsigned int
77  * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr)
78  *  r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr
79  *  Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
80  */
82 #define FN_ENTRY        ENTRY(csum_partial_copy_from_user)
83 #define FN_EXIT         ENDPROC(csum_partial_copy_from_user)
85 #include "csumpartialcopygeneric.S"
88  * FIXME: minor buglet here
89  * We don't return the checksum for the data present in the buffer.  To do
90  * so properly, we would have to add in whatever registers were loaded before
91  * the fault, which, with the current asm above is not predictable.
92  */
93                 .section .fixup,"ax"
94                 .align  4
95 6001:           mov     r4, #-EFAULT
96                 ldr     r5, [fp, #4]            @ *err_ptr
97                 str     r4, [r5]
98                 ldmia   sp, {r1, r2}            @ retrieve dst, len
99                 add     r2, r2, r1
100                 mov     r0, #0                  @ zero the buffer
101 6002:           teq     r2, r1
102                 strneb  r0, [r1], #1
103                 bne     6002b
104                 load_regs
105                 .previous