1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3#include <arch/asm.h> 4/* 5 * Move a buffer from src to test (alignment handled by the hardware). 6 * If dest <= src, call memcpy, otherwise copy in reverse order. 7 * 8 * Parameters: 9 * x0 - dest 10 * x1 - src 11 * x2 - n 12 * Returns: 13 * x0 - dest 14 */ 15ENTRY(memmove) 16 cmp x0, x1 17 b.ls memcpy 18 add x4, x0, x2 19 add x1, x1, x2 20 subs x2, x2, #8 21 b.mi 2f 221: ldr x3, [x1, #-8]! 23 subs x2, x2, #8 24 str x3, [x4, #-8]! 25 b.pl 1b 262: adds x2, x2, #4 27 b.mi 3f 28 ldr w3, [x1, #-4]! 29 sub x2, x2, #4 30 str w3, [x4, #-4]! 313: adds x2, x2, #2 32 b.mi 4f 33 ldrh w3, [x1, #-2]! 34 sub x2, x2, #2 35 strh w3, [x4, #-2]! 364: adds x2, x2, #1 37 b.mi 5f 38 ldrb w3, [x1, #-1] 39 strb w3, [x4, #-1] 405: ret 41ENDPROC(memmove) 42