1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 #include <linux/export.h>
7 #include <asm/alternative-asm.h>
9 #include <asm/asmmacro.h>
11 #include <asm/regdef.h>
12 #include <asm/unwind_hints.h>
15 bstrins.d \r0, \r0, 15, 8
16 bstrins.d \r0, \r0, 31, 16
17 bstrins.d \r0, \r0, 63, 32
20 .section .noinstr.text, "ax"
22 SYM_FUNC_START(memset)
24 * Some CPUs support hardware unaligned access
26 ALTERNATIVE "b __memset_generic", \
27 "b __memset_fast", CPU_FEATURE_UAL
29 SYM_FUNC_ALIAS(__memset, memset)
32 EXPORT_SYMBOL(__memset)
35 _ASM_NOKPROBE(__memset)
38 * void *__memset_generic(void *s, int c, size_t n)
44 SYM_FUNC_START(__memset_generic)
55 SYM_FUNC_END(__memset_generic)
56 _ASM_NOKPROBE(__memset_generic)
59 * void *__memset_fast(void *s, int c, size_t n)
65 SYM_FUNC_START(__memset_fast)
66 /* fill a1 to 64 bits */
75 /* align up address */
77 bstrins.d a3, zero, 2, 0
82 /* set 64 bytes at a time */
95 /* set the remaining bytes */
168 SYM_FUNC_END(__memset_fast)
169 _ASM_NOKPROBE(__memset_fast)
171 STACK_FRAME_NON_STANDARD __memset_fast