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>
14 .section .noinstr.text, "ax"
16 SYM_FUNC_START(memcpy)
18 * Some CPUs support hardware unaligned access
20 ALTERNATIVE "b __memcpy_generic", \
21 "b __memcpy_fast", CPU_FEATURE_UAL
23 SYM_FUNC_ALIAS(__memcpy, memcpy)
26 EXPORT_SYMBOL(__memcpy)
29 _ASM_NOKPROBE(__memcpy)
32 * void *__memcpy_generic(void *dst, const void *src, size_t n)
38 SYM_FUNC_START(__memcpy_generic)
51 SYM_FUNC_END(__memcpy_generic)
52 _ASM_NOKPROBE(__memcpy_generic)
55 SYM_FUNC_START_NOALIGN(__memcpy_small)
111 SYM_FUNC_END(__memcpy_small)
112 _ASM_NOKPROBE(__memcpy_small)
115 * void *__memcpy_fast(void *dst, const void *src, size_t n)
121 SYM_FUNC_START(__memcpy_fast)
123 bnez t0, __memcpy_small
130 /* align up destination address */
140 /* copy 64 bytes at a time */
160 bltu a1, a4, .Lloop64
162 /* copy the remaining bytes */
199 SYM_FUNC_END(__memcpy_fast)
200 _ASM_NOKPROBE(__memcpy_fast)
202 STACK_FRAME_NON_STANDARD __memcpy_small