src/arch/arm64/memcpy.S
raw| 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 | */ |
| 15 | ENTRY(memcpy) |
| 16 | mov x4, x0 |
| 17 | subs x2, x2, #8 |
| 18 | b.mi 2f |
| 19 | 1: ldr x3, [x1], #8 |
| 20 | subs x2, x2, #8 |
| 21 | str x3, [x4], #8 |
| 22 | b.pl 1b |
| 23 | 2: adds x2, x2, #4 |
| 24 | b.mi 3f |
| 25 | ldr w3, [x1], #4 |
| 26 | sub x2, x2, #4 |
| 27 | str w3, [x4], #4 |
| 28 | 3: adds x2, x2, #2 |
| 29 | b.mi 4f |
| 30 | ldrh w3, [x1], #2 |
| 31 | sub x2, x2, #2 |
| 32 | strh w3, [x4], #2 |
| 33 | 4: adds x2, x2, #1 |
| 34 | b.mi 5f |
| 35 | ldrb w3, [x1] |
| 36 | strb w3, [x4] |
| 37 | 5: ret |
| 38 | ENDPROC(memcpy) |