xref: /openbmc/linux/arch/arm64/lib/memcpy.S (revision ccb01374)
1/*
2 * Copyright (C) 2013 ARM Ltd.
3 * Copyright (C) 2013 Linaro.
4 *
5 * This code is based on glibc cortex strings work originally authored by Linaro
6 * and re-licensed under GPLv2 for the Linux kernel. The original code can
7 * be found @
8 *
9 * http://bazaar.launchpad.net/~linaro-toolchain-dev/cortex-strings/trunk/
10 * files/head:/src/aarch64/
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 */
24
25#include <linux/linkage.h>
26#include <asm/assembler.h>
27#include <asm/cache.h>
28
29/*
30 * Copy a buffer from src to dest (alignment handled by the hardware)
31 *
32 * Parameters:
33 *	x0 - dest
34 *	x1 - src
35 *	x2 - n
36 * Returns:
37 *	x0 - dest
38 */
39	.macro ldrb1 ptr, regB, val
40	ldrb  \ptr, [\regB], \val
41	.endm
42
43	.macro strb1 ptr, regB, val
44	strb \ptr, [\regB], \val
45	.endm
46
47	.macro ldrh1 ptr, regB, val
48	ldrh  \ptr, [\regB], \val
49	.endm
50
51	.macro strh1 ptr, regB, val
52	strh \ptr, [\regB], \val
53	.endm
54
55	.macro ldr1 ptr, regB, val
56	ldr \ptr, [\regB], \val
57	.endm
58
59	.macro str1 ptr, regB, val
60	str \ptr, [\regB], \val
61	.endm
62
63	.macro ldp1 ptr, regB, regC, val
64	ldp \ptr, \regB, [\regC], \val
65	.endm
66
67	.macro stp1 ptr, regB, regC, val
68	stp \ptr, \regB, [\regC], \val
69	.endm
70
71	.weak memcpy
72ENTRY(__memcpy)
73ENTRY(memcpy)
74#include "copy_template.S"
75	ret
76ENDPIPROC(memcpy)
77EXPORT_SYMBOL(memcpy)
78ENDPROC(__memcpy)
79EXPORT_SYMBOL(__memcpy)
80