Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney...
[linux-2.6] / arch / arm / lib / io-writesb.S
1 /*
2  *  linux/arch/arm/lib/io-writesb.S
3  *
4  *  Copyright (C) 1995-2000 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/linkage.h>
11 #include <asm/assembler.h>
12
13                 .macro  outword, rd
14 #ifndef __ARMEB__
15                 strb    \rd, [r0]
16                 mov     \rd, \rd, lsr #8
17                 strb    \rd, [r0]
18                 mov     \rd, \rd, lsr #8
19                 strb    \rd, [r0]
20                 mov     \rd, \rd, lsr #8
21                 strb    \rd, [r0]
22 #else
23                 mov     lr, \rd, lsr #24
24                 strb    lr, [r0]
25                 mov     lr, \rd, lsr #16
26                 strb    lr, [r0]
27                 mov     lr, \rd, lsr #8
28                 strb    lr, [r0]
29                 strb    \rd, [r0]
30 #endif
31                 .endm
32
33 .Loutsb_align:  rsb     ip, ip, #4
34                 cmp     ip, r2
35                 movgt   ip, r2
36                 cmp     ip, #2
37                 ldrb    r3, [r1], #1
38                 strb    r3, [r0]
39                 ldrgeb  r3, [r1], #1
40                 strgeb  r3, [r0]
41                 ldrgtb  r3, [r1], #1
42                 strgtb  r3, [r0]
43                 subs    r2, r2, ip
44                 bne     .Loutsb_aligned
45
46 ENTRY(__raw_writesb)
47                 teq     r2, #0          @ do we have to check for the zero len?
48                 moveq   pc, lr
49                 ands    ip, r1, #3
50                 bne     .Loutsb_align
51
52 .Loutsb_aligned:
53                 stmfd   sp!, {r4, r5, lr}
54
55                 subs    r2, r2, #16
56                 bmi     .Loutsb_no_16
57
58 .Loutsb_16_lp:  ldmia   r1!, {r3, r4, r5, ip}
59                 outword r3
60                 outword r4
61                 outword r5
62                 outword ip
63                 subs    r2, r2, #16
64                 bpl     .Loutsb_16_lp
65
66                 tst     r2, #15
67                 ldmeqfd sp!, {r4, r5, pc}
68
69 .Loutsb_no_16:  tst     r2, #8
70                 beq     .Loutsb_no_8
71
72                 ldmia   r1!, {r3, r4}
73                 outword r3
74                 outword r4
75
76 .Loutsb_no_8:   tst     r2, #4
77                 beq     .Loutsb_no_4
78
79                 ldr     r3, [r1], #4
80                 outword r3
81
82 .Loutsb_no_4:   ands    r2, r2, #3
83                 ldmeqfd sp!, {r4, r5, pc}
84
85                 cmp     r2, #2
86                 ldrb    r3, [r1], #1
87                 strb    r3, [r0]
88                 ldrgeb  r3, [r1], #1
89                 strgeb  r3, [r0]
90                 ldrgtb  r3, [r1]
91                 strgtb  r3, [r0]
92
93                 ldmfd   sp!, {r4, r5, pc}
94 ENDPROC(__raw_writesb)