blob: ccad4cf8ccbd343a1a785bc182d69724a0d186c0 [file] [log] [blame]
Furquan Shaikh2af76f42014-04-28 16:39:40 -07001/*
2 * Copyright (C) 2013 ARM Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <arch/asm.h>
18
19/*
20 * Copy a buffer from src to dest (alignment handled by the hardware)
21 *
22 * Parameters:
23 * x0 - dest
24 * x1 - src
25 * x2 - n
26 * Returns:
27 * x0 - dest
28 */
29ENTRY(memcpy)
30 mov x4, x0
31 subs x2, x2, #8
32 b.mi 2f
331: ldr x3, [x1], #8
34 subs x2, x2, #8
35 str x3, [x4], #8
36 b.pl 1b
372: adds x2, x2, #4
38 b.mi 3f
39 ldr w3, [x1], #4
40 sub x2, x2, #4
41 str w3, [x4], #4
423: adds x2, x2, #2
43 b.mi 4f
44 ldrh w3, [x1], #2
45 sub x2, x2, #2
46 strh w3, [x4], #2
474: adds x2, x2, #1
48 b.mi 5f
49 ldrb w3, [x1]
50 strb w3, [x4]
515: ret
52ENDPROC(memcpy)