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/memchr.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/memchr.S')
-rw-r--r-- | arch/arm64/lib/memchr.S | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/arm64/lib/memchr.S b/arch/arm64/lib/memchr.S new file mode 100644 index 000000000000..8636b7549163 --- /dev/null +++ b/arch/arm64/lib/memchr.S | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Based on arch/arm/lib/memchr.S | ||
3 | * | ||
4 | * Copyright (C) 1995-2000 Russell King | ||
5 | * Copyright (C) 2013 ARM Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include <linux/linkage.h> | ||
21 | #include <asm/assembler.h> | ||
22 | |||
23 | /* | ||
24 | * Find a character in an area of memory. | ||
25 | * | ||
26 | * Parameters: | ||
27 | * x0 - buf | ||
28 | * x1 - c | ||
29 | * x2 - n | ||
30 | * Returns: | ||
31 | * x0 - address of first occurrence of 'c' or 0 | ||
32 | */ | ||
33 | ENTRY(memchr) | ||
34 | and w1, w1, #0xff | ||
35 | 1: subs x2, x2, #1 | ||
36 | b.mi 2f | ||
37 | ldrb w3, [x0], #1 | ||
38 | cmp w3, w1 | ||
39 | b.ne 1b | ||
40 | sub x0, x0, #1 | ||
41 | ret | ||
42 | 2: mov x0, #0 | ||
43 | ret | ||
44 | ENDPROC(memchr) | ||