1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Free Software Foundation, Inc.
11 * This file was originally part of the GNU C Library
12 * Contributed to glibc by MontaVista Software, Inc. (written by Nicolas Pitre)
13 * Adapted for Rockbox by Daniel Ankers
15 * All files in this archive are subject to the GNU General Public License.
16 * See the file COPYING in the source tree root for full license agreement.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
26 * Endian independent macros for shifting bytes within registers.
36 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
38 .section .icode,"ax",%progbits
42 .type memcpy,%function
45 stmfd sp!, {r0, r4, lr}
60 4: ldmia r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
62 stmia r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
67 addne pc, pc, ip @ C is always clear here
89 7: ldmfd sp!, {r5 - r8}
91 8: movs r2, r2, lsl #31
99 ldmfd sp!, {r0, r4, pc}
121 .macro forward_copy_shift pull push
126 11: stmfd sp!, {r5 - r9}
129 13: ldmia r1!, {r4, r5, r6, r7}
130 mov r3, lr, pull #\pull
132 ldmia r1!, {r8, r9, ip, lr}
133 orr r3, r3, r4, push #\push
134 mov r4, r4, pull #\pull
135 orr r4, r4, r5, push #\push
136 mov r5, r5, pull #\pull
137 orr r5, r5, r6, push #\push
138 mov r6, r6, pull #\pull
139 orr r6, r6, r7, push #\push
140 mov r7, r7, pull #\pull
141 orr r7, r7, r8, push #\push
142 mov r8, r8, pull #\pull
143 orr r8, r8, r9, push #\push
144 mov r9, r9, pull #\pull
145 orr r9, r9, ip, push #\push
146 mov ip, ip, pull #\pull
147 orr ip, ip, lr, push #\push
148 stmia r0!, {r3, r4, r5, r6, r7, r8, r9, ip}
156 15: mov r3, lr, pull #\pull
159 orr r3, r3, lr, push #\push
163 16: sub r1, r1, #(\push / 8)
169 forward_copy_shift pull=8 push=24
171 17: forward_copy_shift pull=16 push=16
173 18: forward_copy_shift pull=24 push=8