tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / arch / arm64 / memmove.S
blobfc704f7ed506521adff686bef8c68ab9c8893ebb
1 /*
2  * Copyright (C) 2013 ARM Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
14 #include <arch/asm.h>
16  * Move a buffer from src to test (alignment handled by the hardware).
17  * If dest <= src, call memcpy, otherwise copy in reverse order.
18  *
19  * Parameters:
20  *      x0 - dest
21  *      x1 - src
22  *      x2 - n
23  * Returns:
24  *      x0 - dest
25  */
26 ENTRY(memmove)
27         cmp     x0, x1
28         b.ls    memcpy
29         add     x4, x0, x2
30         add     x1, x1, x2
31         subs    x2, x2, #8
32         b.mi    2f
33 1:      ldr     x3, [x1, #-8]!
34         subs    x2, x2, #8
35         str     x3, [x4, #-8]!
36         b.pl    1b
37 2:      adds    x2, x2, #4
38         b.mi    3f
39         ldr     w3, [x1, #-4]!
40         sub     x2, x2, #4
41         str     w3, [x4, #-4]!
42 3:      adds    x2, x2, #2
43         b.mi    4f
44         ldrh    w3, [x1, #-2]!
45         sub     x2, x2, #2
46         strh    w3, [x4, #-2]!
47 4:      adds    x2, x2, #1
48         b.mi    5f
49         ldrb    w3, [x1, #-1]
50         strb    w3, [x4, #-1]
51 5:      ret
52 ENDPROC(memmove)