1 /* Modified by Broadcom Corp. Portions Copyright (c) Broadcom Corp, 2012. */
3 * linux/arch/arm/lib/memset.S
5 * Copyright (C) 1995-2000 Russell King
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.
11 * ASM optimised string functions
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
17 .section .text.fastpath, "a"
21 1: subs r2, r2, #4 @ 1 do we have enough
22 blt 5f @ 1 bytes to align with?
24 strltb r1, [r0], #1 @ 1
25 strleb 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
34 ands r3, r0, #3 @ 1 unaligned?
37 * we know that the pointer in r0 is aligned to a word boundary.
39 orr r1, r1, r1, lsl #8
40 orr r1, r1, r1, lsl #16
48 * We need an extra register for this loop - save the return address and
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}
61 ldmeqfd sp!, {pc} @ Now <64 bytes to go.
63 * No need to correct the count; we're only testing bits from now on
66 stmneia r0!, {r1, r3, ip, lr}
67 stmneia r0!, {r1, r3, ip, lr}
69 stmneia r0!, {r1, r3, ip, lr}
75 * This version aligns the destination pointer in order to write
76 * whole cache lines at once.
79 stmfd sp!, {r4-r7, lr}
94 movs ip, ip, lsl #(32 - 4)
95 stmcsia r0!, {r4, r5, r6, r7}
102 stmgeia r0!, {r1, r3-r7, ip, lr}
103 stmgeia r0!, {r1, r3-r7, ip, lr}
105 ldmeqfd sp!, {r4-r7, pc}
108 stmneia r0!, {r1, r3-r7, ip, lr}
111 ldmfd sp!, {r4-r7, lr}
116 stmneia r0!, {r1, r3}
120 * When we get here, we've got less than 4 bytes to zero. We
121 * may have an unaligned pointer as well.