memcpy.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/linkage.h>
  17. #include <asm/assembler.h>
  18. /*
  19. * Copy a buffer from src to dest (alignment handled by the hardware)
  20. *
  21. * Parameters:
  22. * x0 - dest
  23. * x1 - src
  24. * x2 - n
  25. * Returns:
  26. * x0 - dest
  27. */
  28. ENTRY(memcpy)
  29. mov x4, x0
  30. subs x2, x2, #8
  31. b.mi 2f
  32. 1: ldr x3, [x1], #8
  33. subs x2, x2, #8
  34. str x3, [x4], #8
  35. b.pl 1b
  36. 2: adds x2, x2, #4
  37. b.mi 3f
  38. ldr w3, [x1], #4
  39. sub x2, x2, #4
  40. str w3, [x4], #4
  41. 3: adds x2, x2, #2
  42. b.mi 4f
  43. ldrh w3, [x1], #2
  44. sub x2, x2, #2
  45. strh w3, [x4], #2
  46. 4: adds x2, x2, #1
  47. b.mi 5f
  48. ldrb w3, [x1]
  49. strb w3, [x4]
  50. 5: ret
  51. ENDPROC(memcpy)