]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibSse2/CopyMemWrapper.c
CodeReview for MdePkg/BaseMemoryXXX libraries. Refine file description, function...
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / CopyMemWrapper.c
1 /** @file
2 CopyMem() implementation.
3
4 The following BaseMemoryLib instances contain the same copy of this file:
5 BaseMemoryLib
6 BaseMemoryLibMmx
7 BaseMemoryLibSse2
8 BaseMemoryLibRepStr
9 BaseMemoryLibOptDxe
10 BaseMemoryLibOptPei
11 PeiMemoryLib
12 DxeMemoryLib
13
14 Copyright (c) 2006, Intel Corporation<BR>
15 All rights reserved. This program and the accompanying materials
16 are licensed and made available under the terms and conditions of the BSD License
17 which accompanies this distribution. The full text of the license may be found at
18 http://opensource.org/licenses/bsd-license.php
19
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22
23 **/
24
25
26
27
28 #include "MemLibInternals.h"
29
30 /**
31 Copies a source buffer to a destination buffer, and returns the destination buffer.
32
33 This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
34 DestinationBuffer. The implementation must be reentrant, and it must handle the case
35 where SourceBuffer overlaps DestinationBuffer.
36 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
37 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
38
39 @param DestinationBuffer Pointer to the destination buffer of the memory copy.
40 @param SourceBuffer Pointer to the source buffer of the memory copy.
41 @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.
42
43 @return DestinationBuffer.
44
45 **/
46 VOID *
47 EFIAPI
48 CopyMem (
49 OUT VOID *DestinationBuffer,
50 IN CONST VOID *SourceBuffer,
51 IN UINTN Length
52 )
53 {
54 if (Length == 0) {
55 return DestinationBuffer;
56 }
57 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
58 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
59
60 if (DestinationBuffer == SourceBuffer) {
61 return DestinationBuffer;
62 }
63 return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);
64 }