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