2 * linux/arch/arm/lib/memset.S
4 * Copyright (C) 1995-2000 Russell King
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.
10 * ASM optimised string functions
12 #include <linux/linkage.h>
13 #include <asm/assembler.h>
14 #include <asm/unwind.h>
22 ands r3, r0, #3 @ 1 unaligned?
23 mov ip, r0 @ preserve r0 as return value
26 * we know that the pointer in ip is aligned to a word boundary.
28 1: orr r1, r1, r1, lsl #8
29 orr r1, r1, r1, lsl #16
37 * We need 2 extra registers for this loop - use r8 and the LR
42 UNWIND( .save {r8, lr} )
47 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
48 stmgeia ip!, {r1, r3, r8, lr}
49 stmgeia ip!, {r1, r3, r8, lr}
50 stmgeia ip!, {r1, r3, r8, lr}
52 ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
54 * No need to correct the count; we're only testing bits from now on
57 stmneia ip!, {r1, r3, r8, lr}
58 stmneia ip!, {r1, r3, r8, lr}
60 stmneia ip!, {r1, r3, r8, lr}
67 * This version aligns the destination pointer in order to write
68 * whole cache lines at once.
71 stmfd sp!, {r4-r8, lr}
74 UNWIND( .save {r4-r8, lr} )
89 movs r8, r8, lsl #(32 - 4)
90 stmcsia ip!, {r4, r5, r6, r7}
97 stmgeia ip!, {r1, r3-r8, lr}
98 stmgeia ip!, {r1, r3-r8, lr}
100 ldmeqfd sp!, {r4-r8, pc}
103 stmneia ip!, {r1, r3-r8, lr}
106 ldmfd sp!, {r4-r8, lr}
113 stmneia ip!, {r1, r3}
117 * When we get here, we've got less than 4 bytes to set. We
118 * may have an unaligned pointer as well.
127 6: subs r2, r2, #4 @ 1 do we have enough
128 blt 5b @ 1 bytes to align with?
130 strltb r1, [ip], #1 @ 1
131 strleb r1, [ip], #1 @ 1
132 strb r1, [ip], #1 @ 1
133 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))
141 mov r3, r1 @ copy r1 to r3 and fall into memset64
146 mov ip, r0 @ preserve r0 as return value
147 b 7b @ jump into the middle of memset