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>
19 1: subs r2, r2, #4 @ 1 do we have enough
20 blt 5f @ 1 bytes to align with?
22 strltb r1, [ip], #1 @ 1
23 strleb r1, [ip], #1 @ 1
25 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))
27 * The pointer is now aligned and the length is adjusted. Try doing the
33 * Preserve the contents of r0 for the return value.
36 ands r3, ip, #3 @ 1 unaligned?
39 * we know that the pointer in ip is aligned to a word boundary.
41 orr r1, r1, r1, lsl #8
42 orr r1, r1, r1, lsl #16
50 * We need 2 extra registers for this loop - use r8 and the LR
57 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
58 stmgeia ip!, {r1, r3, r8, lr}
59 stmgeia ip!, {r1, r3, r8, lr}
60 stmgeia ip!, {r1, r3, r8, lr}
62 ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
64 * No need to correct the count; we're only testing bits from now on
67 stmneia ip!, {r1, r3, r8, lr}
68 stmneia ip!, {r1, r3, r8, lr}
70 stmneia ip!, {r1, r3, r8, lr}
76 * This version aligns the destination pointer in order to write
77 * whole cache lines at once.
80 stmfd sp!, {r4-r8, lr}
95 movs r8, r8, lsl #(32 - 4)
96 stmcsia ip!, {r4, r5, r6, r7}
103 stmgeia ip!, {r1, r3-r8, lr}
104 stmgeia ip!, {r1, r3-r8, lr}
106 ldmeqfd sp!, {r4-r8, pc}
109 stmneia ip!, {r1, r3-r8, lr}
112 ldmfd sp!, {r4-r8, lr}
117 stmneia ip!, {r1, r3}
121 * When we get here, we've got less than 4 bytes to zero. We
122 * may have an unaligned pointer as well.