blob: 0cea55d88bda92bac482493b527ef203f9d6087b [file] [log] [blame]
Furquan Shaikh2af76f42014-04-28 16:39:40 -07001/*
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 <arch/asm.h>
18
19/*
20 * Fill in the buffer with character c (alignment handled by the hardware)
21 *
22 * Parameters:
23 * x0 - buf
24 * x1 - c
25 * x2 - n
26 * Returns:
27 * x0 - buf
28 */
29ENTRY(memset)
30 mov x4, x0
31 and w1, w1, #0xff
32 orr w1, w1, w1, lsl #8
33 orr w1, w1, w1, lsl #16
34 orr x1, x1, x1, lsl #32
35 subs x2, x2, #8
36 b.mi 2f
371: str x1, [x4], #8
38 subs x2, x2, #8
39 b.pl 1b
402: adds x2, x2, #4
41 b.mi 3f
42 sub x2, x2, #4
43 str w1, [x4], #4
443: adds x2, x2, #2
45 b.mi 4f
46 sub x2, x2, #2
47 strh w1, [x4], #2
484: adds x2, x2, #1
49 b.mi 5f
50 strb w1, [x4]
515: ret
52ENDPROC(memset)