]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S
Update remaining ARM .S files with INTERWORK_FUNC macro. This is the 2nd half of...
[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 /**
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 .globl ASM_PFX(InternalMemCopyMem)
43 INTERWORK_FUNC(InternalMemCopyMem)
44
45 ASM_PFX(InternalMemCopyMem):
46 stmfd sp!, {r4, r9, lr}
47 tst r0, #3
48 mov r4, r0
49 mov r9, r0
50 mov ip, r2
51 mov lr, r1
52 movne r0, #0
53 bne L4
54 tst r1, #3
55 movne r3, #0
56 moveq r3, #1
57 cmp r2, #127
58 movls r0, #0
59 andhi r0, r3, #1
60 L4:
61 cmp r4, r1
62 bcc L26
63 bls L7
64 rsb r3, r1, r4
65 cmp ip, r3
66 bcc L26
67 cmp ip, #0
68 beq L7
69 add r9, r4, ip
70 add lr, ip, r1
71 b L16
72 L29:
73 sub ip, ip, #8
74 cmp ip, #7
75 ldrd r2, [lr, #-8]!
76 movls r0, #0
77 cmp ip, #0
78 strd r2, [r9, #-8]!
79 beq L7
80 L16:
81 cmp r0, #0
82 bne L29
83 sub r3, lr, #1
84 sub ip, ip, #1
85 ldrb r3, [r3, #0]
86 sub r2, r9, #1
87 cmp ip, #0
88 sub r9, r9, #1
89 sub lr, lr, #1
90 strb r3, [r2, #0]
91 bne L16
92 b L7
93 L11:
94 ldrb r3, [lr], #1
95 sub ip, ip, #1
96 strb r3, [r9], #1
97 L26:
98 cmp ip, #0
99 beq L7
100 L30:
101 cmp r0, #0
102 beq L11
103 sub ip, ip, #128 // 32
104 cmp ip, #127 // 31
105 vldm lr!, {d0-d15}
106 movls r0, #0
107 cmp ip, #0
108 vstm r9!, {d0-d15}
109 bne L30
110 L7:
111 dsb
112 mov r0, r4
113 ldmfd sp!, {r4, r9, pc}
114
115