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