]>
Commit | Line | Data |
---|---|---|
c7f33ca4 | 1 | /*++\r |
2 | \r | |
4ea9375a HT |
3 | Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
c7f33ca4 | 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 | EfiCopyMemRep4.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | This is the code that uses rep movsd CopyMem service\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Tiano.h"\r | |
23 | \r | |
24 | VOID\r | |
25 | EfiCommonLibCopyMem (\r | |
26 | IN VOID *Destination,\r | |
27 | IN VOID *Source,\r | |
28 | IN UINTN Count\r | |
29 | )\r | |
30 | /*++\r | |
31 | \r | |
32 | Routine Description:\r | |
33 | \r | |
34 | Copy Length bytes from Source to Destination.\r | |
35 | \r | |
36 | Arguments:\r | |
37 | \r | |
38 | Destination - Target of copy\r | |
39 | \r | |
40 | Source - Place to copy from\r | |
41 | \r | |
42 | Length - Number of bytes to copy\r | |
43 | \r | |
44 | Returns:\r | |
45 | \r | |
46 | None\r | |
47 | \r | |
48 | --*/\r | |
49 | {\r | |
50 | __asm {\r | |
51 | mov esi, Source ; esi <- Source\r | |
52 | mov edi, Destination ; edi <- Destination\r | |
53 | mov edx, Count ; edx <- Count\r | |
54 | cmp esi, edi\r | |
55 | je _CopyDone\r | |
56 | cmp edx, 0\r | |
57 | je _CopyDone\r | |
58 | lea eax, [esi + edx - 1] ; eax <- End of Source\r | |
59 | cmp esi, edi\r | |
60 | jae _CopyDWord\r | |
61 | cmp eax, edi\r | |
62 | jae _CopyBackward ; Copy backward if overlapped\r | |
63 | _CopyDWord:\r | |
64 | mov ecx, edx\r | |
65 | and edx, 3\r | |
66 | shr ecx, 2\r | |
67 | rep movsd ; Copy as many Dwords as possible\r | |
68 | jmp _CopyBytes\r | |
69 | _CopyBackward:\r | |
70 | mov esi, eax ; esi <- End of Source\r | |
71 | lea edi, [edi + edx - 1] ; edi <- End of Destination\r | |
72 | std\r | |
73 | _CopyBytes:\r | |
74 | mov ecx, edx\r | |
75 | rep movsb ; Copy bytes backward\r | |
76 | cld\r | |
77 | _CopyDone:\r | |
78 | }\r | |
7ccf38a3 | 79 | }\r |