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>
13 .section .noinstr.text, "ax"
15 SYM_FUNC_START(memmove)
16 blt a0, a1, __memcpy /* dst < src, memcpy */
17 blt a1, a0, __rmemcpy /* src < dst, rmemcpy */
18 jr ra /* dst == src, return */
20 SYM_FUNC_ALIAS(__memmove, memmove)
22 EXPORT_SYMBOL(memmove)
23 EXPORT_SYMBOL(__memmove)
25 _ASM_NOKPROBE(memmove)
26 _ASM_NOKPROBE(__memmove)
28 SYM_FUNC_START(__rmemcpy)
30 * Some CPUs support hardware unaligned access
32 ALTERNATIVE "b __rmemcpy_generic", \
33 "b __rmemcpy_fast", CPU_FEATURE_UAL
34 SYM_FUNC_END(__rmemcpy)
35 _ASM_NOKPROBE(__rmemcpy)
38 * void *__rmemcpy_generic(void *dst, const void *src, size_t n)
44 SYM_FUNC_START(__rmemcpy_generic)
60 SYM_FUNC_END(__rmemcpy_generic)
61 _ASM_NOKPROBE(__rmemcpy_generic)
64 * void *__rmemcpy_fast(void *dst, const void *src, size_t n)
70 SYM_FUNC_START(__rmemcpy_fast)
72 bnez t0, __memcpy_small
79 /* align up destination address */
87 /* copy 64 bytes at a time */
107 bltu a4, a3, .Lloop64
109 /* copy the remaining bytes */
146 SYM_FUNC_END(__rmemcpy_fast)
147 _ASM_NOKPROBE(__rmemcpy_fast)