Debian Codegraph @

src/arch/arm64/memset.S

raw
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 */
15 ENTRY(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
23 1: str x1, [x4], #8
24 subs x2, x2, #8
25 b.pl 1b
26 2: adds x2, x2, #4
27 b.mi 3f
28 sub x2, x2, #4
29 str w1, [x4], #4
30 3: adds x2, x2, #2
31 b.mi 4f
32 sub x2, x2, #2
33 strh w1, [x4], #2
34 4: adds x2, x2, #1
35 b.mi 5f
36 strb w1, [x4]
37 5: ret
38 ENDPROC(memset)