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, [r0], #1 @ 1
23 strleb r1, [r0], #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
32 ands r3, r0, #3 @ 1 unaligned?
35 * we know that the pointer in r0 is aligned to a word boundary.
37 orr r1, r1, r1, lsl #8
38 orr r1, r1, r1, lsl #16
46 * We need an extra register for this loop - save the return address and
54 stmgeia r0!, {r1, r3, ip, lr} @ 64 bytes at a time.
55 stmgeia r0!, {r1, r3, ip, lr}
56 stmgeia r0!, {r1, r3, ip, lr}
57 stmgeia r0!, {r1, r3, ip, lr}
59 ldmeqfd sp!, {pc} @ Now <64 bytes to go.
61 * No need to correct the count; we're only testing bits from now on
64 stmneia r0!, {r1, r3, ip, lr}
65 stmneia r0!, {r1, r3, ip, lr}
67 stmneia r0!, {r1, r3, ip, lr}
73 * This version aligns the destination pointer in order to write
74 * whole cache lines at once.
77 stmfd sp!, {r4-r7, lr}
92 movs ip, ip, lsl #(32 - 4)
93 stmcsia r0!, {r4, r5, r6, r7}
100 stmgeia r0!, {r1, r3-r7, ip, lr}
101 stmgeia r0!, {r1, r3-r7, ip, lr}
103 ldmeqfd sp!, {r4-r7, pc}
106 stmneia r0!, {r1, r3-r7, ip, lr}
109 ldmfd sp!, {r4-r7, lr}
114 stmneia r0!, {r1, r3}
118 * When we get here, we've got less than 4 bytes to zero. We
119 * may have an unaligned pointer as well.