]>
Commit | Line | Data |
---|---|---|
3402aac7 | 1 | #------------------------------------------------------------------------------\r |
d39eb83c | 2 | #\r |
3 | # CopyMem() worker for ARM\r | |
4 | #\r | |
5 | # This file started out as C code that did 64 bit moves if the buffer was\r | |
6 | # 32-bit aligned, else it does a byte copy. It also does a byte copy for\r | |
7 | # any trailing bytes. Update using VSTM/SLDM to do 128 byte copies.\r | |
8 | #\r | |
d6ebcab7 HT |
9 | # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r |
10 | # This program and the accompanying materials\r | |
d39eb83c | 11 | # are licensed and made available under the terms and conditions of the BSD License\r |
12 | # which accompanies this distribution. The full text of the license may be found at\r | |
13 | # http://opensource.org/licenses/bsd-license.php\r | |
14 | #\r | |
15 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
16 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
17 | #\r | |
18 | #------------------------------------------------------------------------------\r | |
19 | \r | |
7589d9db AB |
20 | #include <AsmMacroIoLib.h>\r |
21 | \r | |
d39eb83c | 22 | /**\r |
23 | Copy Length bytes from Source to Destination. Overlap is OK.\r | |
24 | \r | |
3402aac7 | 25 | This implementation\r |
d39eb83c | 26 | \r |
27 | @param Destination Target of copy\r | |
28 | @param Source Place to copy from\r | |
29 | @param Length Number of bytes to copy\r | |
30 | \r | |
31 | @return Destination\r | |
32 | \r | |
33 | \r | |
34 | VOID *\r | |
35 | EFIAPI\r | |
36 | InternalMemCopyMem (\r | |
37 | OUT VOID *DestinationBuffer,\r | |
38 | IN CONST VOID *SourceBuffer,\r | |
39 | IN UINTN Length\r | |
40 | )\r | |
41 | **/\r | |
7589d9db | 42 | ASM_FUNC(InternalMemCopyMem)\r |
2ac288f9 | 43 | stmfd sp!, {r4, r9, lr}\r |
44 | tst r0, #3\r | |
45 | mov r4, r0\r | |
46 | mov r9, r0\r | |
47 | mov ip, r2\r | |
48 | mov lr, r1\r | |
49 | movne r0, #0\r | |
50 | bne L4\r | |
51 | tst r1, #3\r | |
52 | movne r3, #0\r | |
53 | moveq r3, #1\r | |
54 | cmp r2, #127\r | |
55 | movls r0, #0\r | |
56 | andhi r0, r3, #1\r | |
d39eb83c | 57 | L4:\r |
2ac288f9 | 58 | cmp r4, r1\r |
59 | bcc L26\r | |
60 | bls L7\r | |
61 | rsb r3, r1, r4\r | |
62 | cmp ip, r3\r | |
63 | bcc L26\r | |
64 | cmp ip, #0\r | |
65 | beq L7\r | |
66 | add r9, r4, ip\r | |
67 | add lr, ip, r1\r | |
68 | b L16\r | |
d39eb83c | 69 | L29:\r |
2ac288f9 | 70 | sub ip, ip, #8\r |
71 | cmp ip, #7\r | |
72 | ldrd r2, [lr, #-8]!\r | |
73 | movls r0, #0\r | |
74 | cmp ip, #0\r | |
75 | strd r2, [r9, #-8]!\r | |
76 | beq L7\r | |
d39eb83c | 77 | L16:\r |
2ac288f9 | 78 | cmp r0, #0\r |
79 | bne L29\r | |
80 | sub r3, lr, #1\r | |
81 | sub ip, ip, #1\r | |
3402aac7 | 82 | ldrb r3, [r3, #0]\r |
2ac288f9 | 83 | sub r2, r9, #1\r |
84 | cmp ip, #0\r | |
85 | sub r9, r9, #1\r | |
86 | sub lr, lr, #1\r | |
87 | strb r3, [r2, #0]\r | |
88 | bne L16\r | |
89 | b L7\r | |
d39eb83c | 90 | L11:\r |
3402aac7 | 91 | ldrb r3, [lr], #1\r |
2ac288f9 | 92 | sub ip, ip, #1\r |
93 | strb r3, [r9], #1\r | |
d39eb83c | 94 | L26:\r |
2ac288f9 | 95 | cmp ip, #0\r |
96 | beq L7\r | |
d39eb83c | 97 | L30:\r |
2ac288f9 | 98 | cmp r0, #0\r |
99 | beq L11\r | |
100 | sub ip, ip, #128 // 32\r | |
101 | cmp ip, #127 // 31\r | |
102 | vldm lr!, {d0-d15}\r | |
103 | movls r0, #0\r | |
104 | cmp ip, #0\r | |
105 | vstm r9!, {d0-d15}\r | |
106 | bne L30\r | |
d39eb83c | 107 | L7:\r |
108 | dsb\r | |
2ac288f9 | 109 | mov r0, r4\r |
110 | ldmfd sp!, {r4, r9, pc}\r | |
d39eb83c | 111 | \r |
3402aac7 | 112 | \r |