1 #------------------------------------------------------------------------------
3 # CopyMem() worker for ARM
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 copies using stm/ldm.
9 # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
10 # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
11 # This program and the accompanying materials
12 # are licensed and made available under the terms and conditions of the BSD License
13 # which accompanies this distribution. The full text of the license may be found at
14 # http://opensource.org/licenses/bsd-license.php
16 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #------------------------------------------------------------------------------
26 Copy Length bytes from Source to Destination. Overlap is OK.
30 @param Destination Target of copy
31 @param Source Place to copy from
32 @param Length Number of bytes to copy
40 OUT VOID *DestinationBuffer,
41 IN CONST VOID *SourceBuffer,
45 ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
46 ASM_PFX(InternalMemCopyMem):
48 // Save the input parameters in extra registers (r11 = destination, r14 = source, r12 = length)
56 bcc memcopy_check_optim_default
58 // If (source + length < dest)
61 bcc memcopy_check_optim_default
62 b memcopy_check_optim_overlap
64 memcopy_check_optim_default:
65 // Check if we can use an optimized path ((length >= 32) && destination word-aligned && source word-aligned) for the memcopy (optimized path if r0 == 1)
82 memcopy_check_optim_overlap:
83 // r10 = dest_end, r14 = source_end
87 // Are we in the optimized case ((length >= 32) && dest_end word-aligned && source_end word-aligned)
101 memcopy_overlapped_non_optim:
102 // We read 1 byte from the end of the source buffer
108 // We write 1 byte at the end of the dest buffer
112 bne memcopy_overlapped_non_optim
115 // r10 = dest_end, r14 = source_end
117 // Are we in the optimized case ?
119 beq memcopy_overlapped_non_optim
121 // Optimized Overlapped - Read 32 bytes
127 // If length is less than 32 then disable optim
133 // Optimized Overlapped - Write 32 bytes
137 // while (length != 0)
138 bne memcopy_overlapped
141 memcopy_default_non_optim:
151 // r10 = dest, r14 = source
152 memcopy_default_loop:
154 beq memcopy_default_non_optim
156 // Optimized memcopy - Read 32 Bytes
161 // If length is less than 32 then disable optim
167 // Optimized memcopy - Write 32 Bytes
170 // while (length != 0)
171 bne memcopy_default_loop