1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3#include <arch/asm.h> 4 5/* 6 * Copy a buffer from src to dest (alignment handled by the hardware) 7 * 8 * Parameters: 9 * x0 - dest 10 * x1 - src 11 * x2 - n 12 * Returns: 13 * x0 - dest 14 */ 15ENTRY(memcpy) 16 mov x4, x0 17 subs x2, x2, #8 18 b.mi 2f 191: ldr x3, [x1], #8 20 subs x2, x2, #8 21 str x3, [x4], #8 22 b.pl 1b 232: adds x2, x2, #4 24 b.mi 3f 25 ldr w3, [x1], #4 26 sub x2, x2, #4 27 str w3, [x4], #4 283: adds x2, x2, #2 29 b.mi 4f 30 ldrh w3, [x1], #2 31 sub x2, x2, #2 32 strh w3, [x4], #2 334: adds x2, x2, #1 34 b.mi 5f 35 ldrb w3, [x1] 36 strb w3, [x4] 375: ret 38ENDPROC(memcpy) 39