xref: /aosp_15_r20/external/coreboot/src/arch/arm64/memset.S (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <arch/asm.h>
4
5/*
6 * Fill in the buffer with character c (alignment handled by the hardware)
7 *
8 * Parameters:
9 *	x0 - buf
10 *	x1 - c
11 *	x2 - n
12 * Returns:
13 *	x0 - buf
14 */
15ENTRY(memset)
16	mov	x4, x0
17	and	w1, w1, #0xff
18	orr	w1, w1, w1, lsl #8
19	orr	w1, w1, w1, lsl #16
20	orr	x1, x1, x1, lsl #32
21	subs	x2, x2, #8
22	b.mi	2f
231:	str	x1, [x4], #8
24	subs	x2, x2, #8
25	b.pl	1b
262:	adds	x2, x2, #4
27	b.mi	3f
28	sub	x2, x2, #4
29	str	w1, [x4], #4
303:	adds	x2, x2, #2
31	b.mi	4f
32	sub	x2, x2, #2
33	strh	w1, [x4], #2
344:	adds	x2, x2, #1
35	b.mi	5f
36	strb	w1, [x4]
375:	ret
38ENDPROC(memset)
39