GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / lib / memset.S
blob800605924c28ba6e2d6ce490057c5543621d847f
1 /* Modified by Broadcom Corp. Portions Copyright (c) Broadcom Corp, 2012. */
2 /*
3  *  linux/arch/arm/lib/memset.S
4  *
5  *  Copyright (C) 1995-2000 Russell King
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  *  ASM optimised string functions
12  */
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
16         .text
17         .section .text.fastpath, "a"
18         .align  5
19         .word   0
21 1:      subs    r2, r2, #4              @ 1 do we have enough
22         blt     5f                      @ 1 bytes to align with?
23         cmp     r3, #2                  @ 1
24         strltb  r1, [r0], #1            @ 1
25         strleb  r1, [r0], #1            @ 1
26         strb    r1, [r0], #1            @ 1
27         add     r2, r2, r3              @ 1 (r2 = r2 - (4 - r3))
29  * The pointer is now aligned and the length is adjusted.  Try doing the
30  * memset again.
31  */
33 ENTRY(memset)
34         ands    r3, r0, #3              @ 1 unaligned?
35         bne     1b                      @ 1
37  * we know that the pointer in r0 is aligned to a word boundary.
38  */
39         orr     r1, r1, r1, lsl #8
40         orr     r1, r1, r1, lsl #16
41         mov     r3, r1
42         cmp     r2, #16
43         blt     4f
45 #if ! CALGN(1)+0
48  * We need an extra register for this loop - save the return address and
49  * use the LR
50  */
51         str     lr, [sp, #-4]!
52         mov     ip, r1
53         mov     lr, r1
55 2:      subs    r2, r2, #64
56         stmgeia r0!, {r1, r3, ip, lr}   @ 64 bytes at a time.
57         stmgeia r0!, {r1, r3, ip, lr}
58         stmgeia r0!, {r1, r3, ip, lr}
59         stmgeia r0!, {r1, r3, ip, lr}
60         bgt     2b
61         ldmeqfd sp!, {pc}               @ Now <64 bytes to go.
63  * No need to correct the count; we're only testing bits from now on
64  */
65         tst     r2, #32
66         stmneia r0!, {r1, r3, ip, lr}
67         stmneia r0!, {r1, r3, ip, lr}
68         tst     r2, #16
69         stmneia r0!, {r1, r3, ip, lr}
70         ldr     lr, [sp], #4
72 #else
75  * This version aligns the destination pointer in order to write
76  * whole cache lines at once.
77  */
79         stmfd   sp!, {r4-r7, lr}
80         mov     r4, r1
81         mov     r5, r1
82         mov     r6, r1
83         mov     r7, r1
84         mov     ip, r1
85         mov     lr, r1
87         cmp     r2, #96
88         tstgt   r0, #31
89         ble     3f
91         and     ip, r0, #31
92         rsb     ip, ip, #32
93         sub     r2, r2, ip
94         movs    ip, ip, lsl #(32 - 4)
95         stmcsia r0!, {r4, r5, r6, r7}
96         stmmiia r0!, {r4, r5}
97         tst     ip, #(1 << 30)
98         mov     ip, r1
99         strne   r1, [r0], #4
101 3:      subs    r2, r2, #64
102         stmgeia r0!, {r1, r3-r7, ip, lr}
103         stmgeia r0!, {r1, r3-r7, ip, lr}
104         bgt     3b
105         ldmeqfd sp!, {r4-r7, pc}
107         tst     r2, #32
108         stmneia r0!, {r1, r3-r7, ip, lr}
109         tst     r2, #16
110         stmneia r0!, {r4-r7}
111         ldmfd   sp!, {r4-r7, lr}
113 #endif
115 4:      tst     r2, #8
116         stmneia r0!, {r1, r3}
117         tst     r2, #4
118         strne   r1, [r0], #4
120  * When we get here, we've got less than 4 bytes to zero.  We
121  * may have an unaligned pointer as well.
122  */
123 5:      tst     r2, #2
124         strneb  r1, [r0], #1
125         strneb  r1, [r0], #1
126         tst     r2, #1
127         strneb  r1, [r0], #1
128         mov     pc, lr
129 ENDPROC(memset)