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