Home | History | Annotate | Download | only in Arm
      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 /**
     21   Copy Length bytes from Source to Destination. Overlap is OK.
     22 
     23   This implementation
     24 
     25   @param  Destination Target of copy
     26   @param  Source      Place to copy from
     27   @param  Length      Number of bytes to copy
     28 
     29   @return Destination
     30 
     31 
     32 VOID *
     33 EFIAPI
     34 InternalMemCopyMem (
     35   OUT     VOID                      *DestinationBuffer,
     36   IN      CONST VOID                *SourceBuffer,
     37   IN      UINTN                     Length
     38   )
     39 **/
     40 .text
     41 .align 2
     42 GCC_ASM_EXPORT(InternalMemCopyMem)
     43 
     44 ASM_PFX(InternalMemCopyMem):
     45   stmfd  sp!, {r4, r9, lr}
     46   tst  r0, #3
     47   mov  r4, r0
     48   mov  r9, r0
     49   mov  ip, r2
     50   mov  lr, r1
     51   movne  r0, #0
     52   bne  L4
     53   tst  r1, #3
     54   movne  r3, #0
     55   moveq  r3, #1
     56   cmp  r2, #127
     57   movls  r0, #0
     58   andhi  r0, r3, #1
     59 L4:
     60   cmp  r4, r1
     61   bcc  L26
     62   bls  L7
     63   rsb  r3, r1, r4
     64   cmp  ip, r3
     65   bcc  L26
     66   cmp  ip, #0
     67   beq  L7
     68   add  r9, r4, ip
     69   add  lr, ip, r1
     70   b  L16
     71 L29:
     72   sub  ip, ip, #8
     73   cmp  ip, #7
     74   ldrd  r2, [lr, #-8]!
     75   movls  r0, #0
     76   cmp  ip, #0
     77   strd  r2, [r9, #-8]!
     78   beq  L7
     79 L16:
     80   cmp  r0, #0
     81   bne  L29
     82   sub  r3, lr, #1
     83   sub  ip, ip, #1
     84   ldrb  r3, [r3, #0]
     85   sub  r2, r9, #1
     86   cmp  ip, #0
     87   sub  r9, r9, #1
     88   sub  lr, lr, #1
     89   strb  r3, [r2, #0]
     90   bne  L16
     91   b   L7
     92 L11:
     93   ldrb  r3, [lr], #1
     94   sub  ip, ip, #1
     95   strb  r3, [r9], #1
     96 L26:
     97   cmp  ip, #0
     98   beq  L7
     99 L30:
    100   cmp  r0, #0
    101   beq  L11
    102   sub  ip, ip, #128          // 32
    103   cmp  ip, #127              // 31
    104   vldm     lr!, {d0-d15}
    105   movls  r0, #0
    106   cmp  ip, #0
    107   vstm  r9!, {d0-d15}
    108   bne  L30
    109 L7:
    110   dsb
    111   mov  r0, r4
    112   ldmfd  sp!, {r4, r9, pc}
    113 
    114 
    115