]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Implementation of the EfiCopyMem routine. This function is broken\r | |
3 | out into its own source file so that it can be excluded from a\r | |
4 | build for a particular platform easily if an optimized version\r | |
5 | is desired.\r | |
6 | \r | |
7 | Copyright (c) 2006, Intel Corporation<BR>\r | |
8 | All rights reserved. This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | \r | |
16 | Module Name: EfiCopyMem.c\r | |
17 | \r | |
18 | **/\r | |
19 | \r | |
58251024 | 20 | #include "MemLibInternals.h"\r |
21 | \r | |
878ddf1f | 22 | /**\r |
23 | Copy Length bytes from Source to Destination.\r | |
24 | \r | |
25 | @param Destination Target of copy\r | |
26 | @param Source Place to copy from\r | |
27 | @param Length Number of bytes to copy\r | |
28 | \r | |
29 | @return Destination\r | |
30 | \r | |
31 | **/\r | |
32 | VOID *\r | |
33 | EFIAPI\r | |
34 | InternalMemCopyMem (\r | |
35 | OUT VOID *Destination,\r | |
36 | IN CONST VOID *Source,\r | |
37 | IN UINTN Length\r | |
38 | )\r | |
39 | {\r | |
40 | //\r | |
41 | // Declare the local variables that actually move the data elements as\r | |
42 | // volatile to prevent the optimizer from replacing this function with\r | |
43 | // the intrinsic memcpy()\r | |
44 | //\r | |
45 | volatile UINT8 *Destination8;\r | |
46 | CONST UINT8 *Source8;\r | |
47 | \r | |
48 | if (Source > Destination) {\r | |
49 | Destination8 = (UINT8*)Destination;\r | |
50 | Source8 = (CONST UINT8*)Source;\r | |
51 | while (Length-- != 0) {\r | |
52 | *(Destination8++) = *(Source8++);\r | |
53 | }\r | |
54 | } else if (Source < Destination) {\r | |
55 | Destination8 = (UINT8*)Destination + Length;\r | |
56 | Source8 = (CONST UINT8*)Source + Length;\r | |
57 | while (Length-- != 0) {\r | |
58 | *(--Destination8) = *(--Source8);\r | |
59 | }\r | |
60 | }\r | |
61 | return Destination;\r | |
62 | }\r |