SetMem.asm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ;------------------------------------------------------------------------------
  2. ;
  3. ; SetMem() 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. It was updated to do 32-byte at a time.
  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. Set Buffer to Value for Size bytes.
  20. @param Buffer Memory to set.
  21. @param Length Number of bytes to set
  22. @param Value Value of the set operation.
  23. @return Buffer
  24. VOID *
  25. EFIAPI
  26. InternalMemSetMem (
  27. OUT VOID *Buffer,
  28. IN UINTN Length,
  29. IN UINT8 Value
  30. )
  31. **/
  32. EXPORT InternalMemSetMem
  33. AREA AsmMemStuff, CODE, READONLY
  34. InternalMemSetMem
  35. stmfd sp!, {r4-r11, lr}
  36. tst r0, #3
  37. movne r3, #0
  38. moveq r3, #1
  39. cmp r1, #31
  40. movls lr, #0
  41. andhi lr, r3, #1
  42. cmp lr, #0
  43. mov r12, r0
  44. bne L31
  45. L32
  46. mov r3, #0
  47. b L43
  48. L31
  49. and r4, r2, #0xff
  50. orr r4, r4, r4, LSL #8
  51. orr r4, r4, r4, LSL #16
  52. mov r5, r4
  53. mov r6, r4
  54. mov r7, r4
  55. mov r8, r4
  56. mov r9, r4
  57. mov r10, r4
  58. mov r11, r4
  59. b L32
  60. L34
  61. cmp lr, #0
  62. streqb r2, [r12], #1
  63. subeq r1, r1, #1
  64. beq L43
  65. sub r1, r1, #32
  66. cmp r1, #31
  67. movls lr, r3
  68. stmia r12!, {r4-r11}
  69. L43
  70. cmp r1, #0
  71. bne L34
  72. ldmfd sp!, {r4-r11, pc}
  73. END