Patrick Georgi | 0a3d4e0 | 2020-03-04 14:39:09 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Furquan Shaikh | 464f5ca | 2015-06-08 10:31:55 -0700 | [diff] [blame] | 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) |