blob: 9cfbbb33d2151daf7d44067375b89c9a459976d8 [file] [log] [blame]
Furquan Shaikh464f5ca2015-06-08 10:31:55 -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.
Furquan Shaikh464f5ca2015-06-08 10:31:55 -070012 */
13
14#include <arch/asm.h>
15
16/*
17 * Copy a buffer from src to dest (alignment handled by the hardware)
18 *
19 * Parameters:
20 * x0 - dest
21 * x1 - src
22 * x2 - n
23 * Returns:
24 * x0 - dest
25 */
26ENTRY(memcpy)
27 mov x4, x0
28 subs x2, x2, #8
29 b.mi 2f
301: ldr x3, [x1], #8
31 subs x2, x2, #8
32 str x3, [x4], #8
33 b.pl 1b
342: adds x2, x2, #4
35 b.mi 3f
36 ldr w3, [x1], #4
37 sub x2, x2, #4
38 str w3, [x4], #4
393: adds x2, x2, #2
40 b.mi 4f
41 ldrh w3, [x1], #2
42 sub x2, x2, #2
43 strh w3, [x4], #2
444: adds x2, x2, #1
45 b.mi 5f
46 ldrb w3, [x1]
47 strb w3, [x4]
485: ret
49ENDPROC(memcpy)