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>
21 ands r3, r0, #3 @ 1 unaligned?
22 mov ip, r0 @ preserve r0 as return value
25 * we know that the pointer in ip is aligned to a word boundary.
27 1: orr r1, r1, r1, lsl #8
28 orr r1, r1, r1, lsl #16
36 * We need 2 extra registers for this loop - use r8 and the LR
41 UNWIND( .save {r8, lr} )
46 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
47 stmgeia ip!, {r1, r3, r8, lr}
48 stmgeia ip!, {r1, r3, r8, lr}
49 stmgeia ip!, {r1, r3, r8, lr}
51 ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
53 * No need to correct the count; we're only testing bits from now on
56 stmneia ip!, {r1, r3, r8, lr}
57 stmneia ip!, {r1, r3, r8, lr}
59 stmneia ip!, {r1, r3, r8, lr}
66 * This version aligns the destination pointer in order to write
67 * whole cache lines at once.
70 stmfd sp!, {r4-r8, lr}
73 UNWIND( .save {r4-r8, lr} )
88 movs r8, r8, lsl #(32 - 4)
89 stmcsia ip!, {r4, r5, r6, r7}
96 stmgeia ip!, {r1, r3-r8, lr}
97 stmgeia ip!, {r1, r3-r8, lr}
99 ldmeqfd sp!, {r4-r8, pc}
102 stmneia ip!, {r1, r3-r8, lr}
105 ldmfd sp!, {r4-r8, lr}
112 stmneia ip!, {r1, r3}
116 * When we get here, we've got less than 4 bytes to zero. We
117 * may have an unaligned pointer as well.
126 6: subs r2, r2, #4 @ 1 do we have enough
127 blt 5b @ 1 bytes to align with?
129 strltb r1, [ip], #1 @ 1
130 strleb r1, [ip], #1 @ 1
131 strb r1, [ip], #1 @ 1
132 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))