blob: 5b61b31053edc772a4e8a952c7a28cefb69ff75a [file] [log] [blame]
Furquan Shaikh464f5ca2015-06-08 10:31:55 -07001/*
Martin Roth96c075a2019-07-28 19:50:52 -06002 * This file is part of the coreboot project.
Furquan Shaikh464f5ca2015-06-08 10:31:55 -07003 *
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.
Furquan Shaikh464f5ca2015-06-08 10:31:55 -070012 */
13
14#include <arch/asm.h>
15
16/*
17 * Fill in the buffer with character c (alignment handled by the hardware)
18 *
19 * Parameters:
20 * x0 - buf
21 * x1 - c
22 * x2 - n
23 * Returns:
24 * x0 - buf
25 */
26ENTRY(memset)
27 mov x4, x0
28 and w1, w1, #0xff
29 orr w1, w1, w1, lsl #8
30 orr w1, w1, w1, lsl #16
31 orr x1, x1, x1, lsl #32
32 subs x2, x2, #8
33 b.mi 2f
341: str x1, [x4], #8
35 subs x2, x2, #8
36 b.pl 1b
372: adds x2, x2, #4
38 b.mi 3f
39 sub x2, x2, #4
40 str w1, [x4], #4
413: adds x2, x2, #2
42 b.mi 4f
43 sub x2, x2, #2
44 strh w1, [x4], #2
454: adds x2, x2, #1
46 b.mi 5f
47 strb w1, [x4]
485: ret
49ENDPROC(memset)