aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/lib/memmove.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm64/lib/memmove.S')
-rw-r--r--arch/arm64/lib/memmove.S57
1 files changed, 57 insertions, 0 deletions
diff --git a/arch/arm64/lib/memmove.S b/arch/arm64/lib/memmove.S
new file mode 100644
index 000000000000..b79fdfa42d39
--- /dev/null
+++ b/arch/arm64/lib/memmove.S
@@ -0,0 +1,57 @@
1/*
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 <linux/linkage.h>
18#include <asm/assembler.h>
19
20/*
21 * Move a buffer from src to test (alignment handled by the hardware).
22 * If dest <= src, call memcpy, otherwise copy in reverse order.
23 *
24 * Parameters:
25 * x0 - dest
26 * x1 - src
27 * x2 - n
28 * Returns:
29 * x0 - dest
30 */
31ENTRY(memmove)
32 cmp x0, x1
33 b.ls memcpy
34 add x4, x0, x2
35 add x1, x1, x2
36 subs x2, x2, #8
37 b.mi 2f
381: ldr x3, [x1, #-8]!
39 subs x2, x2, #8
40 str x3, [x4, #-8]!
41 b.pl 1b
422: adds x2, x2, #4
43 b.mi 3f
44 ldr w3, [x1, #-4]!
45 sub x2, x2, #4
46 str w3, [x4, #-4]!
473: adds x2, x2, #2
48 b.mi 4f
49 ldrh w3, [x1, #-2]!
50 sub x2, x2, #2
51 strh w3, [x4, #-2]!
524: adds x2, x2, #1
53 b.mi 5f
54 ldrb w3, [x1, #-1]
55 strb w3, [x4, #-1]
565: ret
57ENDPROC(memmove)