]>
Commit | Line | Data |
---|---|---|
1 | #------------------------------------------------------------------------------\r | |
2 | #\r | |
3 | # Copyright (c) 2006 - 2008, Intel Corporation\r | |
4 | # All rights reserved. This program and the accompanying materials\r | |
5 | # are licensed and made available under the terms and conditions of the BSD License\r | |
6 | # which accompanies this distribution. The full text of the license may be found at\r | |
7 | # http://opensource.org/licenses/bsd-license.php\r | |
8 | #\r | |
9 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | #\r | |
12 | # Module Name:\r | |
13 | #\r | |
14 | # CopyMem.S\r | |
15 | #\r | |
16 | # Abstract:\r | |
17 | #\r | |
18 | # CopyMem function\r | |
19 | #\r | |
20 | # Notes:\r | |
21 | #\r | |
22 | #------------------------------------------------------------------------------\r | |
23 | \r | |
24 | .globl ASM_PFX(InternalMemCopyMem)\r | |
25 | \r | |
26 | #------------------------------------------------------------------------------\r | |
27 | # VOID *\r | |
28 | # EFIAPI\r | |
29 | # InternalMemCopyMem (\r | |
30 | # IN VOID *Destination,\r | |
31 | # IN VOID *Source,\r | |
32 | # IN UINTN Count\r | |
33 | # );\r | |
34 | #------------------------------------------------------------------------------\r | |
35 | ASM_PFX(InternalMemCopyMem):\r | |
36 | push %esi\r | |
37 | push %edi\r | |
38 | movl 16(%esp), %esi # esi <- Source\r | |
39 | movl 12(%esp), %edi # edi <- Destination\r | |
40 | movl 20(%esp), %edx # edx <- Count\r | |
41 | leal -1(%esi,%edx,), %eax # eax <- End of Source\r | |
42 | cmpl %edi, %esi\r | |
43 | jae L0\r | |
44 | cmpl %edi, %eax # Overlapped?\r | |
45 | jae L_CopyBackward # Copy backward if overlapped\r | |
46 | L0:\r | |
47 | xorl %ecx, %ecx\r | |
48 | subl %edi, %ecx\r | |
49 | andl $15, %ecx # ecx + edi aligns on 16-byte boundary\r | |
50 | jz L1\r | |
51 | cmpl %edx, %ecx\r | |
52 | cmova %edx, %ecx\r | |
53 | subl %ecx, %edx # edx <- remaining bytes to copy\r | |
54 | rep\r | |
55 | movsb\r | |
56 | L1:\r | |
57 | movl %edx, %ecx\r | |
58 | andl $15, %edx\r | |
59 | shrl $4, %ecx # ecx <- # of DQwords to copy\r | |
60 | jz L_CopyBytes\r | |
61 | addl $-16, %esp\r | |
62 | movdqu %xmm0, (%esp)\r | |
63 | L2:\r | |
64 | movdqu (%esi), %xmm0\r | |
65 | movntdq %xmm0, (%edi)\r | |
66 | addl $16, %esi\r | |
67 | addl $16, %edi\r | |
68 | loop L2\r | |
69 | mfence\r | |
70 | movdqu (%esp),%xmm0\r | |
71 | addl $16, %esp # stack cleanup\r | |
72 | jmp L_CopyBytes\r | |
73 | L_CopyBackward:\r | |
74 | movl %eax, %esi # esi <- Last byte in Source\r | |
75 | leal -1(%edi,%edx,), %edi # edi <- Last byte in Destination\r | |
76 | std\r | |
77 | L_CopyBytes:\r | |
78 | movl %edx, %ecx\r | |
79 | rep\r | |
80 | movsb\r | |
81 | cld\r | |
82 | movl 12(%esp), %eax # eax <- Destination as return value\r | |
83 | pop %edi\r | |
84 | pop %esi\r | |
85 | ret\r |