Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 7 | #include <linux/linkage.h> |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | .text |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 10 | ENTRY(memmove) /* o0=dst o1=src o2=len */ |
David S. Miller | 2077cef | 2015-03-23 09:22:10 -0700 | [diff] [blame] | 11 | brz,pn %o2, 99f |
| 12 | mov %o0, %g1 |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | cmp %o0, %o1 |
David S. Miller | 2077cef | 2015-03-23 09:22:10 -0700 | [diff] [blame] | 15 | bleu,pt %xcc, 2f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David S. Miller | 2077cef | 2015-03-23 09:22:10 -0700 | [diff] [blame] | 29 | 99: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | retl |
| 31 | mov %g1, %o0 |
David S. Miller | 2077cef | 2015-03-23 09:22:10 -0700 | [diff] [blame] | 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 |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 59 | ENDPROC(memmove) |