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 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
28 * Endian independent macros for shifting bytes within registers.
38 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
40 .section .icode,"ax",%progbits
44 .type memcpy,%function
47 stmfd sp!, {r0, r4, lr}
62 4: ldmia r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
64 stmia r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
69 addne pc, pc, ip @ C is always clear here
91 7: ldmfd sp!, {r5 - r8}
93 8: movs r2, r2, lsl #31
101 ldmfd sp!, {r0, r4, pc}
123 .macro forward_copy_shift pull push
128 11: stmfd sp!, {r5 - r9}
131 13: ldmia r1!, {r4, r5, r6, r7}
132 mov r3, lr, pull #\pull
134 ldmia r1!, {r8, r9, ip, lr}
135 orr r3, r3, r4, push #\push
136 mov r4, r4, pull #\pull
137 orr r4, r4, r5, push #\push
138 mov r5, r5, pull #\pull
139 orr r5, r5, r6, push #\push
140 mov r6, r6, pull #\pull
141 orr r6, r6, r7, push #\push
142 mov r7, r7, pull #\pull
143 orr r7, r7, r8, push #\push
144 mov r8, r8, pull #\pull
145 orr r8, r8, r9, push #\push
146 mov r9, r9, pull #\pull
147 orr r9, r9, ip, push #\push
148 mov ip, ip, pull #\pull
149 orr ip, ip, lr, push #\push
150 stmia r0!, {r3, r4, r5, r6, r7, r8, r9, ip}
158 15: mov r3, lr, pull #\pull
161 orr r3, r3, lr, push #\push
165 16: sub r1, r1, #(\push / 8)
171 forward_copy_shift pull=8 push=24
173 17: forward_copy_shift pull=16 push=16
175 18: forward_copy_shift pull=24 push=8