xref: /openbmc/linux/arch/arm64/lib/memcpy.S (revision 12eb4683)
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 * Copy a buffer from src to dest (alignment handled by the hardware)
22 *
23 * Parameters:
24 *	x0 - dest
25 *	x1 - src
26 *	x2 - n
27 * Returns:
28 *	x0 - dest
29 */
30ENTRY(memcpy)
31	mov	x4, x0
32	subs	x2, x2, #8
33	b.mi	2f
341:	ldr	x3, [x1], #8
35	subs	x2, x2, #8
36	str	x3, [x4], #8
37	b.pl	1b
382:	adds	x2, x2, #4
39	b.mi	3f
40	ldr	w3, [x1], #4
41	sub	x2, x2, #4
42	str	w3, [x4], #4
433:	adds	x2, x2, #2
44	b.mi	4f
45	ldrh	w3, [x1], #2
46	sub	x2, x2, #2
47	strh	w3, [x4], #2
484:	adds	x2, x2, #1
49	b.mi	5f
50	ldrb	w3, [x1]
51	strb	w3, [x4]
525:	ret
53ENDPROC(memcpy)
54