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