]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/CompilerIntrinsicesLib: Fixed memmove() and memset()
authorOlivier Martin <olivier.martin@arm.com>
Tue, 11 Nov 2014 00:52:11 +0000 (00:52 +0000)
committeroliviermartin <oliviermartin@Edk2>
Tue, 11 Nov 2014 00:52:11 +0000 (00:52 +0000)
- Fixed memmove when going backward: the copy started one byte
  after the end of the region to copy
- memset: - removed unused register
          - fixed arguments size and character arguments were
            actually reversed
- Added memmove() to ARM32 GCC

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16328 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S [new file with mode: 0644]
ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.asm
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
new file mode 100644 (file)
index 0000000..79f95b0
--- /dev/null
@@ -0,0 +1,48 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+  .text\r
+  .align 2\r
+  GCC_ASM_EXPORT (memmove)\r
+\r
+# VOID\r
+# EFIAPI\r
+# memmove (\r
+#  IN  VOID          *Destination,\r
+#  IN  CONST VOID    *Source,\r
+#  IN  UINT32        Size\r
+#  );\r
+ASM_PFX(memmove):\r
+  CMP     r2, #0\r
+  BXEQ    lr\r
+  CMP     r0, r1\r
+  BXEQ    lr\r
+  BHI     memmove_backward\r
+\r
+memmove_forward:\r
+  LDRB    r3, [r1], #1\r
+  STRB    r3, [r0], #1\r
+  SUBS    r2, r2, #1\r
+  BXEQ    lr\r
+  B       memmove_forward\r
+\r
+memmove_backward:\r
+  add     r0, r2\r
+  add     r1, r2\r
+memmove_backward_loop:\r
+  LDRB    r3, [r1, #-1]!\r
+  STRB    r3, [r0, #-1]!\r
+  SUBS    r2, r2, #1\r
+  BXEQ    lr\r
+  B       memmove_backward_loop\r
index ff7552d1c642aa133b666bf04fd76d34bc0467a7..2147e29dbd26b3a00f2be35a9403159497c97942 100755 (executable)
@@ -1,6 +1,6 @@
 //------------------------------------------------------------------------------\r
 //\r
-// Copyright (c) 2011, ARM Limited. All rights reserved.\r
+// Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
 //\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
 ;\r
 __aeabi_memmove\r
   CMP     r2, #0\r
-  BXEQ    r14\r
+  BXEQ    lr\r
   CMP     r0, r1\r
-  BXEQ    r14\r
+  BXEQ    lr\r
   BHI     memmove_backward\r
-  BLS     memmove_forward\r
 \r
 memmove_forward\r
   LDRB    r3, [r1], #1\r
   STRB    r3, [r0], #1\r
   SUBS    r2, r2, #1\r
-  BXEQ    r14\r
-  B       memmove_forward\r
+  BNE     memmove_forward\r
+  BX      lr\r
 \r
 memmove_backward\r
   add     r0, r2\r
   add     r1, r2\r
 memmove_backward_loop\r
-  LDRB    r3, [r1], #-1\r
-  STRB    r3, [r0], #-1\r
-  SUBS    r2, r2, #-1\r
-  BXEQ    r14\r
-  B       memmove_backward_loop\r
+  LDRB    r3, [r1, #-1]!\r
+  STRB    r3, [r0, #-1]!\r
+  SUBS    r2, r2, #1\r
+  BNE     memmove_backward_loop\r
+  BX      lr\r
 \r
   END\r
index 7290e859586470c3771d5297fabb289a651f3352..0c7789eb58165a982962eb00cab511c534881662 100644 (file)
@@ -1,6 +1,7 @@
 #------------------------------------------------------------------------------\r
 #\r
 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+# Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
   .align 2\r
   GCC_ASM_EXPORT (memset)\r
 \r
-\r
+# VOID\r
+# EFIAPI\r
+# memset (\r
+#  IN  VOID    *Destination,\r
+#  IN  UINT32  Character,\r
+#  IN  UINT32  Size\r
+#  );\r
 ASM_PFX(memset):\r
-\r
+  cmp  r2, #0\r
+  bxeq lr\r
   @ args = 0, pretend = 0, frame = 0\r
   @ frame_needed = 1, uses_anonymous_args = 0\r
-  stmfd  sp!, {r7, lr}\r
-  mov  ip, #0\r
-  add  r7, sp, #0\r
-  mov  lr, r0\r
-  b  L9\r
 L10:\r
-  and  r3, r1, #255\r
-  add  ip, ip, #1\r
-  strb  r3, [lr], #1\r
-L9:\r
-  cmp  ip, r2\r
+  strb  r1, [r0], #1\r
+  subs  r2, r2, #1\r
+  @ While size is not 0\r
   bne  L10\r
-  ldmfd  sp!, {r7, pc}\r
-\r
+  bx   lr\r
index 74e02430483cf0c090cd8e09350f19fa58b5c904..bae3c1fada11a4176dbeaaaf86edbf19690bb1dd 100755 (executable)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------\r
 //\r
 // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+// Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r
 //\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
 \r
     AREA    Memset, CODE, READONLY\r
 \r
+; void __aeabi_memclr4(void *dest, size_t n);\r
+; void __aeabi_memclr(void *dest, size_t n);\r
+__aeabi_memclr\r
+__aeabi_memclr4\r
+  mov   r2, #0\r
+\r
 ;\r
 ;VOID\r
 ;EFIAPI\r
 ;__aeabi_memset (\r
 ; IN  VOID    *Destination,\r
-; IN  UINT32  Character,\r
-; IN  UINT32  Size\r
+; IN  UINT32  Size,\r
+; IN  UINT32  Character\r
 ; );\r
 ;\r
 __aeabi_memset\r
-\r
+  cmp  r1, #0\r
+  bxeq lr\r
   ; args = 0, pretend = 0, frame = 0\r
   ; frame_needed = 1, uses_anonymous_args = 0\r
-  stmfd  sp!, {r7, lr}\r
-  mov  ip, #0\r
-  add  r7, sp, #0\r
-  mov  lr, r0\r
-  b  L9\r
 L10\r
-  and  r3, r1, #255\r
-  add  ip, ip, #1\r
-  strb  r3, [lr], #1\r
-L9\r
-  cmp  ip, r2\r
+  strb  r2, [r0], #1\r
+  subs  r1, r1, #1\r
+  ; While size is not 0\r
   bne  L10\r
-  ldmfd  sp!, {r7, pc}\r
-\r
-__aeabi_memclr\r
-  mov   r2, r1\r
-  mov   r1, #0\r
-  b     __aeabi_memset\r
-\r
-__aeabi_memclr4\r
-  mov   r2, r1\r
-  mov   r1, #0\r
-  b     __aeabi_memset\r
+  bx   lr\r
 \r
   END\r
index a1c9ae65b05b72239c34139bf8be787eb5035ba8..3487787a9c36afd561068acc1320c2de4d842bad 100644 (file)
@@ -60,6 +60,7 @@
 \r
   Arm/memcpy.S     | GCC\r
   Arm/memset.S     | GCC\r
+  Arm/memmove.S    | GCC\r
 \r
 #  Arm/modsi3.c     | GCC\r
 #  Arm/moddi3.c     | GCC\r