CopyMem.asm 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ;------------------------------------------------------------------------------
  2. ;
  3. ; CopyMem() worker for ARM
  4. ;
  5. ; This file started out as C code that did 64 bit moves if the buffer was
  6. ; 32-bit aligned, else it does a byte copy. It also does a byte copy for
  7. ; any trailing bytes. Update using VSTM/SLDM to do 128 byte copies.
  8. ;
  9. ; Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
  10. ; This program and the accompanying materials
  11. ; are licensed and made available under the terms and conditions of the BSD License
  12. ; which accompanies this distribution. The full text of the license may be found at
  13. ; http://opensource.org/licenses/bsd-license.php
  14. ;
  15. ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  16. ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  17. ;
  18. ;------------------------------------------------------------------------------
  19. /**
  20. Copy Length bytes from Source to Destination. Overlap is OK.
  21. This implementation
  22. @param Destination Target of copy
  23. @param Source Place to copy from
  24. @param Length Number of bytes to copy
  25. @return Destination
  26. VOID *
  27. EFIAPI
  28. InternalMemCopyMem (
  29. OUT VOID *DestinationBuffer,
  30. IN CONST VOID *SourceBuffer,
  31. IN UINTN Length
  32. )
  33. **/
  34. EXPORT InternalMemCopyMem
  35. AREA AsmMemStuff, CODE, READONLY
  36. InternalMemCopyMem
  37. stmfd sp!, {r4, r9, lr}
  38. tst r0, #3
  39. mov r4, r0
  40. mov r9, r0
  41. mov ip, r2
  42. mov lr, r1
  43. movne r0, #0
  44. bne L4
  45. tst r1, #3
  46. movne r3, #0
  47. moveq r3, #1
  48. cmp r2, #127
  49. movls r0, #0
  50. andhi r0, r3, #1
  51. L4
  52. cmp r4, r1
  53. bcc L26
  54. bls L7
  55. rsb r3, r1, r4
  56. cmp ip, r3
  57. bcc L26
  58. cmp ip, #0
  59. beq L7
  60. add r9, r4, ip
  61. add lr, ip, r1
  62. b L16
  63. L29
  64. sub ip, ip, #8
  65. cmp ip, #7
  66. ldrd r2, [lr, #-8]!
  67. movls r0, #0
  68. cmp ip, #0
  69. strd r2, [r9, #-8]!
  70. beq L7
  71. L16
  72. cmp r0, #0
  73. bne L29
  74. sub r3, lr, #1
  75. sub ip, ip, #1
  76. ldrb r3, [r3, #0]
  77. sub r2, r9, #1
  78. cmp ip, #0
  79. sub r9, r9, #1
  80. sub lr, lr, #1
  81. strb r3, [r2, #0]
  82. bne L16
  83. b L7
  84. L11
  85. ldrb r3, [lr], #1
  86. sub ip, ip, #1
  87. strb r3, [r9], #1
  88. L26
  89. cmp ip, #0
  90. beq L7
  91. L30
  92. cmp r0, #0
  93. beq L11
  94. sub ip, ip, #128 // 32
  95. cmp ip, #127 // 31
  96. vldm lr!, {d0-d15}
  97. movls r0, #0
  98. cmp ip, #0
  99. vstm r9!, {d0-d15}
  100. bne L30
  101. L7
  102. dsb
  103. mov r0, r4
  104. ldmfd sp!, {r4, r9, pc}
  105. END