diff options
Diffstat (limited to 'arch/arm64/lib')
-rw-r--r-- | arch/arm64/lib/Makefile | 3 | ||||
-rw-r--r-- | arch/arm64/lib/memchr.S | 44 | ||||
-rw-r--r-- | arch/arm64/lib/memcpy.S | 53 | ||||
-rw-r--r-- | arch/arm64/lib/memmove.S | 57 | ||||
-rw-r--r-- | arch/arm64/lib/memset.S | 53 |
5 files changed, 209 insertions, 1 deletions
diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index 2fb7f6092aae..2fce1398aa24 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | lib-y := bitops.o delay.o \ | 1 | lib-y := bitops.o delay.o \ |
2 | strncpy_from_user.o strnlen_user.o clear_user.o \ | 2 | strncpy_from_user.o strnlen_user.o clear_user.o \ |
3 | copy_from_user.o copy_to_user.o copy_in_user.o \ | 3 | copy_from_user.o copy_to_user.o copy_in_user.o \ |
4 | copy_page.o clear_page.o | 4 | copy_page.o clear_page.o \ |
5 | memchr.o memcpy.o memmove.o memset.o | ||
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) | ||
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) | ||
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 | */ | ||
31 | ENTRY(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 | ||
38 | 1: ldr x3, [x1, #-8]! | ||
39 | subs x2, x2, #8 | ||
40 | str x3, [x4, #-8]! | ||
41 | b.pl 1b | ||
42 | 2: adds x2, x2, #4 | ||
43 | b.mi 3f | ||
44 | ldr w3, [x1, #-4]! | ||
45 | sub x2, x2, #4 | ||
46 | str w3, [x4, #-4]! | ||
47 | 3: adds x2, x2, #2 | ||
48 | b.mi 4f | ||
49 | ldrh w3, [x1, #-2]! | ||
50 | sub x2, x2, #2 | ||
51 | strh w3, [x4, #-2]! | ||
52 | 4: adds x2, x2, #1 | ||
53 | b.mi 5f | ||
54 | ldrb w3, [x1, #-1] | ||
55 | strb w3, [x4, #-1] | ||
56 | 5: ret | ||
57 | ENDPROC(memmove) | ||
diff --git a/arch/arm64/lib/memset.S b/arch/arm64/lib/memset.S new file mode 100644 index 000000000000..87e4a68fbbbc --- /dev/null +++ b/arch/arm64/lib/memset.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 | * Fill in the buffer with character c (alignment handled by the hardware) | ||
22 | * | ||
23 | * Parameters: | ||
24 | * x0 - buf | ||
25 | * x1 - c | ||
26 | * x2 - n | ||
27 | * Returns: | ||
28 | * x0 - buf | ||
29 | */ | ||
30 | ENTRY(memset) | ||
31 | mov x4, x0 | ||
32 | and w1, w1, #0xff | ||
33 | orr w1, w1, w1, lsl #8 | ||
34 | orr w1, w1, w1, lsl #16 | ||
35 | orr x1, x1, x1, lsl #32 | ||
36 | subs x2, x2, #8 | ||
37 | b.mi 2f | ||
38 | 1: str x1, [x4], #8 | ||
39 | subs x2, x2, #8 | ||
40 | b.pl 1b | ||
41 | 2: adds x2, x2, #4 | ||
42 | b.mi 3f | ||
43 | sub x2, x2, #4 | ||
44 | str w1, [x4], #4 | ||
45 | 3: adds x2, x2, #2 | ||
46 | b.mi 4f | ||
47 | sub x2, x2, #2 | ||
48 | strh w1, [x4], #2 | ||
49 | 4: adds x2, x2, #1 | ||
50 | b.mi 5f | ||
51 | strb w1, [x4] | ||
52 | 5: ret | ||
53 | ENDPROC(memset) | ||