diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2013-03-21 12:16:43 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2013-03-21 13:39:29 -0400 |
commit | 4a8992271c843cb5bcd3321bf6a02eb251280b1d (patch) | |
tree | 100bdf14109f0d6b6ac559db6f25a337daa4280c /arch/arm64/lib/memcpy.S | |
parent | 792072066d30372772137be9ee2f4d72d77329f9 (diff) |
arm64: klib: Optimised memory functions
This patch introduces AArch64-specific memory functions (memcpy,
memmove, memchr, memset). These functions are not optimised for any CPU
implementation but can be used as a starting point once hardware is
available.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/lib/memcpy.S')
-rw-r--r-- | arch/arm64/lib/memcpy.S | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/arm64/lib/memcpy.S b/arch/arm64/lib/memcpy.S new file mode 100644 index 000000000000..27b5003609b6 --- /dev/null +++ b/arch/arm64/lib/memcpy.S | |||
@@ -0,0 +1,53 @@ | |||
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 | */ | ||
30 | ENTRY(memcpy) | ||
31 | mov x4, x0 | ||
32 | subs x2, x2, #8 | ||
33 | b.mi 2f | ||
34 | 1: ldr x3, [x1], #8 | ||
35 | subs x2, x2, #8 | ||
36 | str x3, [x4], #8 | ||
37 | b.pl 1b | ||
38 | 2: adds x2, x2, #4 | ||
39 | b.mi 3f | ||
40 | ldr w3, [x1], #4 | ||
41 | sub x2, x2, #4 | ||
42 | str w3, [x4], #4 | ||
43 | 3: adds x2, x2, #2 | ||
44 | b.mi 4f | ||
45 | ldrh w3, [x1], #2 | ||
46 | sub x2, x2, #2 | ||
47 | strh w3, [x4], #2 | ||
48 | 4: adds x2, x2, #1 | ||
49 | b.mi 5f | ||
50 | ldrb w3, [x1] | ||
51 | strb w3, [x4] | ||
52 | 5: ret | ||
53 | ENDPROC(memcpy) | ||