1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Thom Johansen
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 .section .icode,"ax",%progbits
25 /* The following code is based on code found in Linux kernel version 2.6.15.3
26 * linux/arch/arm/lib/memset.S
28 * Copyright (C) 1995-2000 Russell King
31 /* This code will align a pointer for memset, if needed */
32 1: cmp r2, #4 @ 1 do we have enough
33 blt 5f @ 1 bytes to align with?
35 strgtb r1, [r0, #-1]! @ 1
36 strgeb r1, [r0, #-1]! @ 1
37 strb r1, [r0, #-1]! @ 1
38 sub r2, r2, r3 @ 1 r2 = r2 - r3
42 .type memset,%function
44 add r0, r0, r2 @ we'll write backwards in memory
45 ands r3, r0, #3 @ 1 unaligned?
49 * we know that the pointer in r0 is aligned to a word boundary.
51 orr r1, r1, r1, lsl #8
52 orr r1, r1, r1, lsl #16
57 * We need an extra register for this loop - save the return address and
65 stmgedb r0!, {r1, r3, ip, lr} @ 64 bytes at a time.
66 stmgedb r0!, {r1, r3, ip, lr}
67 stmgedb r0!, {r1, r3, ip, lr}
68 stmgedb r0!, {r1, r3, ip, lr}
70 ldmeqfd sp!, {pc} @ Now <64 bytes to go.
72 * No need to correct the count; we're only testing bits from now on
75 stmnedb r0!, {r1, r3, ip, lr}
76 stmnedb r0!, {r1, r3, ip, lr}
78 stmnedb r0!, {r1, r3, ip, lr}
86 * When we get here, we've got less than 4 bytes to zero. We
87 * may have an unaligned pointer as well.
96 .size memset,.end-memset