copy_template.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (C) 2005-2017 Andes Technology Corporation
  3. beq $r1, $r0, quit_memcpy
  4. beqz $r2, quit_memcpy
  5. srli $r3, $r2, #5 ! check if len < cache-line size 32
  6. beqz $r3, word_copy_entry
  7. andi $r4, $r0, #0x3 ! check byte-align
  8. beqz $r4, unalign_word_copy_entry
  9. addi $r4, $r4,#-4
  10. abs $r4, $r4 ! check how many un-align byte to copy
  11. sub $r2, $r2, $r4 ! update $R2
  12. unalign_byte_copy:
  13. lbi1 $r3, $r1, #1
  14. addi $r4, $r4, #-1
  15. sbi1 $r3, $r0, #1
  16. bnez $r4, unalign_byte_copy
  17. beqz $r2, quit_memcpy
  18. unalign_word_copy_entry:
  19. andi $r3, $r0, 0x1f ! check cache-line unaligncount
  20. beqz $r3, cache_copy
  21. addi $r3, $r3, #-32
  22. abs $r3, $r3
  23. sub $r2, $r2, $r3 ! update $R2
  24. unalign_word_copy:
  25. lmw1 $r4, $r1, $r4
  26. addi $r3, $r3, #-4
  27. smw1 $r4, $r0, $r4
  28. bnez $r3, unalign_word_copy
  29. beqz $r2, quit_memcpy
  30. addi $r3, $r2, #-32 ! to check $r2< cache_line , than go to word_copy
  31. bltz $r3, word_copy_entry
  32. cache_copy:
  33. srli $r3, $r2, #5
  34. beqz $r3, word_copy_entry
  35. 3:
  36. lmw1 $r17, $r1, $r24
  37. addi $r3, $r3, #-1
  38. smw1 $r17, $r0, $r24
  39. bnez $r3, 3b
  40. word_copy_entry:
  41. andi $r2, $r2, #31
  42. beqz $r2, quit_memcpy
  43. 5:
  44. srli $r3, $r2, #2
  45. beqz $r3, byte_copy
  46. word_copy:
  47. lmw1 $r4, $r1, $r4
  48. addi $r3, $r3, #-1
  49. smw1 $r4, $r0, $r4
  50. bnez $r3, word_copy
  51. andi $r2, $r2, #3
  52. beqz $r2, quit_memcpy
  53. byte_copy:
  54. lbi1 $r3, $r1, #1
  55. addi $r2, $r2, #-1
  56. sbi1 $r3, $r0, #1
  57. bnez $r2, byte_copy
  58. quit_memcpy: