Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* memmove.S: Simple memmove implementation. |
2 | * | |
3 | * Copyright (C) 1997, 2004 David S. Miller (davem@redhat.com) | |
4 | * Copyright (C) 1996, 1997, 1998, 1999 Jakub Jelinek (jj@ultra.linux.cz) | |
5 | */ | |
6 | ||
8695c37d DM |
7 | #include <linux/linkage.h> |
8 | ||
1da177e4 | 9 | .text |
8695c37d | 10 | ENTRY(memmove) /* o0=dst o1=src o2=len */ |
2077cef4 DM |
11 | brz,pn %o2, 99f |
12 | mov %o0, %g1 | |
13 | ||
1da177e4 | 14 | cmp %o0, %o1 |
2077cef4 | 15 | bleu,pt %xcc, 2f |
1da177e4 LT |
16 | add %o1, %o2, %g7 |
17 | cmp %g7, %o0 | |
18 | bleu,pt %xcc, memcpy | |
19 | add %o0, %o2, %o5 | |
20 | sub %g7, 1, %o1 | |
21 | ||
22 | sub %o5, 1, %o0 | |
23 | 1: ldub [%o1], %g7 | |
24 | subcc %o2, 1, %o2 | |
25 | sub %o1, 1, %o1 | |
26 | stb %g7, [%o0] | |
27 | bne,pt %icc, 1b | |
28 | sub %o0, 1, %o0 | |
2077cef4 | 29 | 99: |
1da177e4 LT |
30 | retl |
31 | mov %g1, %o0 | |
2077cef4 DM |
32 | |
33 | /* We can't just call memcpy for these memmove cases. On some | |
34 | * chips the memcpy uses cache initializing stores and when dst | |
35 | * and src are close enough, those can clobber the source data | |
36 | * before we've loaded it in. | |
37 | */ | |
38 | 2: or %o0, %o1, %g7 | |
39 | or %o2, %g7, %g7 | |
40 | andcc %g7, 0x7, %g0 | |
41 | bne,pn %xcc, 4f | |
42 | nop | |
43 | ||
44 | 3: ldx [%o1], %g7 | |
45 | add %o1, 8, %o1 | |
46 | subcc %o2, 8, %o2 | |
47 | add %o0, 8, %o0 | |
48 | bne,pt %icc, 3b | |
49 | stx %g7, [%o0 - 0x8] | |
50 | ba,a,pt %xcc, 99b | |
51 | ||
52 | 4: ldub [%o1], %g7 | |
53 | add %o1, 1, %o1 | |
54 | subcc %o2, 1, %o2 | |
55 | add %o0, 1, %o0 | |
56 | bne,pt %icc, 4b | |
57 | stb %g7, [%o0 - 0x1] | |
58 | ba,a,pt %xcc, 99b | |
8695c37d | 59 | ENDPROC(memmove) |