blob: 8916ddab5c6714acc672f919671724bbcc4a5809 [file] [log] [blame]
Patrick Georgi0a3d4e02020-03-04 14:39:09 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Furquan Shaikh464f5ca2015-06-08 10:31:55 -07002
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)