memmove.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include <linux/linkage.h>
  7. #include <asm/export.h>
  8. .text
  9. ENTRY(memmove) /* o0=dst o1=src o2=len */
  10. brz,pn %o2, 99f
  11. mov %o0, %g1
  12. cmp %o0, %o1
  13. bleu,pt %xcc, 2f
  14. add %o1, %o2, %g7
  15. cmp %g7, %o0
  16. bleu,pt %xcc, memcpy
  17. add %o0, %o2, %o5
  18. sub %g7, 1, %o1
  19. sub %o5, 1, %o0
  20. 1: ldub [%o1], %g7
  21. subcc %o2, 1, %o2
  22. sub %o1, 1, %o1
  23. stb %g7, [%o0]
  24. bne,pt %icc, 1b
  25. sub %o0, 1, %o0
  26. 99:
  27. retl
  28. mov %g1, %o0
  29. /* We can't just call memcpy for these memmove cases. On some
  30. * chips the memcpy uses cache initializing stores and when dst
  31. * and src are close enough, those can clobber the source data
  32. * before we've loaded it in.
  33. */
  34. 2: or %o0, %o1, %g7
  35. or %o2, %g7, %g7
  36. andcc %g7, 0x7, %g0
  37. bne,pn %xcc, 4f
  38. nop
  39. 3: ldx [%o1], %g7
  40. add %o1, 8, %o1
  41. subcc %o2, 8, %o2
  42. add %o0, 8, %o0
  43. bne,pt %icc, 3b
  44. stx %g7, [%o0 - 0x8]
  45. ba,a,pt %xcc, 99b
  46. 4: ldub [%o1], %g7
  47. add %o1, 1, %o1
  48. subcc %o2, 1, %o2
  49. add %o0, 1, %o0
  50. bne,pt %icc, 4b
  51. stb %g7, [%o0 - 0x1]
  52. ba,a,pt %xcc, 99b
  53. ENDPROC(memmove)
  54. EXPORT_SYMBOL(memmove)