]>
Commit | Line | Data |
---|---|---|
631f060b | 1 | /** @file\r |
2 | CopyMem() implementation.\r | |
3 | \r | |
2bfb6009 | 4 | The following BaseMemoryLib instances contain the same copy of this file:\r |
9095d37b | 5 | \r |
631f060b | 6 | BaseMemoryLib\r |
7 | BaseMemoryLibMmx\r | |
8 | BaseMemoryLibSse2\r | |
9 | BaseMemoryLibRepStr\r | |
2bfb6009 LG |
10 | BaseMemoryLibOptDxe\r |
11 | BaseMemoryLibOptPei\r | |
631f060b | 12 | PeiMemoryLib\r |
1fef058f | 13 | UefiMemoryLib\r |
631f060b | 14 | \r |
9095d37b | 15 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 16 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
631f060b | 17 | \r |
eb1c78db | 18 | **/\r |
631f060b | 19 | \r |
20 | #include "MemLibInternals.h"\r | |
21 | \r | |
22 | /**\r | |
23 | Copies a source buffer to a destination buffer, and returns the destination buffer.\r | |
24 | \r | |
25 | This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns\r | |
26 | DestinationBuffer. The implementation must be reentrant, and it must handle the case\r | |
27 | where SourceBuffer overlaps DestinationBuffer.\r | |
9095d37b | 28 | \r |
eb1c78db | 29 | If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r |
30 | If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r | |
631f060b | 31 | \r |
2fc59a00 | 32 | @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r |
33 | @param SourceBuffer The pointer to the source buffer of the memory copy.\r | |
34 | @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r | |
631f060b | 35 | \r |
36 | @return DestinationBuffer.\r | |
37 | \r | |
38 | **/\r | |
39 | VOID *\r | |
40 | EFIAPI\r | |
41 | CopyMem (\r | |
42 | OUT VOID *DestinationBuffer,\r | |
43 | IN CONST VOID *SourceBuffer,\r | |
44 | IN UINTN Length\r | |
45 | )\r | |
46 | {\r | |
2bfb6009 | 47 | if (Length == 0) {\r |
631f060b | 48 | return DestinationBuffer;\r |
49 | }\r | |
50 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r | |
51 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r | |
52 | \r | |
53 | if (DestinationBuffer == SourceBuffer) {\r | |
54 | return DestinationBuffer;\r | |
55 | }\r | |
56 | return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);\r | |
57 | }\r |