arm64: percpu: implement optimised pcpu access using tpidr_el1
[pandora-kernel.git] / arch / arm64 / lib / memset.S
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)